@Test public void distributeWeights_shouldDistribteCorrectly(){ VolumeLevelSelector volumeLevelSelector = new VolumeLevelSelector(); VolumeWeighterTaskResponse volumeOne = new VolumeWeighterTaskResponse(); volumeOne.setWeightClass(WeightClass.BAD); VolumeWeighterTaskResponse volumeTwo = new VolumeWeighterTaskResponse(); volumeTwo.setWeightClass(WeightClass.OK); VolumeWeighterTaskResponse volumeThree = new VolumeWeighterTaskResponse(); volumeThree.setWeightClass(WeightClass.GOOD); List<VolumeWeighterTaskResponse> weightedMixes = Arrays.asList(volumeOne,volumeTwo,volumeThree); List<Map<String, Double>> distributedMixes = volumeLevelSelector.distributeWeights(weightedMixes); assertThat(distributedMixes).hasSize(1+2+3); }
public List<Map<String, Double>> distributeWeights(List<VolumeWeighterTaskResponse> weightedMixes){ List<Map<String, Double>> distibutedMixes = new ArrayList<>(); for(VolumeWeighterTaskResponse mix : weightedMixes){ for(int i=0; i<mix.getWeightClass().ordinal()+1; i++){ distibutedMixes.add(mix.getPotentialMix()); } } return distibutedMixes; }
VolumeLevelSelector { public List<Map<String, Double>> distributeWeights(List<VolumeWeighterTaskResponse> weightedMixes){ List<Map<String, Double>> distibutedMixes = new ArrayList<>(); for(VolumeWeighterTaskResponse mix : weightedMixes){ for(int i=0; i<mix.getWeightClass().ordinal()+1; i++){ distibutedMixes.add(mix.getPotentialMix()); } } return distibutedMixes; } }
VolumeLevelSelector { public List<Map<String, Double>> distributeWeights(List<VolumeWeighterTaskResponse> weightedMixes){ List<Map<String, Double>> distibutedMixes = new ArrayList<>(); for(VolumeWeighterTaskResponse mix : weightedMixes){ for(int i=0; i<mix.getWeightClass().ordinal()+1; i++){ distibutedMixes.add(mix.getPotentialMix()); } } return distibutedMixes; }  }
VolumeLevelSelector { public List<Map<String, Double>> distributeWeights(List<VolumeWeighterTaskResponse> weightedMixes){ List<Map<String, Double>> distibutedMixes = new ArrayList<>(); for(VolumeWeighterTaskResponse mix : weightedMixes){ for(int i=0; i<mix.getWeightClass().ordinal()+1; i++){ distibutedMixes.add(mix.getPotentialMix()); } } return distibutedMixes; }  Map<String, Double> selectFromWeightedMixes(List<VolumeWeighterTaskResponse> weightedMixes); List<Map<String, Double>> distributeWeights(List<VolumeWeighterTaskResponse> weightedMixes); }
VolumeLevelSelector { public List<Map<String, Double>> distributeWeights(List<VolumeWeighterTaskResponse> weightedMixes){ List<Map<String, Double>> distibutedMixes = new ArrayList<>(); for(VolumeWeighterTaskResponse mix : weightedMixes){ for(int i=0; i<mix.getWeightClass().ordinal()+1; i++){ distibutedMixes.add(mix.getPotentialMix()); } } return distibutedMixes; }  Map<String, Double> selectFromWeightedMixes(List<VolumeWeighterTaskResponse> weightedMixes); List<Map<String, Double>> distributeWeights(List<VolumeWeighterTaskResponse> weightedMixes);  }