DotTranslator { public static String consolidateObjectsToXML( ArrayList<AbstractWitsmlObject> witsmlObjects, String version, String objectType ) throws ValveException { if(!"1.3.1.1".equals(version) && !"1.4.1.1".equals(version)) { throw new ValveException("Unsupported client version <" + version + "> in DoT GET"); } String xmlString; switch (objectType.toLowerCase()) { case "well": xmlString = consolidateWellsToXML(witsmlObjects, version); break; case "wellbore": xmlString = consolidateWellboresToXML(witsmlObjects, version); break; case "trajectory": xmlString = consolidateTrajectoriesToXML(witsmlObjects, version); break; case "log": xmlString = consolidateLogsToXML(witsmlObjects, version); break; case "fluidsreport": xmlString = consolidateFluidsReportsToXML(witsmlObjects, version); break; default: throw new ValveException("Unsupported object type: " + witsmlObjects.get(0).getObjectType()); } return xmlString; }  static AbstractWitsmlObject get1311WitsmlObject(AbstractWitsmlObject wmlObj); static AbstractWitsmlObject translateQueryResponse( AbstractWitsmlObject wmlObject,
                                                               String jsonResponseString,
                                                               Map<String, String> optionsIn ); static AbstractWitsmlObject createFsRQueryResponse( String jsonResponseString,
                                                               AbstractWitsmlObject witsmlObject ); static String consolidateObjectsToXML(
            ArrayList<AbstractWitsmlObject> witsmlObjects,
            String version,
            String objectType
    );  }
@Test(expected = ValveException.class) public void consolidateObjectsToXMLFailTest() throws ValveException { ArrayList<AbstractWitsmlObject> witsmlObjects = new ArrayList<>(); ObjWell well = new ObjWell(); well.setName("well-1"); well.setUid("well-1"); witsmlObjects.add(well); String clientVersion = "InvalidVersion"; String objectType = "well"; DotTranslator.consolidateObjectsToXML(witsmlObjects, clientVersion, objectType); }
@Test public void consolidateObjectsToXMLWellTest() throws ValveException { ArrayList<AbstractWitsmlObject> witsmlObjects = new ArrayList<>(); ObjWell well = new ObjWell(); well.setName("well-1"); well.setUid("well-1"); witsmlObjects.add(well); String clientVersion = "1.3.1.1"; String objectType = "well"; String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><wells version=\"1.3.1.1\" xmlns=\"http: String actual = DotTranslator.consolidateObjectsToXML(witsmlObjects, clientVersion, objectType); assertEquals(expected, actual); witsmlObjects = new ArrayList<>(); com.hashmapinc.tempus.WitsmlObjects.v1411.ObjWell well1411 = new com.hashmapinc.tempus.WitsmlObjects.v1411.ObjWell(); well1411.setName("well-1"); well1411.setUid("well-1"); witsmlObjects.add(well1411); clientVersion = "1.4.1.1"; objectType = "well"; expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><wells version=\"1.4.1.1\" xmlns=\"http: actual = DotTranslator.consolidateObjectsToXML(witsmlObjects, clientVersion, objectType); assertEquals(expected, actual); }
@Test public void consolidateObjectsToXMLWellBoreTest() throws ValveException { ArrayList<AbstractWitsmlObject> witsmlObjects = new ArrayList<>(); ObjWellbore well = new ObjWellbore(); well.setName("well-1"); well.setUid("well-1"); witsmlObjects.add(well); String clientVersion = "1.3.1.1"; String objectType = "wellbore"; String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><wellbores version=\"1.3.1.1\" xmlns=\"http: String actual = DotTranslator.consolidateObjectsToXML(witsmlObjects, clientVersion, objectType); assertEquals(expected, actual); witsmlObjects = new ArrayList<>(); com.hashmapinc.tempus.WitsmlObjects.v1411.ObjWellbore well1411 = new com.hashmapinc.tempus.WitsmlObjects.v1411.ObjWellbore(); well1411.setName("well-1"); well1411.setUid("well-1"); witsmlObjects.add(well1411); clientVersion = "1.4.1.1"; objectType = "wellbore"; expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><wellbores version=\"1.4.1.1\" xmlns=\"http: actual = DotTranslator.consolidateObjectsToXML(witsmlObjects, clientVersion, objectType); System.out.println(actual); assertEquals(expected, actual); }
@Test public void consolidateObjectsToXMLTrajectoryTest() throws ValveException { ArrayList<AbstractWitsmlObject> witsmlObjects = new ArrayList<>(); ObjTrajectory trajectory = new ObjTrajectory(); trajectory.setName("trajectory-1"); trajectory.setUid("trajectory-1"); witsmlObjects.add(trajectory); String clientVersion = "1.3.1.1"; String objectType = "trajectory"; String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><trajectorys version=\"1.3.1.1\" xmlns=\"http: String actual = DotTranslator.consolidateObjectsToXML(witsmlObjects, clientVersion, objectType); assertEquals(expected, actual); witsmlObjects = new ArrayList<>(); com.hashmapinc.tempus.WitsmlObjects.v1411.ObjTrajectory traj1411 = new com.hashmapinc.tempus.WitsmlObjects.v1411.ObjTrajectory(); traj1411.setName("trajectory-1"); traj1411.setUid("trajectory-1"); witsmlObjects.add(traj1411); clientVersion = "1.4.1.1"; objectType = "trajectory"; expected = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><trajectorys version=\"1.4.1.1\" xmlns=\"http: actual = DotTranslator.consolidateObjectsToXML(witsmlObjects, clientVersion, objectType); System.out.println(actual); assertEquals(expected, actual); }