### Question:
PatchingServiceImpl implements PatchingService, Constants { @Override public List<Map<String, Object>> getNonCompliantExecsForAG(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())) { long currentNumber = entry.getValue(); long previousNumber = 0; String execName = fetchAppExec(entry.getKey()); boolean sponsorDataOverwritten = false; for (Map<String, Object> existingSponsorData : appComplianceList) { if (execName.equals(existingSponsorData .get("Executive Sponsor"))) { previousNumber = (long) existingSponsorData .get(NON_COMPLIANT_NUMBER); long updatedNumber = currentNumber + previousNumber; existingSponsorData.put(NON_COMPLIANT_NUMBER, updatedNumber); sponsorDataOverwritten = true; break; } } if (!sponsorDataOverwritten) { createdMap.put(NON_COMPLIANT_NUMBER, currentNumber); createdMap.put("Executive Sponsor", execName); 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);  }### Answer:
@Test public void getNonCompliantExecsForAGTest() throws Exception { Map<String, Long> nonComplaintMap = new HashMap<>(); nonComplaintMap.put("ec2", 100l); nonComplaintMap.put("s3", 500l); 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); assertThat(patchingServiceImpl.getNonCompliantExecsForAG("anyString"), is(notNullValue())); }