@Test public void testGetMeasureWithJobDetailsGroupByOrgForSuccess() throws Exception { String measureName = "measureName"; String measureId = "1"; GriffinMeasure measure = createGriffinMeasure(measureName); measure.setOrganization("org"); measure.setId(Long.valueOf(measureId)); given(measureRepo.findByDeleted(false)).willReturn(Arrays .asList(measure)); Map<String, Object> jobDetail = createJobDetailMap(); List<Map<String, Object>> jobList = Arrays.asList(jobDetail); Map<String, List<Map<String, Object>>> measuresById = new HashMap<>(); measuresById.put(measureId, jobList); Map<String, Map<String, List<Map<String, Object>>>> map = service .getMeasureWithJobDetailsGroupByOrg(measuresById); assertThat(map.size()).isEqualTo(1); assertThat(map).containsKey("org"); assertThat(map.get("org").get(measureName)).isEqualTo(jobList); }
@Override public Map<String, Map<String, List<Map<String, Object>>>> getMeasureWithJobDetailsGroupByOrg(Map<String, List<Map<String, Object>>> jobDetails) { Map<String, Map<String, List<Map<String, Object>>>> result = new HashMap<>(); List<GriffinMeasure> measures = measureRepo.findByDeleted(false); if (measures == null) { return null; } for (Measure measure : measures) { String orgName = measure.getOrganization(); String measureName = measure.getName(); String measureId = measure.getId().toString(); List<Map<String, Object>> jobList = jobDetails .getOrDefault(measureId, new ArrayList<>()); Map<String, List<Map<String, Object>>> measureWithJobs = result .getOrDefault(orgName, new HashMap<>()); measureWithJobs.put(measureName, jobList); result.put(orgName, measureWithJobs); } return result; }
MeasureOrgServiceImpl implements MeasureOrgService { @Override public Map<String, Map<String, List<Map<String, Object>>>> getMeasureWithJobDetailsGroupByOrg(Map<String, List<Map<String, Object>>> jobDetails) { Map<String, Map<String, List<Map<String, Object>>>> result = new HashMap<>(); List<GriffinMeasure> measures = measureRepo.findByDeleted(false); if (measures == null) { return null; } for (Measure measure : measures) { String orgName = measure.getOrganization(); String measureName = measure.getName(); String measureId = measure.getId().toString(); List<Map<String, Object>> jobList = jobDetails .getOrDefault(measureId, new ArrayList<>()); Map<String, List<Map<String, Object>>> measureWithJobs = result .getOrDefault(orgName, new HashMap<>()); measureWithJobs.put(measureName, jobList); result.put(orgName, measureWithJobs); } return result; } }
MeasureOrgServiceImpl implements MeasureOrgService { @Override public Map<String, Map<String, List<Map<String, Object>>>> getMeasureWithJobDetailsGroupByOrg(Map<String, List<Map<String, Object>>> jobDetails) { Map<String, Map<String, List<Map<String, Object>>>> result = new HashMap<>(); List<GriffinMeasure> measures = measureRepo.findByDeleted(false); if (measures == null) { return null; } for (Measure measure : measures) { String orgName = measure.getOrganization(); String measureName = measure.getName(); String measureId = measure.getId().toString(); List<Map<String, Object>> jobList = jobDetails .getOrDefault(measureId, new ArrayList<>()); Map<String, List<Map<String, Object>>> measureWithJobs = result .getOrDefault(orgName, new HashMap<>()); measureWithJobs.put(measureName, jobList); result.put(orgName, measureWithJobs); } return result; }  }
MeasureOrgServiceImpl implements MeasureOrgService { @Override public Map<String, Map<String, List<Map<String, Object>>>> getMeasureWithJobDetailsGroupByOrg(Map<String, List<Map<String, Object>>> jobDetails) { Map<String, Map<String, List<Map<String, Object>>>> result = new HashMap<>(); List<GriffinMeasure> measures = measureRepo.findByDeleted(false); if (measures == null) { return null; } for (Measure measure : measures) { String orgName = measure.getOrganization(); String measureName = measure.getName(); String measureId = measure.getId().toString(); List<Map<String, Object>> jobList = jobDetails .getOrDefault(measureId, new ArrayList<>()); Map<String, List<Map<String, Object>>> measureWithJobs = result .getOrDefault(orgName, new HashMap<>()); measureWithJobs.put(measureName, jobList); result.put(orgName, measureWithJobs); } return result; }  @Override List<String> getOrgs(); @Override List<String> getMetricNameListByOrg(String org); @Override Map<String, List<String>> getMeasureNamesGroupByOrg(); @Override Map<String, Map<String, List<Map<String, Object>>>> getMeasureWithJobDetailsGroupByOrg(Map<String,
        List<Map<String, Object>>> jobDetails); }
MeasureOrgServiceImpl implements MeasureOrgService { @Override public Map<String, Map<String, List<Map<String, Object>>>> getMeasureWithJobDetailsGroupByOrg(Map<String, List<Map<String, Object>>> jobDetails) { Map<String, Map<String, List<Map<String, Object>>>> result = new HashMap<>(); List<GriffinMeasure> measures = measureRepo.findByDeleted(false); if (measures == null) { return null; } for (Measure measure : measures) { String orgName = measure.getOrganization(); String measureName = measure.getName(); String measureId = measure.getId().toString(); List<Map<String, Object>> jobList = jobDetails .getOrDefault(measureId, new ArrayList<>()); Map<String, List<Map<String, Object>>> measureWithJobs = result .getOrDefault(orgName, new HashMap<>()); measureWithJobs.put(measureName, jobList); result.put(orgName, measureWithJobs); } return result; }  @Override List<String> getOrgs(); @Override List<String> getMetricNameListByOrg(String org); @Override Map<String, List<String>> getMeasureNamesGroupByOrg(); @Override Map<String, Map<String, List<Map<String, Object>>>> getMeasureWithJobDetailsGroupByOrg(Map<String,
        List<Map<String, Object>>> jobDetails);  }