@Test public void getPatchingProgressTest() throws Exception { Map<String, Object> patchingProgressMap = new HashMap<>(); List<Map<String, Object>> patchingProgressList = new ArrayList<>(); patchingProgressMap.put("2018-04-01T00:00:00.000Z", 100l); patchingProgressMap.put("date", "2018-04-01"); patchingProgressMap.put("patching_percentage", "20"); patchingProgressMap.put("total_instances", "2000"); patchingProgressList.add(patchingProgressMap); patchingProgressMap.put("2018-04-01T00:00:00.000Z", 100l); patchingProgressMap.put("date", "2018-04-07"); patchingProgressMap.put("patching_percentage", "20"); patchingProgressMap.put("appTag", "Cloud"); patchingProgressList.add(patchingProgressMap); when(repository.getPatchingProgress(anyString(),anyObject(),anyObject())) .thenReturn(patchingProgressList); when(filterRepository.getListOfTargetTypes(anyString(),anyString())) .thenReturn(CommonTestUtil.getAssetCountByApps()); when(repository.getAmilAvailDate(anyInt(),anyInt())) .thenReturn("2017-10-13"); assertThat(patchingServiceImpl.getPatchingProgress("anyString",2018,2), is(notNullValue())); }
@Override public Map<String, Object> getPatchingProgress(String assetGroup, int year, int quarter) throws ServiceException { List<Map<String, Object>> patchingProgressList; try { patchingProgressList = repository.getPatchingProgress(assetGroup, getFirstDayOfQuarter(quarter, year), getLastDayOfQuarter(quarter, year)); Comparator<Map<String, Object>> comp = (m1, m2) -> LocalDate.parse( m1.get("date").toString(), DateTimeFormatter.ISO_DATE) .compareTo( LocalDate.parse(m2.get("date").toString(), DateTimeFormatter.ISO_DATE)); Collections.sort(patchingProgressList, comp); fillNoDataDatesWithPrevious(patchingProgressList, year, quarter); issueTrendService.useRealTimeDataForLatestDate( patchingProgressList, assetGroup, "patching", null, null); } catch (DataException e) { throw new ServiceException(e); } return segregatePatchingProgressByWeek(assetGroup, patchingProgressList, year, quarter); }
PatchingServiceImpl implements PatchingService, Constants { @Override public Map<String, Object> getPatchingProgress(String assetGroup, int year, int quarter) throws ServiceException { List<Map<String, Object>> patchingProgressList; try { patchingProgressList = repository.getPatchingProgress(assetGroup, getFirstDayOfQuarter(quarter, year), getLastDayOfQuarter(quarter, year)); Comparator<Map<String, Object>> comp = (m1, m2) -> LocalDate.parse( m1.get("date").toString(), DateTimeFormatter.ISO_DATE) .compareTo( LocalDate.parse(m2.get("date").toString(), DateTimeFormatter.ISO_DATE)); Collections.sort(patchingProgressList, comp); fillNoDataDatesWithPrevious(patchingProgressList, year, quarter); issueTrendService.useRealTimeDataForLatestDate( patchingProgressList, assetGroup, "patching", null, null); } catch (DataException e) { throw new ServiceException(e); } return segregatePatchingProgressByWeek(assetGroup, patchingProgressList, year, quarter); } }
PatchingServiceImpl implements PatchingService, Constants { @Override public Map<String, Object> getPatchingProgress(String assetGroup, int year, int quarter) throws ServiceException { List<Map<String, Object>> patchingProgressList; try { patchingProgressList = repository.getPatchingProgress(assetGroup, getFirstDayOfQuarter(quarter, year), getLastDayOfQuarter(quarter, year)); Comparator<Map<String, Object>> comp = (m1, m2) -> LocalDate.parse( m1.get("date").toString(), DateTimeFormatter.ISO_DATE) .compareTo( LocalDate.parse(m2.get("date").toString(), DateTimeFormatter.ISO_DATE)); Collections.sort(patchingProgressList, comp); fillNoDataDatesWithPrevious(patchingProgressList, year, quarter); issueTrendService.useRealTimeDataForLatestDate( patchingProgressList, assetGroup, "patching", null, null); } catch (DataException e) { throw new ServiceException(e); } return segregatePatchingProgressByWeek(assetGroup, patchingProgressList, year, quarter); }  }
PatchingServiceImpl implements PatchingService, Constants { @Override public Map<String, Object> getPatchingProgress(String assetGroup, int year, int quarter) throws ServiceException { List<Map<String, Object>> patchingProgressList; try { patchingProgressList = repository.getPatchingProgress(assetGroup, getFirstDayOfQuarter(quarter, year), getLastDayOfQuarter(quarter, year)); Comparator<Map<String, Object>> comp = (m1, m2) -> LocalDate.parse( m1.get("date").toString(), DateTimeFormatter.ISO_DATE) .compareTo( LocalDate.parse(m2.get("date").toString(), DateTimeFormatter.ISO_DATE)); Collections.sort(patchingProgressList, comp); fillNoDataDatesWithPrevious(patchingProgressList, year, quarter); issueTrendService.useRealTimeDataForLatestDate( patchingProgressList, assetGroup, "patching", null, null); } catch (DataException e) { throw new ServiceException(e); } return segregatePatchingProgressByWeek(assetGroup, patchingProgressList, year, quarter); }  @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 Map<String, Object> getPatchingProgress(String assetGroup, int year, int quarter) throws ServiceException { List<Map<String, Object>> patchingProgressList; try { patchingProgressList = repository.getPatchingProgress(assetGroup, getFirstDayOfQuarter(quarter, year), getLastDayOfQuarter(quarter, year)); Comparator<Map<String, Object>> comp = (m1, m2) -> LocalDate.parse( m1.get("date").toString(), DateTimeFormatter.ISO_DATE) .compareTo( LocalDate.parse(m2.get("date").toString(), DateTimeFormatter.ISO_DATE)); Collections.sort(patchingProgressList, comp); fillNoDataDatesWithPrevious(patchingProgressList, year, quarter); issueTrendService.useRealTimeDataForLatestDate( patchingProgressList, assetGroup, "patching", null, null); } catch (DataException e) { throw new ServiceException(e); } return segregatePatchingProgressByWeek(assetGroup, patchingProgressList, year, quarter); }  @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);  }