@Test public void getListOfLastWeekDateOfQuarterTest() { List<LocalDate> lastdaysweekofQuarter = projectionRepositoryImpl.getListOfLastWeekDateOfQuarter(); assertTrue(lastdaysweekofQuarter.size() > 0); }
public List<LocalDate> getListOfLastWeekDateOfQuarter() { LocalDate today = LocalDate.now(); LocalDate startDate = LocalDate.of(today.getYear(), today.getMonth().firstMonthOfQuarter(), 1); Month firstMonthOftheQuarter = startDate.getMonth(); Month secMonthOftheQuarter = startDate.getMonth().plus(1); Month thirdMonthOftheQuarter = secMonthOftheQuarter.plus(1); List<Month> monthList = new ArrayList<>(); monthList.add(firstMonthOftheQuarter); monthList.add(secMonthOftheQuarter); monthList.add(thirdMonthOftheQuarter); int year = today.getYear(); List<LocalDate> lastWeeksOfQuarterList = new ArrayList<>(); for (Month month : monthList) { IntStream.rangeClosed(1, YearMonth.of(year, month).lengthOfMonth()) .mapToObj(day -> LocalDate.of(year, month, day)) .filter(date -> date.getDayOfWeek() == DayOfWeek.SUNDAY) .forEach(date -> lastWeeksOfQuarterList.add(date)); } return lastWeeksOfQuarterList; }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { public List<LocalDate> getListOfLastWeekDateOfQuarter() { LocalDate today = LocalDate.now(); LocalDate startDate = LocalDate.of(today.getYear(), today.getMonth().firstMonthOfQuarter(), 1); Month firstMonthOftheQuarter = startDate.getMonth(); Month secMonthOftheQuarter = startDate.getMonth().plus(1); Month thirdMonthOftheQuarter = secMonthOftheQuarter.plus(1); List<Month> monthList = new ArrayList<>(); monthList.add(firstMonthOftheQuarter); monthList.add(secMonthOftheQuarter); monthList.add(thirdMonthOftheQuarter); int year = today.getYear(); List<LocalDate> lastWeeksOfQuarterList = new ArrayList<>(); for (Month month : monthList) { IntStream.rangeClosed(1, YearMonth.of(year, month).lengthOfMonth()) .mapToObj(day -> LocalDate.of(year, month, day)) .filter(date -> date.getDayOfWeek() == DayOfWeek.SUNDAY) .forEach(date -> lastWeeksOfQuarterList.add(date)); } return lastWeeksOfQuarterList; } }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { public List<LocalDate> getListOfLastWeekDateOfQuarter() { LocalDate today = LocalDate.now(); LocalDate startDate = LocalDate.of(today.getYear(), today.getMonth().firstMonthOfQuarter(), 1); Month firstMonthOftheQuarter = startDate.getMonth(); Month secMonthOftheQuarter = startDate.getMonth().plus(1); Month thirdMonthOftheQuarter = secMonthOftheQuarter.plus(1); List<Month> monthList = new ArrayList<>(); monthList.add(firstMonthOftheQuarter); monthList.add(secMonthOftheQuarter); monthList.add(thirdMonthOftheQuarter); int year = today.getYear(); List<LocalDate> lastWeeksOfQuarterList = new ArrayList<>(); for (Month month : monthList) { IntStream.rangeClosed(1, YearMonth.of(year, month).lengthOfMonth()) .mapToObj(day -> LocalDate.of(year, month, day)) .filter(date -> date.getDayOfWeek() == DayOfWeek.SUNDAY) .forEach(date -> lastWeeksOfQuarterList.add(date)); } return lastWeeksOfQuarterList; }  }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { public List<LocalDate> getListOfLastWeekDateOfQuarter() { LocalDate today = LocalDate.now(); LocalDate startDate = LocalDate.of(today.getYear(), today.getMonth().firstMonthOfQuarter(), 1); Month firstMonthOftheQuarter = startDate.getMonth(); Month secMonthOftheQuarter = startDate.getMonth().plus(1); Month thirdMonthOftheQuarter = secMonthOftheQuarter.plus(1); List<Month> monthList = new ArrayList<>(); monthList.add(firstMonthOftheQuarter); monthList.add(secMonthOftheQuarter); monthList.add(thirdMonthOftheQuarter); int year = today.getYear(); List<LocalDate> lastWeeksOfQuarterList = new ArrayList<>(); for (Month month : monthList) { IntStream.rangeClosed(1, YearMonth.of(year, month).lengthOfMonth()) .mapToObj(day -> LocalDate.of(year, month, day)) .filter(date -> date.getDayOfWeek() == DayOfWeek.SUNDAY) .forEach(date -> lastWeeksOfQuarterList.add(date)); } return lastWeeksOfQuarterList; }  @Override Boolean updateProjectionByTargetType(ProjectionRequest projectionRequest); @Override List<Map<String, Object>> getProjectionDetailsFromDb(String targetType, int year, int quarter); @Override Long getTotalAssetCountByTargetType(String targetType); List<LocalDate> getListOfLastWeekDateOfQuarter(); int getWeekNoByDate(LocalDate date); @Override Map<Integer, Long> getPatchingSnapshot(String assetGroup); Map<String, Long> getUnPatchedDetailsByApplication(String assetGroup, String resourceType); Map<String, Long> getAssetDetailsByApplication(String assetGroup, String resourceType); Long getAssetCountByAg(String assetGroup, String resourceType); @SuppressWarnings("deprecation") List<Map<String, Object>> getAppsDetails(String appType); }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { public List<LocalDate> getListOfLastWeekDateOfQuarter() { LocalDate today = LocalDate.now(); LocalDate startDate = LocalDate.of(today.getYear(), today.getMonth().firstMonthOfQuarter(), 1); Month firstMonthOftheQuarter = startDate.getMonth(); Month secMonthOftheQuarter = startDate.getMonth().plus(1); Month thirdMonthOftheQuarter = secMonthOftheQuarter.plus(1); List<Month> monthList = new ArrayList<>(); monthList.add(firstMonthOftheQuarter); monthList.add(secMonthOftheQuarter); monthList.add(thirdMonthOftheQuarter); int year = today.getYear(); List<LocalDate> lastWeeksOfQuarterList = new ArrayList<>(); for (Month month : monthList) { IntStream.rangeClosed(1, YearMonth.of(year, month).lengthOfMonth()) .mapToObj(day -> LocalDate.of(year, month, day)) .filter(date -> date.getDayOfWeek() == DayOfWeek.SUNDAY) .forEach(date -> lastWeeksOfQuarterList.add(date)); } return lastWeeksOfQuarterList; }  @Override Boolean updateProjectionByTargetType(ProjectionRequest projectionRequest); @Override List<Map<String, Object>> getProjectionDetailsFromDb(String targetType, int year, int quarter); @Override Long getTotalAssetCountByTargetType(String targetType); List<LocalDate> getListOfLastWeekDateOfQuarter(); int getWeekNoByDate(LocalDate date); @Override Map<Integer, Long> getPatchingSnapshot(String assetGroup); Map<String, Long> getUnPatchedDetailsByApplication(String assetGroup, String resourceType); Map<String, Long> getAssetDetailsByApplication(String assetGroup, String resourceType); Long getAssetCountByAg(String assetGroup, String resourceType); @SuppressWarnings("deprecation") List<Map<String, Object>> getAppsDetails(String appType);  }