@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); }
@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 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 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); }
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(); }
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();  }