### Question:
ProjectionRepositoryImpl implements ProjectionRepository, Constants { public Map<String, Long> getAssetDetailsByApplication(String assetGroup, String resourceType) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(LATEST, true); if (resourceType.equals(ONPREMSERVER)) { mustFilter.put(CommonUtils.convertAttributetoKeyword(INSCOPE), true); } String aggsFilterApp = CommonUtils.convertAttributetoKeyword(TAGS_APPLICATION); try { return esRepository.getTotalDistributionForIndexAndType(assetGroup, 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);  }### Answer:
@Test public void getAssetDetailsByApplicationTest() throws Exception { Map<String, Long> assetcountByApp = new HashMap<>(); assetcountByApp.put("app1", 120l); assetcountByApp.put("app2", 150l); when( esRepository.getTotalDistributionForIndexAndType(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyInt(), anyObject())).thenReturn(assetcountByApp); projectionRepositoryImpl.getAssetDetailsByApplication("aws-all", "ec2"); projectionRepositoryImpl.getAssetDetailsByApplication("aws-all", "onpremserver"); when( esRepository.getTotalDistributionForIndexAndType(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyInt(), anyObject())).thenThrow(new RuntimeException()); assertThatThrownBy(() -> projectionRepositoryImpl.getAssetDetailsByApplication("aws-all", "ec2")).isInstanceOf( DataException.class); }