DotValve implements IValve { @Override @Async("asyncCustomTaskExecutor") public CompletableFuture<String> createObject(QueryContext qc) throws ValveException { ArrayList<String> uids = new ArrayList<>(); LOG.fine(ValveLogging.getLogMsg(qc.EXCHANGE_ID,"Async create object")); try { for (AbstractWitsmlObject witsmlObject : qc.WITSML_OBJECTS) { uids.add(this.DELEGATOR.createObject(witsmlObject, qc.USERNAME, qc.PASSWORD, qc.EXCHANGE_ID, this.CLIENT)); } } catch (ValveException e) { LOG.warning(ValveLogging.getLogMsg(qc.EXCHANGE_ID,"Exception in DotValve createObject: " + e.getMessage())); throw new ValveException(e.getMessage(), e.getErrorCode()); } catch (Exception e){ LOG.warning(ValveLogging.getLogMsg(qc.EXCHANGE_ID,"Exception in DotValve createObject: " + e.getMessage())); throw new ValveException(e.getMessage()); } return CompletableFuture.completedFuture(StringUtils.join(uids, ',')); } 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 shouldCreateSingleObject() throws Exception { ArrayList<AbstractWitsmlObject> witsmlObjects; witsmlObjects = new ArrayList<>(); ObjWellbore wellboreA = new ObjWellbore(); wellboreA.setName("wellbore-A"); wellboreA.setUid("wellbore-A"); witsmlObjects.add(wellboreA); QueryContext qc = new QueryContext( "1.3.1.1", "wellbore", null, "", witsmlObjects, "goodUsername", "goodPassword", "shouldCreateSingleObject" ); when( this.mockDelegator.createObject(wellboreA, qc.USERNAME, qc.PASSWORD, qc.EXCHANGE_ID, this.mockClient) ).thenReturn(wellboreA.getUid()); String expected = wellboreA.getUid(); String actual = this.valve.createObject(qc).get(); assertEquals(expected, actual); }
@Test public void shouldCreateTrajectory() throws Exception { ArrayList<AbstractWitsmlObject> witsmlObjects; witsmlObjects = new ArrayList<>(); ObjTrajectory traj = new ObjTrajectory(); traj.setUid("traj-A"); traj.setName("traj-A"); witsmlObjects.add(traj); QueryContext qc = new QueryContext( "1.3.1.1", "trajectory", null, "", witsmlObjects, "goodUsername", "goodPassword", "shouldCreateTrajectory" ); when( this.mockDelegator.createObject(traj, qc.USERNAME, qc.PASSWORD, qc.EXCHANGE_ID, this.mockClient) ).thenReturn(traj.getUid()); String expected = traj.getUid(); String actual = this.valve.createObject(qc).get(); assertEquals(expected, actual); }
@Test public void shouldCreatePluralObject() throws Exception { ArrayList<AbstractWitsmlObject> witsmlObjects; witsmlObjects = new ArrayList<>(); ObjWellbore wellboreA = new ObjWellbore(); wellboreA.setName("wellbore-A"); wellboreA.setUid("wellbore-A"); witsmlObjects.add(wellboreA); ObjWellbore wellboreB = new ObjWellbore(); wellboreB.setName("wellbore-B"); wellboreB.setUid("wellbore-B"); witsmlObjects.add(wellboreB); QueryContext qc = new QueryContext( "1.3.1.1", "wellbore", null, "", witsmlObjects, "goodUsername", "goodPassword", "shouldCreatePluralObject" ); when( this.mockDelegator.createObject(wellboreA, qc.USERNAME, qc.PASSWORD, qc.EXCHANGE_ID, this.mockClient) ).thenReturn(wellboreA.getUid()); when( this.mockDelegator.createObject(wellboreB, qc.USERNAME, qc.PASSWORD, qc.EXCHANGE_ID, this.mockClient) ).thenReturn(wellboreB.getUid()); String expected = wellboreA.getUid() + "," + wellboreB.getUid(); String actual = this.valve.createObject(qc).get(); assertEquals(expected, actual); }