DotDelegator { public ArrayList<AbstractWitsmlObject> search(AbstractWitsmlObject witsmlObject, String username, String password, String exchangeID, DotClient client, Map<String, String> optionsIn) throws ValveException, ValveAuthException, UnirestException, IOException, DatatypeConfigurationException, JAXBException { String objectType = witsmlObject.getObjectType(); if (objectType.equals("log")) return performLogSearch(witsmlObject, username, password, exchangeID, client, optionsIn); String endpoint = this.getEndpoint(objectType + "search"); String query; try { if ("trajectory".equals(objectType)) { String wellboreUuid = getParentWellboreUUID(witsmlObject, exchangeID, client, username, password); if (wellboreUuid == null) { return null; } query = GraphQLQueryConverter.getQuery(witsmlObject, wellboreUuid); } else { query = GraphQLQueryConverter.getQuery(witsmlObject); } } catch (Exception ex) { throw new ValveException(ex.getMessage()); } HttpRequestWithBody request = Unirest.post(endpoint); request.header("Content-Type", "application/json"); request.body(query); HttpResponse<String> response = client.makeRequest(request, username, password, exchangeID); int status = response.getStatus(); if (201 == status || 200 == status || 400 == status) { ArrayList<AbstractWitsmlObject> wmlResponses = GraphQLRespConverter.convert(response.getBody(), objectType); if (wmlResponses == null || wmlResponses.isEmpty()) return null; if ("trajectory".equals(objectType)) { for (AbstractWitsmlObject wmlResponse : wmlResponses) { ObjTrajectory trajResp = (ObjTrajectory) wmlResponse; trajResp.setUidWell(witsmlObject.getGrandParentUid()); trajResp.setUidWellbore(witsmlObject.getParentUid()); } } ArrayList<AbstractWitsmlObject> results = new ArrayList<>(); for (AbstractWitsmlObject wmlResponse : wmlResponses) { results.add(DotTranslator.translateQueryResponse(witsmlObject, wmlResponse.getJSONString("1.4.1.1"), optionsIn)); } return results; } else { throw new ValveException(response.getBody()); } } DotDelegator(Map<String, String> config); void deleteObject(AbstractWitsmlObject witsmlObj, String username, String password, String exchangeID,
			DotClient client); void performElementDelete(AbstractWitsmlObject witsmlObj, String username, String password,
			String exchangeID, DotClient client); void updateObject(AbstractWitsmlObject witsmlObj, String username, String password, String exchangeID,
			DotClient client); String updateFluidsReport(AbstractWitsmlObject witsmlObj, String username, String password,
			String exchangeID, DotClient client); void updateLog(AbstractWitsmlObject witsmlObj, String username, String password, String exchangeID,
			DotClient client, String payload); String getUuid(AbstractWitsmlObject witsmlObj, String uid, DotClient client, String username,
			String password, String exchangeID); String createObject(AbstractWitsmlObject witsmlObj, String username, String password, String exchangeID,
			DotClient client); String createFluidsReportObject(AbstractWitsmlObject witsmlObj, String username, String password,
			String exchangeID, DotClient client); String createLogObject(AbstractWitsmlObject witsmlObj, String username, String password, String exchangeID,
			DotClient client); static short mnemonicsChecks( String channelPayload,
										 String dataPayload,
										 String version ); HttpResponse<String> performPost(String payload, String endpoint, HashMap<String, String> requestParams,
			DotClient client, String username, String password, String exchangeID); String[] getMappedPayloads4Log(String version, String payload, AbstractWitsmlObject witsmlObj); AbstractWitsmlObject getObject(AbstractWitsmlObject witsmlObject, String username, String password,
			String exchangeID, DotClient client, Map<String, String> optionsIn); ArrayList<AbstractWitsmlObject> search(AbstractWitsmlObject witsmlObject, String username, String password,
			String exchangeID, DotClient client, Map<String, String> optionsIn);  }
@Test public void shouldFindWellsWithEmptyGraphQLQuery() throws Exception { String query = TestUtilities.getResourceAsString("well1311FullEmptyQuery.xml"); String response = TestUtilities.getResourceAsString("WellGraphQLResponseFull.json"); ObjWells queryObject = WitsmlMarshal.deserialize(query, ObjWells.class); AbstractWitsmlObject singleWell = queryObject.getWell().get(0); GraphQLQueryConverter converter = new GraphQLQueryConverter(); String jsonQuery = converter.getQuery(singleWell); assertNotNull(jsonQuery); String endpoint = this.url + this.graphQlWellPath; HttpRequestWithBody req = Unirest.post(endpoint); req.header("Content-Type", "application/json"); req.body(jsonQuery); HttpResponse<String> resp = mock(HttpResponse.class); when(resp.getBody()).thenReturn(response); when(resp.getStatus()).thenReturn(200); when(this.mockClient.makeRequest(argThat(someReq -> ( someReq.getHttpMethod().name().equals(req.getHttpMethod().name()) && someReq.getUrl().equals(req.getUrl()) && someReq.getHeaders().containsKey("Content-Type") )), eq("goodUsername"), eq("goodPassword"), anyString())).thenReturn(resp); ArrayList<AbstractWitsmlObject> foundObjects = this.delegator.search(singleWell, "goodUsername", "goodPassword", "exchangeID", this.mockClient, new HashMap<>()); assertEquals(3, foundObjects.size()); }