### Question:
TaggingRepositoryImpl implements TaggingRepository, Constants { @Override public String getTaggingByApplication(String ag, String targetType) throws DataException { StringBuilder requestBody = new StringBuilder(); StringBuilder urlToQuery = new StringBuilder(esUrl).append("/").append( ag); if (!StringUtils.isEmpty(targetType)) { urlToQuery.append("/").append(targetType); urlToQuery.append("/").append(UNDERSCORE_COUNT); requestBody .append("{\"query\":{\"bool\":{\"must\":[{\"match\":{\"latest\":\"true\"}}],\"must_not\":[{\"exists\":{\"field\":\"tags.Application\"}}]}}}"); } else { urlToQuery.append("/").append(SEARCH); requestBody .append("{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"match\":{\"latest\":\"true\"}}],\"must_not\":[{\"exists\":{\"field\":\"tags.Application\"}}]}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"_entitytype.keyword\",\"size\":" + TEN_THOUSAND + "}}}}"); } String responseJson = ""; try { responseJson = PacHttpUtils.doHttpPost(urlToQuery.toString(), requestBody.toString()); } catch (Exception e) { logger.error(e.getMessage()); throw new DataException(e); } return responseJson; }  JsonArray getUntaggedIssuesByapplicationFromES(String assetGroup,
            String mandatoryTags, String searchText, int from, int size); List<Map<String, Object>> getRuleParamsFromDbByPolicyId(
            String policyId); Long getUntaggedIssues(String assetGroup, String mandatoryTag); List<Map<String, Object>> getRuleTargetTypesFromDbByPolicyId(
            String policyId); String getUntaggedTargetTypeIssues(
            UntaggedTargetTypeRequest request, List<String> tagsList); @Override String getTaggingByApplication(String ag, String targetType);  }### Answer:
@Test public void getTaggingByApplicationTest() throws Exception { String response = "{\"count\":239,\"_shards\":{\"total\":176,\"successful\":176,\"skipped\":0,\"failed\":0}}"; mockStatic(PacHttpUtils.class); when(PacHttpUtils.doHttpPost(anyString(), anyString())).thenReturn(response); ReflectionTestUtils.setField(taggingRepositoryImpl, "esUrl", "dummyEsURL"); assertThat(taggingRepositoryImpl.getTaggingByApplication("aws-all", "ec2"), is(notNullValue())); assertThat(taggingRepositoryImpl.getTaggingByApplication("aws-all", null), is(notNullValue())); when(PacHttpUtils.doHttpPost(anyString(), anyString())).thenThrow(new DataException()); assertThatThrownBy(() -> taggingRepositoryImpl.getTaggingByApplication("aws-all", "ec2")) .isInstanceOf(DataException.class); }