ConverterUtil { public static HDWorkload convertWorkload(Workload workload, BaseJob job) { String name = "TestPlan for " + workload.getProject() != null ? " project " + workload.getProject().getName() : " workload " + workload.getName(); int id = workload.getProject() != null ? workload.getProject().getId() : workload.getId(); name += " (id" + id + ")"; HDWorkload hdWorkload = new HDWorkload(); hdWorkload.setTankHttpClientClass(job.getTankClientClass() != null ? job.getTankClientClass() : new TankConfig().getAgentConfig().getTankClientClassDefault()); hdWorkload.setDescription(name); hdWorkload.setName(name); hdWorkload.setVariables(new HDTestVariables(job.isAllowOverride(), job.getVariables())); for (TestPlan plan : workload.getTestPlans()) { HDTestPlan tp = new HDTestPlan(); tp.setTestPlanName(plan.getName()); tp.setUserPercentage(plan.getUserPercentage()); tp.getGroup().addAll(convertScriptGroups(plan.getScriptGroups(), new StepCounter())); hdWorkload.getPlans().add(tp); } return hdWorkload; }  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 testConvertWorkload_1() throws Exception { Workload workload = new Workload(); workload.setName(""); workload.setParent(new Project()); workload.setTestPlan(new LinkedList()); BaseJob job = new JobConfiguration(); HDWorkload result = ConverterUtil.convertWorkload(workload, job); assertNotNull(result); assertEquals(" project null (id0)", result.getName()); assertEquals(" project null (id0)", result.getDescription()); }