JobDetailFormatter { protected static String calculateCost(TankConfig config, JobInstance proposedJobInstance, List<JobRegion> regions, long simulationTime) { List<VmInstanceType> instanceTypes = config.getVmManagerConfig().getInstanceTypes(); BigDecimal costPerHour = instanceTypes.stream().filter(type -> type.getName().equals(proposedJobInstance.getVmInstanceType())).findFirst().map(type -> new BigDecimal(type.getCost())).orElseGet(() -> new BigDecimal(.5D)); long time = simulationTime + proposedJobInstance.getRampTime(); int numMachines = regions.stream().mapToInt(region -> Integer.parseInt(region.getUsers())).filter(users -> users > 0).map(users -> (int) Math.ceil((double) users / (double) proposedJobInstance.getNumUsersPerAgent())).sum(); BigDecimal cost = estimateCost(numMachines, costPerHour, time); NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); return nf.format(cost.doubleValue()); }  static String createJobDetails(JobValidator validator, Workload workload, JobInstance proposedJobInstance); static String createJobDetails(JobValidator validator, String scriptName);  }
@Test public void calculateCost() { }
@Test public void testCalculateCost_1() throws Exception { TankConfig config = new TankConfig(); JobInstance proposedJobInstance = new JobInstance(); List<JobRegion> regions = new LinkedList(); long simulationTime = 1L; String result = JobDetailFormatter.calculateCost(config, proposedJobInstance, regions, simulationTime); assertNotNull(result); }
@Test public void testCalculateCost_2() throws Exception { TankConfig config = new TankConfig(); JobInstance proposedJobInstance = new JobInstance(); List<JobRegion> regions = new LinkedList(); long simulationTime = 1L; String result = JobDetailFormatter.calculateCost(config, proposedJobInstance, regions, simulationTime); assertNotNull(result); }
@Test public void testCalculateCost_3() throws Exception { TankConfig config = new TankConfig(); JobInstance proposedJobInstance = new JobInstance(); List<JobRegion> regions = new LinkedList(); long simulationTime = 1L; String result = JobDetailFormatter.calculateCost(config, proposedJobInstance, regions, simulationTime); assertNotNull(result); }
@Test public void testCalculateCost_4() throws Exception { TankConfig config = new TankConfig(); JobInstance proposedJobInstance = new JobInstance(); List<JobRegion> regions = new LinkedList(); long simulationTime = 1L; String result = JobDetailFormatter.calculateCost(config, proposedJobInstance, regions, simulationTime); assertNotNull(result); }