@Test public void getInstanceInfoTest() throws Exception { List<Map<String, Object>> instancesInfo = new ArrayList<>(); Map<String, Object> instanceInfo = new HashMap<>(); instanceInfo.put("_resourceid", "i-1234"); instanceInfo.put("accountName", "testAccount"); instanceInfo.put("vpc", "test1234"); instanceInfo.put("application", "app1"); instancesInfo.add(instanceInfo); Map<String, String> filters = new HashMap<>(); filters.put("_resourceid", "i-1234"); when( elasticSearchRepository.getSortedDataFromES(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject())).thenReturn(instancesInfo); Map<String, String> emptyfilters = new HashMap<>(); patchingRepositoryImpl.getInstanceInfo("aws-all", null); patchingRepositoryImpl.getInstanceInfo("aws-all", emptyfilters); patchingRepositoryImpl.getInstanceInfo("aws-all", filters); when( elasticSearchRepository.getSortedDataFromES(anyString(), anyString(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject())).thenThrow(new RuntimeException()); assertThatThrownBy(() -> patchingRepositoryImpl.getInstanceInfo("aws-all", filters)).isInstanceOf( DataException.class); }
@Override public List<Map<String, Object>> getInstanceInfo(String assetGroup, Map<String, String> filters) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(LATEST, true); mustFilter.put(STATE_NAME, RUNNING); Map<String, Object> mustNotFilter = new HashMap<>(); mustNotFilter.put(PLATFORM, WINDOWS); if (null != filters && filters.size() > 0) { filters.forEach((key, value) -> mustFilter.put(key, value)); } try{ return elasticSearchRepository .getSortedDataFromES(assetGroup, "ec2", mustFilter, mustNotFilter, null, Arrays.asList("tags.Name", TAGS_APPLICATION, RESOURCEID, "tags.Environment", "accountname", "vpcid", "privateipaddress"), null, null); } catch(Exception e){ throw new DataException(e); } }
PatchingRepositoryImpl implements PatchingRepository, Constants { @Override public List<Map<String, Object>> getInstanceInfo(String assetGroup, Map<String, String> filters) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(LATEST, true); mustFilter.put(STATE_NAME, RUNNING); Map<String, Object> mustNotFilter = new HashMap<>(); mustNotFilter.put(PLATFORM, WINDOWS); if (null != filters && filters.size() > 0) { filters.forEach((key, value) -> mustFilter.put(key, value)); } try{ return elasticSearchRepository .getSortedDataFromES(assetGroup, "ec2", mustFilter, mustNotFilter, null, Arrays.asList("tags.Name", TAGS_APPLICATION, RESOURCEID, "tags.Environment", "accountname", "vpcid", "privateipaddress"), null, null); } catch(Exception e){ throw new DataException(e); } } }
PatchingRepositoryImpl implements PatchingRepository, Constants { @Override public List<Map<String, Object>> getInstanceInfo(String assetGroup, Map<String, String> filters) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(LATEST, true); mustFilter.put(STATE_NAME, RUNNING); Map<String, Object> mustNotFilter = new HashMap<>(); mustNotFilter.put(PLATFORM, WINDOWS); if (null != filters && filters.size() > 0) { filters.forEach((key, value) -> mustFilter.put(key, value)); } try{ return elasticSearchRepository .getSortedDataFromES(assetGroup, "ec2", mustFilter, mustNotFilter, null, Arrays.asList("tags.Name", TAGS_APPLICATION, RESOURCEID, "tags.Environment", "accountname", "vpcid", "privateipaddress"), null, null); } catch(Exception e){ throw new DataException(e); } }  }
PatchingRepositoryImpl implements PatchingRepository, Constants { @Override public List<Map<String, Object>> getInstanceInfo(String assetGroup, Map<String, String> filters) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(LATEST, true); mustFilter.put(STATE_NAME, RUNNING); Map<String, Object> mustNotFilter = new HashMap<>(); mustNotFilter.put(PLATFORM, WINDOWS); if (null != filters && filters.size() > 0) { filters.forEach((key, value) -> mustFilter.put(key, value)); } try{ return elasticSearchRepository .getSortedDataFromES(assetGroup, "ec2", mustFilter, mustNotFilter, null, Arrays.asList("tags.Name", TAGS_APPLICATION, RESOURCEID, "tags.Environment", "accountname", "vpcid", "privateipaddress"), null, null); } catch(Exception e){ throw new DataException(e); } }  @Override List<Map<String, Object>> getPatchingProgress(String assetGroup,
            LocalDate startDate, LocalDate endDate); @Override List<Map<String, Object>> getIssueInfo(String assetGroup); List<Map<String, Object>> getClosedIssueInfo(String assetGroup,
            int size); @Override List<Map<String, Object>> getInstanceInfo(String assetGroup,
            Map<String, String> filters); @Override List<Map<String, Object>> getExecAndDirectorInfo(); @Override long getInstanceInfoCount(String assetGroup,
            Map<String, String> filters, String searchText); @Override String getAmilAvailDate(int year, int quarter); @Override int getPatchingWindow(); @Override Map<String, Long> getQuartersWithPatchingData(String assetGroup); Map<String, Object> addParentConditionPatching(String targetType); @Override List<Map<String, Object>> getOnpremIssueInfo(String assetGroup); @Override List<Map<String, Object>> getOnpremResourceInfo(String assetGroup,
            Map<String, String> filters); @Override Map<String, Object> getDirectorsAndExcutiveSponsers(String appTag,
            String appType); @Override Map<String, Long> getNonCompliantNumberForAgAndResourceType(
            String assetGroup, String resourceType); @Override List<Map<String, Object>> getPatchingPercentForDateRange(String assetGroup, LocalDate fromDate,
			LocalDate toDate); }
PatchingRepositoryImpl implements PatchingRepository, Constants { @Override public List<Map<String, Object>> getInstanceInfo(String assetGroup, Map<String, String> filters) throws DataException { Map<String, Object> mustFilter = new HashMap<>(); mustFilter.put(LATEST, true); mustFilter.put(STATE_NAME, RUNNING); Map<String, Object> mustNotFilter = new HashMap<>(); mustNotFilter.put(PLATFORM, WINDOWS); if (null != filters && filters.size() > 0) { filters.forEach((key, value) -> mustFilter.put(key, value)); } try{ return elasticSearchRepository .getSortedDataFromES(assetGroup, "ec2", mustFilter, mustNotFilter, null, Arrays.asList("tags.Name", TAGS_APPLICATION, RESOURCEID, "tags.Environment", "accountname", "vpcid", "privateipaddress"), null, null); } catch(Exception e){ throw new DataException(e); } }  @Override List<Map<String, Object>> getPatchingProgress(String assetGroup,
            LocalDate startDate, LocalDate endDate); @Override List<Map<String, Object>> getIssueInfo(String assetGroup); List<Map<String, Object>> getClosedIssueInfo(String assetGroup,
            int size); @Override List<Map<String, Object>> getInstanceInfo(String assetGroup,
            Map<String, String> filters); @Override List<Map<String, Object>> getExecAndDirectorInfo(); @Override long getInstanceInfoCount(String assetGroup,
            Map<String, String> filters, String searchText); @Override String getAmilAvailDate(int year, int quarter); @Override int getPatchingWindow(); @Override Map<String, Long> getQuartersWithPatchingData(String assetGroup); Map<String, Object> addParentConditionPatching(String targetType); @Override List<Map<String, Object>> getOnpremIssueInfo(String assetGroup); @Override List<Map<String, Object>> getOnpremResourceInfo(String assetGroup,
            Map<String, String> filters); @Override Map<String, Object> getDirectorsAndExcutiveSponsers(String appTag,
            String appType); @Override Map<String, Long> getNonCompliantNumberForAgAndResourceType(
            String assetGroup, String resourceType); @Override List<Map<String, Object>> getPatchingPercentForDateRange(String assetGroup, LocalDate fromDate,
			LocalDate toDate);  }