ConverterUtil { public static String getWorkloadXML(HDWorkload hdWorkload) { AWSXRay.beginSubsegment("JAXB.Marshal." + HDWorkload.class.getSimpleName()); StringWriter sw; try { JAXBContext context = JAXBContext.newInstance(HDWorkload.class.getPackage().getName()); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); sw = new StringWriter(); marshaller.marshal(hdWorkload, sw); sw.flush(); sw.close(); } catch (JAXBException | IOException e) { e.printStackTrace(); throw new RuntimeException(e); } finally { AWSXRay.endSubsegment(); } return sw.toString(); }  static HDWorkload convertScriptToHdWorkload(Script script); static HDWorkload convertWorkload(Workload workload, BaseJob job); static String getWorkloadXML(HDWorkload hdWorkload); static boolean isAssignment(RequestData data); static List<Header> getPostData(Set<RequestData> postData); static List<ResponseData> getResponseData(Set<RequestData> responseData); static List<Header> getResponseHeaders(Set<RequestData> responseHeaders, Set<RequestData> responseCookies); static List<Header> getRequestHeaders(Set<RequestData> headers, Set<RequestData> cookies); static boolean includedHeader(String header);  }
@Test public void testGetWorkloadXML_1() throws Exception { HDWorkload hdWorkload = new HDWorkload(); AWSXRay.beginDummySegment(); String result = ConverterUtil.getWorkloadXML(hdWorkload); AWSXRay.endSegment(); assertTrue(result.contains("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>")); assertTrue(result.contains("<ns2:workload xmlns:ns2=\"urn:com/intuit/tank/harness/data/v1\">")); assertTrue(result.contains("<client-class>com.intuit.tank.httpclient4.TankHttpClient4</client-class>")); assertTrue(result.contains("</ns2:workload>")); }