@Test public void shouldUpdateTrajectory1411() throws Exception { com.hashmapinc.tempus.WitsmlObjects.v1411.ObjTrajectory traj1411 = new com.hashmapinc.tempus.WitsmlObjects.v1411.ObjTrajectory(); traj1411.setUid("traj1411"); traj1411.setName("traj1411"); traj1411.setUidWellbore("wellbore1411"); traj1411.setUidWell("well1411"); String endpoint = this.url + this.trajectoryPath + traj1411.getUid(); HttpRequest req1411 = Unirest.put(endpoint); req1411.header("Content-Type", "application/json"); req1411.queryString("uidWellbore", traj1411.getUidWellbore()); req1411.queryString("uidWell", traj1411.getUidWell()); HttpResponse<String> resp = mock(HttpResponse.class); when(resp.getStatus()).thenReturn(200); when(this.mockClient.makeRequest(argThat(someReq -> ( someReq.getHttpMethod().name().equals(req1411.getHttpMethod().name()) && someReq.getUrl().equals(req1411.getUrl()) && someReq.getHeaders().containsKey("Content-Type") )), eq("goodUsername"), eq("goodPassword"), anyString())).thenReturn(resp); this.delegator.updateObject(traj1411, "goodUsername", "goodPassword", "exchangeID", this.mockClient); verify(this.mockClient).makeRequest(argThat(someReq -> ( someReq.getHttpMethod().name().equals(req1411.getHttpMethod().name()) && someReq.getUrl().equals(req1411.getUrl()) && someReq.getHeaders().containsKey("Content-Type") )), eq("goodUsername"), eq("goodPassword"), anyString()); }
public void updateObject(AbstractWitsmlObject witsmlObj, String username, String password, String exchangeID, DotClient client) throws ValveException, ValveAuthException, UnirestException, JsonProcessingException { String objectType = witsmlObj.getObjectType(); String version = witsmlObj.getVersion(); if ("fluidsReport".equalsIgnoreCase(objectType)) { updateFluidsReport(witsmlObj, username, password, exchangeID, client); } else { String payload; if ("1.4.1.1".equals(version)) { payload = witsmlObj.getJSONString("1.4.1.1"); } else { payload = witsmlObj.getJSONString("1.3.1.1"); } payload = JsonUtil.removeEmpties(new JSONObject(payload)); if (LOG_OBJECT.equals(objectType)) { updateLog(witsmlObj, username, password, exchangeID, client, payload); } else { String uid = witsmlObj.getUid(); String endpoint = this.getEndpoint(objectType) + uid; HttpRequestWithBody request = Unirest.put(endpoint); HttpResponse<String> response; request.header("Content-Type", "application/json"); if (payload.length() > 0) { request.body(payload); addQueryStringParams(objectType, request, witsmlObj); response = client.makeRequest(request, username, password, exchangeID); int status = response.getStatus(); if (201 == status || 200 == status) { LOG.info(ValveLogging.getLogRespMsg(exchangeID, "Successfully updated object with UID: " + uid, response)); } else { LOG.warning(ValveLogging.getLogRespMsg(exchangeID, "Failed to update object with UID: " + uid, response)); throw new ValveException(response.getBody()); } } } } }
DotDelegator { public void updateObject(AbstractWitsmlObject witsmlObj, String username, String password, String exchangeID, DotClient client) throws ValveException, ValveAuthException, UnirestException, JsonProcessingException { String objectType = witsmlObj.getObjectType(); String version = witsmlObj.getVersion(); if ("fluidsReport".equalsIgnoreCase(objectType)) { updateFluidsReport(witsmlObj, username, password, exchangeID, client); } else { String payload; if ("1.4.1.1".equals(version)) { payload = witsmlObj.getJSONString("1.4.1.1"); } else { payload = witsmlObj.getJSONString("1.3.1.1"); } payload = JsonUtil.removeEmpties(new JSONObject(payload)); if (LOG_OBJECT.equals(objectType)) { updateLog(witsmlObj, username, password, exchangeID, client, payload); } else { String uid = witsmlObj.getUid(); String endpoint = this.getEndpoint(objectType) + uid; HttpRequestWithBody request = Unirest.put(endpoint); HttpResponse<String> response; request.header("Content-Type", "application/json"); if (payload.length() > 0) { request.body(payload); addQueryStringParams(objectType, request, witsmlObj); response = client.makeRequest(request, username, password, exchangeID); int status = response.getStatus(); if (201 == status || 200 == status) { LOG.info(ValveLogging.getLogRespMsg(exchangeID, "Successfully updated object with UID: " + uid, response)); } else { LOG.warning(ValveLogging.getLogRespMsg(exchangeID, "Failed to update object with UID: " + uid, response)); throw new ValveException(response.getBody()); } } } } } }
DotDelegator { public void updateObject(AbstractWitsmlObject witsmlObj, String username, String password, String exchangeID, DotClient client) throws ValveException, ValveAuthException, UnirestException, JsonProcessingException { String objectType = witsmlObj.getObjectType(); String version = witsmlObj.getVersion(); if ("fluidsReport".equalsIgnoreCase(objectType)) { updateFluidsReport(witsmlObj, username, password, exchangeID, client); } else { String payload; if ("1.4.1.1".equals(version)) { payload = witsmlObj.getJSONString("1.4.1.1"); } else { payload = witsmlObj.getJSONString("1.3.1.1"); } payload = JsonUtil.removeEmpties(new JSONObject(payload)); if (LOG_OBJECT.equals(objectType)) { updateLog(witsmlObj, username, password, exchangeID, client, payload); } else { String uid = witsmlObj.getUid(); String endpoint = this.getEndpoint(objectType) + uid; HttpRequestWithBody request = Unirest.put(endpoint); HttpResponse<String> response; request.header("Content-Type", "application/json"); if (payload.length() > 0) { request.body(payload); addQueryStringParams(objectType, request, witsmlObj); response = client.makeRequest(request, username, password, exchangeID); int status = response.getStatus(); if (201 == status || 200 == status) { LOG.info(ValveLogging.getLogRespMsg(exchangeID, "Successfully updated object with UID: " + uid, response)); } else { LOG.warning(ValveLogging.getLogRespMsg(exchangeID, "Failed to update object with UID: " + uid, response)); throw new ValveException(response.getBody()); } } } } } DotDelegator(Map<String, String> config); }
DotDelegator { public void updateObject(AbstractWitsmlObject witsmlObj, String username, String password, String exchangeID, DotClient client) throws ValveException, ValveAuthException, UnirestException, JsonProcessingException { String objectType = witsmlObj.getObjectType(); String version = witsmlObj.getVersion(); if ("fluidsReport".equalsIgnoreCase(objectType)) { updateFluidsReport(witsmlObj, username, password, exchangeID, client); } else { String payload; if ("1.4.1.1".equals(version)) { payload = witsmlObj.getJSONString("1.4.1.1"); } else { payload = witsmlObj.getJSONString("1.3.1.1"); } payload = JsonUtil.removeEmpties(new JSONObject(payload)); if (LOG_OBJECT.equals(objectType)) { updateLog(witsmlObj, username, password, exchangeID, client, payload); } else { String uid = witsmlObj.getUid(); String endpoint = this.getEndpoint(objectType) + uid; HttpRequestWithBody request = Unirest.put(endpoint); HttpResponse<String> response; request.header("Content-Type", "application/json"); if (payload.length() > 0) { request.body(payload); addQueryStringParams(objectType, request, witsmlObj); response = client.makeRequest(request, username, password, exchangeID); int status = response.getStatus(); if (201 == status || 200 == status) { LOG.info(ValveLogging.getLogRespMsg(exchangeID, "Successfully updated object with UID: " + uid, response)); } else { LOG.warning(ValveLogging.getLogRespMsg(exchangeID, "Failed to update object with UID: " + uid, response)); 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); }
DotDelegator { public void updateObject(AbstractWitsmlObject witsmlObj, String username, String password, String exchangeID, DotClient client) throws ValveException, ValveAuthException, UnirestException, JsonProcessingException { String objectType = witsmlObj.getObjectType(); String version = witsmlObj.getVersion(); if ("fluidsReport".equalsIgnoreCase(objectType)) { updateFluidsReport(witsmlObj, username, password, exchangeID, client); } else { String payload; if ("1.4.1.1".equals(version)) { payload = witsmlObj.getJSONString("1.4.1.1"); } else { payload = witsmlObj.getJSONString("1.3.1.1"); } payload = JsonUtil.removeEmpties(new JSONObject(payload)); if (LOG_OBJECT.equals(objectType)) { updateLog(witsmlObj, username, password, exchangeID, client, payload); } else { String uid = witsmlObj.getUid(); String endpoint = this.getEndpoint(objectType) + uid; HttpRequestWithBody request = Unirest.put(endpoint); HttpResponse<String> response; request.header("Content-Type", "application/json"); if (payload.length() > 0) { request.body(payload); addQueryStringParams(objectType, request, witsmlObj); response = client.makeRequest(request, username, password, exchangeID); int status = response.getStatus(); if (201 == status || 200 == status) { LOG.info(ValveLogging.getLogRespMsg(exchangeID, "Successfully updated object with UID: " + uid, response)); } else { LOG.warning(ValveLogging.getLogRespMsg(exchangeID, "Failed to update object with UID: " + uid, response)); 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);  }