@Test public void getTotalAssetCountByTargetTypeTest() throws Exception { when( esRepository.getTotalDocumentCountForIndexAndType(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyString(), anyObject())).thenReturn(100l); projectionRepositoryImpl.getTotalAssetCountByTargetType("ec2"); when( esRepository.getTotalDocumentCountForIndexAndType(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyString(), anyObject())).thenThrow(new RuntimeException()); assertThatThrownBy(() -> projectionRepositoryImpl.getTotalAssetCountByTargetType("ec2")).isInstanceOf( DataException.class); }
@Override public Long getTotalAssetCountByTargetType(String targetType) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); Map<String, Object> mustTermsFilter = new HashMap<>(); mustFilter.put("latest", true); mustFilter.put(CommonUtils.convertAttributetoKeyword("inScope"), true); try { return esRepository.getTotalDocumentCountForIndexAndType("aws" + "_" + targetType, targetType, mustFilter, null, null, null, mustTermsFilter); } catch (Exception e) { logger.error(e); throw new DataException(e); } }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { @Override public Long getTotalAssetCountByTargetType(String targetType) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); Map<String, Object> mustTermsFilter = new HashMap<>(); mustFilter.put("latest", true); mustFilter.put(CommonUtils.convertAttributetoKeyword("inScope"), true); try { return esRepository.getTotalDocumentCountForIndexAndType("aws" + "_" + targetType, targetType, mustFilter, null, null, null, mustTermsFilter); } catch (Exception e) { logger.error(e); throw new DataException(e); } } }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { @Override public Long getTotalAssetCountByTargetType(String targetType) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); Map<String, Object> mustTermsFilter = new HashMap<>(); mustFilter.put("latest", true); mustFilter.put(CommonUtils.convertAttributetoKeyword("inScope"), true); try { return esRepository.getTotalDocumentCountForIndexAndType("aws" + "_" + targetType, targetType, mustFilter, null, null, null, mustTermsFilter); } catch (Exception e) { logger.error(e); throw new DataException(e); } }  }
ProjectionRepositoryImpl implements ProjectionRepository, Constants { @Override public Long getTotalAssetCountByTargetType(String targetType) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); Map<String, Object> mustTermsFilter = new HashMap<>(); mustFilter.put("latest", true); mustFilter.put(CommonUtils.convertAttributetoKeyword("inScope"), true); try { return esRepository.getTotalDocumentCountForIndexAndType("aws" + "_" + targetType, targetType, mustFilter, null, null, null, mustTermsFilter); } 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 { @Override public Long getTotalAssetCountByTargetType(String targetType) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); Map<String, Object> mustTermsFilter = new HashMap<>(); mustFilter.put("latest", true); mustFilter.put(CommonUtils.convertAttributetoKeyword("inScope"), true); try { return esRepository.getTotalDocumentCountForIndexAndType("aws" + "_" + targetType, targetType, mustFilter, null, null, null, mustTermsFilter); } 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);  }