### Question:
TargetTypesServiceImpl implements TargetTypesService { @Override public List<TargetTypeAttribute> getTargetTypeAttributes(final List<TargetTypes> targetTypes) { List<TargetTypeAttribute> attributes = Lists.newArrayList(); for (TargetTypes targetType : targetTypes) { String targetName = targetType.getTargetName().trim(); String dataSourceName = targetType.getDataSourceName().trim(); TargetTypeAttribute targetTypeAttribute = new TargetTypeAttribute(); targetTypeAttribute.setAttributes(Lists.newArrayList()); targetTypeAttribute.setTargetName(targetType.getTargetName().trim()); targetTypeAttribute.setAllAttributesName(getFieldNames(dataSourceName + "_" + targetName, targetName)); targetTypeAttribute.setIncludeAll(false); targetTypeAttribute.setIndex("/"+dataSourceName + "_" + targetName); attributes.add(targetTypeAttribute); } return attributes; }  @Override Collection<String> getTargetTypesNamesByDataSourceName(final String dataSourceName); @Override List<TargetTypes> getAllTargetTypesByDomainList(final List<String> domains); @Override Page<TargetTypesProjections> getAllTargetTypeDetails(String searchTerm, int page, int size); @Override List<String> getAllTargetTypesCategories(); @Override List<TargetTypesDetails> getAllTargetTypes(List<AssetGroupTargetTypes> selectedTargetTypes); @Override List<TargetTypeAttribute> getTargetTypeAttributes(final List<TargetTypes> targetTypes); @Override Map<String, Object> getAttributeValues(AttributeValuesRequest attributeValuesRequest); @Override TargetTypes getTargetTypesByName(String targetTypeName); @Override String updateTargetTypeDetails(CreateUpdateTargetTypeDetailsRequest targetTypesDetails, final String userId); @Override String addTargetTypeDetails(final CreateUpdateTargetTypeDetailsRequest targetTypeDetailsRequest, final String userId); @Override void deleteIndex(String targetTypeIndex);  }### Answer:
@SuppressWarnings("unchecked") @Test public void getTargetTypeAttributesTest() throws IOException { when(config.getElasticSearch()).thenReturn(getElasticSearchProperty()); HttpEntity jsonEntity = new StringEntity("{}", ContentType.APPLICATION_JSON); when(targetTypesRepository.existsById(anyString())).thenReturn(false); when(response.getEntity()).thenReturn(jsonEntity); when(restClient.performRequest(anyString(), anyString(), any(Map.class), any(HttpEntity.class), Matchers.<Header>anyVararg())).thenReturn(response); ReflectionTestUtils.setField(targetTypesServiceImpl, "restClient", restClient); when(sl.getStatusCode()).thenReturn(200); when(response.getStatusLine()).thenReturn(sl); String jsonString = "{\"k1\":\"v1\",\"k2\":\"v2\"}"; JsonNode actualObj = new ObjectMapper().readTree(jsonString); when(mapper.readTree(anyString())).thenReturn(actualObj); assertThat(targetTypesService.getTargetTypeAttributes(getTargetTypes()), is(notNullValue())); }