@Test public void getUnPatchedDetailsByApplicationTest() throws Exception { Map<String, Long> unpatchedAssetCountApp = new HashMap<>(); unpatchedAssetCountApp.put("app1", 100l); unpatchedAssetCountApp.put("app2", 150l); when( esRepository.getTotalDistributionForIndexAndType(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyInt(), anyObject())).thenReturn(unpatchedAssetCountApp); projectionRepositoryImpl.getUnPatchedDetailsByApplication("aws-all", "ec2"); projectionRepositoryImpl.getUnPatchedDetailsByApplication("aws-all", "s3"); projectionRepositoryImpl.getUnPatchedDetailsByApplication("aws-all", "onpremserver"); when( esRepository.getTotalDistributionForIndexAndType(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyInt(), anyObject())).thenThrow(new RuntimeException()); assertThatThrownBy(() -> projectionRepositoryImpl.getUnPatchedDetailsByApplication("aws-all", "ec2")) .isInstanceOf(DataException.class); }
public Map<String, Long> getUnPatchedDetailsByApplication(String assetGroup, String resourceType) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword(TYPE), ISSUE); mustFilter.put(CommonUtils.convertAttributetoKeyword(ISSUE_STATUS), OPEN); if (resourceType.equals(ONPREMSERVER)) { mustFilter.put(CommonUtils.convertAttributetoKeyword(RULEID), ONPREM_KERNEL_COMPLIANCE_RULE); } else if (resourceType.equals(EC2)) { mustFilter.put(CommonUtils.convertAttributetoKeyword(RULEID), EC2_KERNEL_COMPLIANCE_RULE); } String aggsFilterApp = CommonUtils.convertAttributetoKeyword(TAGS_APPLICATION); try { return esRepository.getTotalDistributionForIndexAndType(assetGroup, "issue_" + resourceType, mustFilter, null, null, aggsFilterApp, TEN_THOUSAND, null); } catch (Exception e) { logger.error(e); throw new DataException(e); } }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { public Map<String, Long> getUnPatchedDetailsByApplication(String assetGroup, String resourceType) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword(TYPE), ISSUE); mustFilter.put(CommonUtils.convertAttributetoKeyword(ISSUE_STATUS), OPEN); if (resourceType.equals(ONPREMSERVER)) { mustFilter.put(CommonUtils.convertAttributetoKeyword(RULEID), ONPREM_KERNEL_COMPLIANCE_RULE); } else if (resourceType.equals(EC2)) { mustFilter.put(CommonUtils.convertAttributetoKeyword(RULEID), EC2_KERNEL_COMPLIANCE_RULE); } String aggsFilterApp = CommonUtils.convertAttributetoKeyword(TAGS_APPLICATION); try { return esRepository.getTotalDistributionForIndexAndType(assetGroup, "issue_" + resourceType, mustFilter, null, null, aggsFilterApp, TEN_THOUSAND, null); } catch (Exception e) { logger.error(e); throw new DataException(e); } } }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { public Map<String, Long> getUnPatchedDetailsByApplication(String assetGroup, String resourceType) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword(TYPE), ISSUE); mustFilter.put(CommonUtils.convertAttributetoKeyword(ISSUE_STATUS), OPEN); if (resourceType.equals(ONPREMSERVER)) { mustFilter.put(CommonUtils.convertAttributetoKeyword(RULEID), ONPREM_KERNEL_COMPLIANCE_RULE); } else if (resourceType.equals(EC2)) { mustFilter.put(CommonUtils.convertAttributetoKeyword(RULEID), EC2_KERNEL_COMPLIANCE_RULE); } String aggsFilterApp = CommonUtils.convertAttributetoKeyword(TAGS_APPLICATION); try { return esRepository.getTotalDistributionForIndexAndType(assetGroup, "issue_" + resourceType, mustFilter, null, null, aggsFilterApp, TEN_THOUSAND, null); } catch (Exception e) { logger.error(e); throw new DataException(e); } }  }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { public Map<String, Long> getUnPatchedDetailsByApplication(String assetGroup, String resourceType) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword(TYPE), ISSUE); mustFilter.put(CommonUtils.convertAttributetoKeyword(ISSUE_STATUS), OPEN); if (resourceType.equals(ONPREMSERVER)) { mustFilter.put(CommonUtils.convertAttributetoKeyword(RULEID), ONPREM_KERNEL_COMPLIANCE_RULE); } else if (resourceType.equals(EC2)) { mustFilter.put(CommonUtils.convertAttributetoKeyword(RULEID), EC2_KERNEL_COMPLIANCE_RULE); } String aggsFilterApp = CommonUtils.convertAttributetoKeyword(TAGS_APPLICATION); try { return esRepository.getTotalDistributionForIndexAndType(assetGroup, "issue_" + resourceType, mustFilter, null, null, aggsFilterApp, TEN_THOUSAND, null); } catch (Exception e) { logger.error(e); throw new DataException(e); } }  @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 Map<String, Long> getUnPatchedDetailsByApplication(String assetGroup, String resourceType) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(CommonUtils.convertAttributetoKeyword(TYPE), ISSUE); mustFilter.put(CommonUtils.convertAttributetoKeyword(ISSUE_STATUS), OPEN); if (resourceType.equals(ONPREMSERVER)) { mustFilter.put(CommonUtils.convertAttributetoKeyword(RULEID), ONPREM_KERNEL_COMPLIANCE_RULE); } else if (resourceType.equals(EC2)) { mustFilter.put(CommonUtils.convertAttributetoKeyword(RULEID), EC2_KERNEL_COMPLIANCE_RULE); } String aggsFilterApp = CommonUtils.convertAttributetoKeyword(TAGS_APPLICATION); try { return esRepository.getTotalDistributionForIndexAndType(assetGroup, "issue_" + resourceType, mustFilter, null, null, aggsFilterApp, TEN_THOUSAND, null); } catch (Exception e) { logger.error(e); throw new DataException(e); } }  @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);  }