@Test public void getNonCompliantNumberForAGTest() throws Exception { Map<String, Long> nonComplaintMap = new HashMap<>(); nonComplaintMap.put("Adapt", 500l); List<Map<String, Object>> execAndDirectorInfoList = new ArrayList<>(); Map<String,Object> execAndDirectorInfoMap = new HashMap<>(); execAndDirectorInfoMap.put("appTag", "Adapt"); execAndDirectorInfoMap.put("director", "John Doel"); execAndDirectorInfoMap.put("executiveSponsor", "John Doe"); execAndDirectorInfoList.add(execAndDirectorInfoMap); List<Map<String, Long>> nonComplaintList = new ArrayList<>(); nonComplaintList.add(nonComplaintMap); when(filterRepository.getListOfTargetTypes(anyString(),anyString())) .thenReturn(CommonTestUtil.getAssetCountByApps()); when(repository.getNonCompliantNumberForAgAndResourceType(anyString(),anyString())) .thenReturn(nonComplaintMap); when(repository.getExecAndDirectorInfo()) .thenReturn(execAndDirectorInfoList); assertThat(patchingServiceImpl.getNonCompliantNumberForAG("anyString"), is(notNullValue())); }
@Override public List<Map<String, Object>> getNonCompliantNumberForAG( String assetGroup) throws ServiceException { List<Map<String, Long>> appComplianceMapList = new ArrayList<>(); List<Map<String, Object>> appComplianceList = new ArrayList<>(); try{ AssetCountDTO[] targetTypes = filterRepository.getListOfTargetTypes( assetGroup, null); for (AssetCountDTO targettype : targetTypes) { if (StringUtils.isNotBlank(targettype.getType())) { appComplianceMapList.add(repository.getNonCompliantNumberForAgAndResourceType(assetGroup, targettype.getType())); } } } catch (DataException e) { throw new ServiceException(e); } for (Map<String, Long> appComplianceMap : appComplianceMapList) { for (Map.Entry<String, Long> entry : appComplianceMap.entrySet()) { Map<String, Object> createdMap = new HashMap<>(); if (StringUtils.isNotBlank(entry.getKey())) { createdMap.put("app", entry.getKey()); createdMap.put(NON_COMPLIANT_NUMBER, entry.getValue()); createdMap .put("Director", fetchAppDirector(entry.getKey())); appComplianceList.add(createdMap); } } } Comparator<Map<String, Object>> comp = (m1, m2) -> Integer.compare( new Integer(m2.get(NON_COMPLIANT_NUMBER).toString()), new Integer(m1.get(NON_COMPLIANT_NUMBER).toString())); Collections.sort(appComplianceList, comp); if (appComplianceList.isEmpty()) { throw new ServiceException(NO_DATA_FOUND); } return appComplianceList; }
PatchingServiceImpl implements PatchingService, Constants { @Override public List<Map<String, Object>> getNonCompliantNumberForAG( String assetGroup) throws ServiceException { List<Map<String, Long>> appComplianceMapList = new ArrayList<>(); List<Map<String, Object>> appComplianceList = new ArrayList<>(); try{ AssetCountDTO[] targetTypes = filterRepository.getListOfTargetTypes( assetGroup, null); for (AssetCountDTO targettype : targetTypes) { if (StringUtils.isNotBlank(targettype.getType())) { appComplianceMapList.add(repository.getNonCompliantNumberForAgAndResourceType(assetGroup, targettype.getType())); } } } catch (DataException e) { throw new ServiceException(e); } for (Map<String, Long> appComplianceMap : appComplianceMapList) { for (Map.Entry<String, Long> entry : appComplianceMap.entrySet()) { Map<String, Object> createdMap = new HashMap<>(); if (StringUtils.isNotBlank(entry.getKey())) { createdMap.put("app", entry.getKey()); createdMap.put(NON_COMPLIANT_NUMBER, entry.getValue()); createdMap .put("Director", fetchAppDirector(entry.getKey())); appComplianceList.add(createdMap); } } } Comparator<Map<String, Object>> comp = (m1, m2) -> Integer.compare( new Integer(m2.get(NON_COMPLIANT_NUMBER).toString()), new Integer(m1.get(NON_COMPLIANT_NUMBER).toString())); Collections.sort(appComplianceList, comp); if (appComplianceList.isEmpty()) { throw new ServiceException(NO_DATA_FOUND); } return appComplianceList; } }
PatchingServiceImpl implements PatchingService, Constants { @Override public List<Map<String, Object>> getNonCompliantNumberForAG( String assetGroup) throws ServiceException { List<Map<String, Long>> appComplianceMapList = new ArrayList<>(); List<Map<String, Object>> appComplianceList = new ArrayList<>(); try{ AssetCountDTO[] targetTypes = filterRepository.getListOfTargetTypes( assetGroup, null); for (AssetCountDTO targettype : targetTypes) { if (StringUtils.isNotBlank(targettype.getType())) { appComplianceMapList.add(repository.getNonCompliantNumberForAgAndResourceType(assetGroup, targettype.getType())); } } } catch (DataException e) { throw new ServiceException(e); } for (Map<String, Long> appComplianceMap : appComplianceMapList) { for (Map.Entry<String, Long> entry : appComplianceMap.entrySet()) { Map<String, Object> createdMap = new HashMap<>(); if (StringUtils.isNotBlank(entry.getKey())) { createdMap.put("app", entry.getKey()); createdMap.put(NON_COMPLIANT_NUMBER, entry.getValue()); createdMap .put("Director", fetchAppDirector(entry.getKey())); appComplianceList.add(createdMap); } } } Comparator<Map<String, Object>> comp = (m1, m2) -> Integer.compare( new Integer(m2.get(NON_COMPLIANT_NUMBER).toString()), new Integer(m1.get(NON_COMPLIANT_NUMBER).toString())); Collections.sort(appComplianceList, comp); if (appComplianceList.isEmpty()) { throw new ServiceException(NO_DATA_FOUND); } return appComplianceList; }  }
PatchingServiceImpl implements PatchingService, Constants { @Override public List<Map<String, Object>> getNonCompliantNumberForAG( String assetGroup) throws ServiceException { List<Map<String, Long>> appComplianceMapList = new ArrayList<>(); List<Map<String, Object>> appComplianceList = new ArrayList<>(); try{ AssetCountDTO[] targetTypes = filterRepository.getListOfTargetTypes( assetGroup, null); for (AssetCountDTO targettype : targetTypes) { if (StringUtils.isNotBlank(targettype.getType())) { appComplianceMapList.add(repository.getNonCompliantNumberForAgAndResourceType(assetGroup, targettype.getType())); } } } catch (DataException e) { throw new ServiceException(e); } for (Map<String, Long> appComplianceMap : appComplianceMapList) { for (Map.Entry<String, Long> entry : appComplianceMap.entrySet()) { Map<String, Object> createdMap = new HashMap<>(); if (StringUtils.isNotBlank(entry.getKey())) { createdMap.put("app", entry.getKey()); createdMap.put(NON_COMPLIANT_NUMBER, entry.getValue()); createdMap .put("Director", fetchAppDirector(entry.getKey())); appComplianceList.add(createdMap); } } } Comparator<Map<String, Object>> comp = (m1, m2) -> Integer.compare( new Integer(m2.get(NON_COMPLIANT_NUMBER).toString()), new Integer(m1.get(NON_COMPLIANT_NUMBER).toString())); Collections.sort(appComplianceList, comp); if (appComplianceList.isEmpty()) { throw new ServiceException(NO_DATA_FOUND); } return appComplianceList; }  @Override List<Map<String, Object>> getNonCompliantNumberForAG(
            String assetGroup); @Override List<Map<String, Object>> getNonCompliantExecsForAG(String assetGroup); @Override List<Map<String, Object>> getPatchingDetails(String assetGroup,
            Map<String, String> filter); @Override Map<String, Object> getPatchingProgress(String assetGroup, int year,
            int quarter); @Override List<Map<String, Object>> getQuartersWithPatchingData(
            String assetGroup); @Override LocalDate getFirstDayOfQuarter(int quarterNumber, int year); @Override LocalDate getLastDayOfQuarter(int quarterNumber, int year); @Override int getOngoingQuarter(); @Override int getOngoingYear(); @Override Object filterMatchingCollectionElements(
            List<Map<String, Object>> masterDetailList, String searchText,
            boolean b); @Override Medal getStarRatingForAgPatching(String ag, int quarter, int year); }
PatchingServiceImpl implements PatchingService, Constants { @Override public List<Map<String, Object>> getNonCompliantNumberForAG( String assetGroup) throws ServiceException { List<Map<String, Long>> appComplianceMapList = new ArrayList<>(); List<Map<String, Object>> appComplianceList = new ArrayList<>(); try{ AssetCountDTO[] targetTypes = filterRepository.getListOfTargetTypes( assetGroup, null); for (AssetCountDTO targettype : targetTypes) { if (StringUtils.isNotBlank(targettype.getType())) { appComplianceMapList.add(repository.getNonCompliantNumberForAgAndResourceType(assetGroup, targettype.getType())); } } } catch (DataException e) { throw new ServiceException(e); } for (Map<String, Long> appComplianceMap : appComplianceMapList) { for (Map.Entry<String, Long> entry : appComplianceMap.entrySet()) { Map<String, Object> createdMap = new HashMap<>(); if (StringUtils.isNotBlank(entry.getKey())) { createdMap.put("app", entry.getKey()); createdMap.put(NON_COMPLIANT_NUMBER, entry.getValue()); createdMap .put("Director", fetchAppDirector(entry.getKey())); appComplianceList.add(createdMap); } } } Comparator<Map<String, Object>> comp = (m1, m2) -> Integer.compare( new Integer(m2.get(NON_COMPLIANT_NUMBER).toString()), new Integer(m1.get(NON_COMPLIANT_NUMBER).toString())); Collections.sort(appComplianceList, comp); if (appComplianceList.isEmpty()) { throw new ServiceException(NO_DATA_FOUND); } return appComplianceList; }  @Override List<Map<String, Object>> getNonCompliantNumberForAG(
            String assetGroup); @Override List<Map<String, Object>> getNonCompliantExecsForAG(String assetGroup); @Override List<Map<String, Object>> getPatchingDetails(String assetGroup,
            Map<String, String> filter); @Override Map<String, Object> getPatchingProgress(String assetGroup, int year,
            int quarter); @Override List<Map<String, Object>> getQuartersWithPatchingData(
            String assetGroup); @Override LocalDate getFirstDayOfQuarter(int quarterNumber, int year); @Override LocalDate getLastDayOfQuarter(int quarterNumber, int year); @Override int getOngoingQuarter(); @Override int getOngoingYear(); @Override Object filterMatchingCollectionElements(
            List<Map<String, Object>> masterDetailList, String searchText,
            boolean b); @Override Medal getStarRatingForAgPatching(String ag, int quarter, int year);  }