DotValve implements IValve { @Override @Async("asyncCustomTaskExecutor") public CompletableFuture<Boolean> deleteObject(QueryContext qc) throws ValveException { boolean result = false; if (qc.WITSML_OBJECTS.size() > 1) throw new ValveException("Delete cannot have more than one singular object per query", (short)-444); if (qc.WITSML_OBJECTS.size() == 0) throw new ValveException("Delete must have exactly one singluar object, but found 0 in the query"); try { AbstractWitsmlObject wmlObject = qc.WITSML_OBJECTS.get(0); if (wmlObject.getUid() == null || "".equals(wmlObject.getUid())){ throw new ValveException("Delete cannot have more than one singular object per query", (short)-415); } if (!isObjectDelete(wmlObject.getObjectType().toLowerCase(), qc.QUERY_XML.toLowerCase())){ this.DELEGATOR.performElementDelete(wmlObject, qc.USERNAME, qc.PASSWORD, qc.EXCHANGE_ID, this.CLIENT); result = true; } else { this.DELEGATOR.deleteObject(wmlObject, qc.USERNAME, qc.PASSWORD, qc.EXCHANGE_ID, this.CLIENT); result = true; } } catch (Exception e) { LOG.warning(ValveLogging.getLogMsg(qc.EXCHANGE_ID,"Exception in DotValve deleteObject: " + e.getMessage())); if (e.getClass() == ValveException.class) throw ((ValveException)e); throw new ValveException(e.getMessage()); } return CompletableFuture.completedFuture(result); } DotValve(Map<String, String> config);  DotValve(DotClient client, DotDelegator delegator); @Override String getName(); @Override String getDescription(); @Override String getObjectSelectionCapability(String WMLtypeIn); @Override @Async("asyncCustomTaskExecutor") CompletableFuture<String> getObject(QueryContext qc); static boolean trajHasSearchQueryArgs( QueryContext qc ); @Override @Async("asyncCustomTaskExecutor") CompletableFuture<String> createObject(QueryContext qc); @Override @Async("asyncCustomTaskExecutor") CompletableFuture<Boolean> deleteObject(QueryContext qc); @Override @Async("asyncCustomTaskExecutor") CompletableFuture<Boolean> updateObject(QueryContext qc); @Override void authenticate(String username, String password); Map<String, AbstractWitsmlObject[]> getCap();  }
@Test public void shouldDeleteSingleObject() throws Exception { ArrayList<AbstractWitsmlObject> witsmlObjects; witsmlObjects = new ArrayList<>(); ObjWellbores wmlObjWellbores = new ObjWellbores(); ObjWellbore wellboreA = new ObjWellbore(); wellboreA.setUid("wellbore-A"); witsmlObjects.add(wellboreA); wmlObjWellbores.addWellbore(wellboreA); QueryContext qc = new QueryContext( "1.3.1.1", "wellbore", null, WitsmlMarshal.serialize(wmlObjWellbores), witsmlObjects, "goodUsername", "goodPassword", "shouldDeleteSingleObject" ); this.valve.deleteObject(qc); verify(this.mockDelegator).deleteObject(wellboreA, qc.USERNAME, qc.PASSWORD, qc.EXCHANGE_ID, this.mockClient); verifyNoMoreInteractions(this.mockDelegator); }
@Test public void shouldDeleteLogRecurringElement() throws Exception { ArrayList<AbstractWitsmlObject> logs1311 = new ArrayList<>(); ArrayList<AbstractWitsmlObject> logs1411 = new ArrayList<>(); ObjLogs logsObj1311 = new ObjLogs(); com.hashmapinc.tempus.WitsmlObjects.v1411.ObjLogs logsObj1411 = new com.hashmapinc.tempus.WitsmlObjects.v1411.ObjLogs(); ObjLog log1311 = new ObjLog(); log1311.setUid("HM_800023"); log1311.setUidWell("U2"); log1311.setUidWellbore("WBDD600"); com.hashmapinc.tempus.WitsmlObjects.v1411.CsLogCurveInfo csLogCurveInfo = new com.hashmapinc.tempus.WitsmlObjects.v1411.CsLogCurveInfo(); csLogCurveInfo.setUid("lci-13"); List<com.hashmapinc.tempus.WitsmlObjects.v1411.CsLogCurveInfo> csLogCurveInfoList = new ArrayList<>(); csLogCurveInfoList.add(csLogCurveInfo); log1311.setLogCurveInfo(csLogCurveInfoList); logs1311.add(log1311); logsObj1311.addLog(log1311); com.hashmapinc.tempus.WitsmlObjects.v1411.ObjLog log1411 = new com.hashmapinc.tempus.WitsmlObjects.v1411.ObjLog(); log1411.setUid("HM_800023"); log1411.setUidWell("U2"); log1411.setUidWellbore("WBDD600"); csLogCurveInfo.setUid("lci-13"); csLogCurveInfoList.add(csLogCurveInfo); log1411.setLogCurveInfo(csLogCurveInfoList); logs1411.add(log1411); logsObj1411.addLog(log1411); QueryContext qc1311 = new QueryContext( "1.3.1.1", "log", null, WitsmlMarshal.serialize(logsObj1311), logs1311, "goodUsername", "goodPassword", "shouldDeleteLogRecurringElement-1311" ); QueryContext qc1411 = new QueryContext( "1.4.1.1", "log", null, WitsmlMarshal.serialize(logsObj1411), logs1411, "goodUsername", "goodPassword", "shouldDeleteLogRecurringElement-1411" ); this.valve.deleteObject(qc1311); this.valve.deleteObject(qc1411); verify(this.mockDelegator).deleteObject(log1311, qc1311.USERNAME, qc1311.PASSWORD, qc1311.EXCHANGE_ID, this.mockClient); verify(this.mockDelegator).deleteObject(log1411, qc1411.USERNAME, qc1411.PASSWORD, qc1411.EXCHANGE_ID, this.mockClient); verifyNoMoreInteractions(this.mockDelegator); }
@Test public void shouldDeleteLogSubNode() throws Exception { ArrayList<AbstractWitsmlObject> logs1311 = new ArrayList<>(); ArrayList<AbstractWitsmlObject> logs1411 = new ArrayList<>(); ObjLogs logsObj1311 = new ObjLogs(); com.hashmapinc.tempus.WitsmlObjects.v1411.ObjLogs logsObj1411 = new com.hashmapinc.tempus.WitsmlObjects.v1411.ObjLogs(); ObjLog log1311 = new ObjLog(); log1311.setUid("HM_800023"); log1311.setUidWell("U2"); log1311.setUidWellbore("WBDD600"); log1311.setServiceCompany(null); log1311.setRunNumber(null); logs1311.add(log1311); logsObj1311.addLog(log1311); com.hashmapinc.tempus.WitsmlObjects.v1411.ObjLog log1411 = new com.hashmapinc.tempus.WitsmlObjects.v1411.ObjLog(); log1411.setUid("HM_800023"); log1411.setUidWell("U2"); log1411.setUidWellbore("WBDD600"); log1411.setServiceCompany(null); log1411.setRunNumber(null); logs1411.add(log1411); logsObj1411.addLog(log1411); QueryContext qc1311 = new QueryContext( "1.3.1.1", "log", null, WitsmlMarshal.serialize(logsObj1311), logs1311, "goodUsername", "goodPassword", "shouldDeleteLogSubNode-1311" ); QueryContext qc1411 = new QueryContext( "1.4.1.1", "log", null, WitsmlMarshal.serialize(logsObj1411), logs1411, "goodUsername", "goodPassword", "shouldDeleteLogSubNode-1411" ); this.valve.deleteObject(qc1311); this.valve.deleteObject(qc1411); verify(this.mockDelegator).deleteObject(log1311, qc1311.USERNAME, qc1311.PASSWORD, qc1311.EXCHANGE_ID, this.mockClient); verify(this.mockDelegator).deleteObject(log1411, qc1411.USERNAME, qc1411.PASSWORD, qc1411.EXCHANGE_ID, this.mockClient); verifyNoMoreInteractions(this.mockDelegator); }
@Test public void shouldDeleteTrajectory() throws Exception { ArrayList<AbstractWitsmlObject> trajs1311 = new ArrayList<>(); ArrayList<AbstractWitsmlObject> trajs1411 = new ArrayList<>(); ObjTrajectorys trajsObj1311 = new ObjTrajectorys(); com.hashmapinc.tempus.WitsmlObjects.v1411.ObjTrajectorys trajsObj1411 = new com.hashmapinc.tempus.WitsmlObjects.v1411.ObjTrajectorys(); ObjTrajectory traj1311 = new ObjTrajectory(); traj1311.setUid("traj-1311"); trajs1311.add(traj1311); trajsObj1311.addTrajectory(traj1311); com.hashmapinc.tempus.WitsmlObjects.v1411.ObjTrajectory traj1411 = new com.hashmapinc.tempus.WitsmlObjects.v1411.ObjTrajectory(); traj1411.setUid("traj-1411"); trajs1411.add(traj1411); trajsObj1411.addTrajectory(traj1411); QueryContext qc1311 = new QueryContext( "1.3.1.1", "trajectory", null, WitsmlMarshal.serialize(trajsObj1311), trajs1311, "goodUsername", "goodPassword", "shouldDeleteTrajectory-1311" ); QueryContext qc1411 = new QueryContext( "1.4.1.1", "trajectory", null, WitsmlMarshal.serialize(trajsObj1411), trajs1411, "goodUsername", "goodPassword", "shouldDeleteTrajectory-1411" ); this.valve.deleteObject(qc1311); this.valve.deleteObject(qc1411); verify(this.mockDelegator).deleteObject(traj1311, qc1311.USERNAME, qc1311.PASSWORD, qc1311.EXCHANGE_ID, this.mockClient); verify(this.mockDelegator).deleteObject(traj1411, qc1411.USERNAME, qc1411.PASSWORD, qc1411.EXCHANGE_ID, this.mockClient); verifyNoMoreInteractions(this.mockDelegator); }
@Test(expected = ValveException.class) public void shouldNotDeletePluralObjectAndThrowException() throws Exception { ArrayList<AbstractWitsmlObject> witsmlObjects; witsmlObjects = new ArrayList<>(); ObjWellbores wmlObjWellbores = new ObjWellbores(); ObjWellbore wellboreA = new ObjWellbore(); wellboreA.setUid("wellbore-A"); witsmlObjects.add(wellboreA); wmlObjWellbores.addWellbore(wellboreA); ObjWellbore wellboreB = new ObjWellbore(); wellboreB.setUid("wellbore-B"); wmlObjWellbores.addWellbore(wellboreB); witsmlObjects.add(wellboreB); QueryContext qc = new QueryContext( "1.3.1.1", "wellbore", null, WitsmlMarshal.serialize(wmlObjWellbores), witsmlObjects, "goodUsername", "goodPassword", "shouldDeletePluralObject" ); this.valve.deleteObject(qc); verify(this.mockDelegator).deleteObject(wellboreA, qc.USERNAME, qc.PASSWORD, qc.EXCHANGE_ID, this.mockClient); verify(this.mockDelegator).deleteObject(wellboreB, qc.USERNAME, qc.PASSWORD, qc.EXCHANGE_ID, this.mockClient); verifyNoMoreInteractions(this.mockDelegator); }