@SuppressWarnings("unchecked") @Test public void getAttributeValuesTest() throws IOException { AttributeValuesRequest attributeValuesRequest = getAttributeValuesRequest(); when(config.getElasticSearch()).thenReturn(getElasticSearchProperty()); HttpEntity jsonEntity = new StringEntity("{}", ContentType.APPLICATION_JSON); 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); Map<String, Object> ruleParamDetails = Maps.newHashMap(); when(mapper.readValue(anyString(), any(TypeReference.class))).thenReturn(ruleParamDetails); assertThat(targetTypesService.getAttributeValues(attributeValuesRequest), is(notNullValue())); }
@Override public Map<String, Object> getAttributeValues(AttributeValuesRequest attributeValuesRequest) { try { Response response = invokeAPI("GET", attributeValuesRequest.getIndex(), attributeValuesRequest.getPayload()); if(response != null) { String attributeValues = EntityUtils.toString(response.getEntity()); return mapper.readValue(attributeValues, new TypeReference<Map<String, Object>>(){}); } } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); } return Maps.newHashMap(); }
TargetTypesServiceImpl implements TargetTypesService { @Override public Map<String, Object> getAttributeValues(AttributeValuesRequest attributeValuesRequest) { try { Response response = invokeAPI("GET", attributeValuesRequest.getIndex(), attributeValuesRequest.getPayload()); if(response != null) { String attributeValues = EntityUtils.toString(response.getEntity()); return mapper.readValue(attributeValues, new TypeReference<Map<String, Object>>(){}); } } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); } return Maps.newHashMap(); } }
TargetTypesServiceImpl implements TargetTypesService { @Override public Map<String, Object> getAttributeValues(AttributeValuesRequest attributeValuesRequest) { try { Response response = invokeAPI("GET", attributeValuesRequest.getIndex(), attributeValuesRequest.getPayload()); if(response != null) { String attributeValues = EntityUtils.toString(response.getEntity()); return mapper.readValue(attributeValues, new TypeReference<Map<String, Object>>(){}); } } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); } return Maps.newHashMap(); }  }
TargetTypesServiceImpl implements TargetTypesService { @Override public Map<String, Object> getAttributeValues(AttributeValuesRequest attributeValuesRequest) { try { Response response = invokeAPI("GET", attributeValuesRequest.getIndex(), attributeValuesRequest.getPayload()); if(response != null) { String attributeValues = EntityUtils.toString(response.getEntity()); return mapper.readValue(attributeValues, new TypeReference<Map<String, Object>>(){}); } } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); } return Maps.newHashMap(); }  @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); }
TargetTypesServiceImpl implements TargetTypesService { @Override public Map<String, Object> getAttributeValues(AttributeValuesRequest attributeValuesRequest) { try { Response response = invokeAPI("GET", attributeValuesRequest.getIndex(), attributeValuesRequest.getPayload()); if(response != null) { String attributeValues = EntityUtils.toString(response.getEntity()); return mapper.readValue(attributeValues, new TypeReference<Map<String, Object>>(){}); } } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); } return Maps.newHashMap(); }  @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);  }