### Question:
ProjectionRepositoryImpl implements ProjectionRepository, Constants { @Override public Map<Integer, Long> getPatchingSnapshot(String assetGroup) throws DataException { String responseJson = null; JsonParser jsonParser; JsonObject resultJson; Map<Integer, Long> patchedInstancesMap = new HashMap<>(); LocalDate today = LocalDate.now(); List<LocalDate> dates = updateCurrentWeekDate(today, getListOfLastWeekDateOfQuarter()); StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append("/").append("assetgroup_stats").append("/") .append("patching").append("/").append("_search").append("?").append("size").append("=") .append(ES_PAGE_SIZE); StringBuilder requestBody = new StringBuilder( "{\"sort\":[{\"date\":{\"order\":\"asc\"}}],\"query\":{\"bool\":{\"must\":[{\"terms\":{\"date\":["); for (LocalDate date : dates) { requestBody.append("\"" + date + "\","); } requestBody.deleteCharAt(requestBody.lastIndexOf(",")); requestBody.append("]}},{\"match\":{\"ag.keyword\":\"" + assetGroup + "\"}}]}}}"); try { responseJson = PacHttpUtils.doHttpPost(urlToQueryBuffer.toString(), requestBody.toString()); } catch (Exception e) { logger.error(e); throw new DataException(e); } jsonParser = new JsonParser(); resultJson = (JsonObject) jsonParser.parse(responseJson); if (resultJson != null) { patchedInstancesMap = processJsonData(resultJson); } return patchedInstancesMap; }  @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 getPatchingSnapshotTest()throws Exception { String response = "{\"took\":134,\"timed_out\":false,\"_shards\":{\"total\":5,\"successful\":5,\"failed\":0},\"hits\":{\"total\":39703,\"max_score\":1,\"hits\":[{\"_index\":\"assetgroup_stats\",\"_type\":\"patching\",\"_id\":\"EAB576835F943FE515EE98EC4CED313A\",\"_score\":1,\"_source\":{\"date\":\"2018-01-11\",\"unpatched_instances\":36,\"ag\":\"adapt\",\"@id\":\"EAB576835F943FE515EE98EC4CED313A\",\"patched_instances\":5,\"total_instances\":41,\"patching_percentage\":12}}]}}"; mockStatic(PacHttpUtils.class); ReflectionTestUtils.setField(projectionRepositoryImpl, "esUrl", "dummyEsURL"); when(PacHttpUtils.doHttpPost(anyString(), anyString())).thenReturn(response); projectionRepositoryImpl.getPatchingSnapshot("aws-all"); when(PacHttpUtils.doHttpPost(anyString(), anyString())).thenThrow(new RuntimeException()); assertThatThrownBy(() -> projectionRepositoryImpl.getPatchingSnapshot("aws-all")).isInstanceOf( DataException.class); }