@Test public void testFilterQueriesReturnNull() { GraphqlClient graphqlClient = Mockito.mock(GraphqlClient.class); context.registerAdapter(Resource.class, GraphqlClient.class, (Function<Resource, GraphqlClient>) input -> input.getValueMap().get( "cq:graphqlClient") != null ? graphqlClient : null); Query query = new Query(); GraphqlResponse<Object, Object> response = new GraphqlResponse<Object, Object>(); response.setData(query); when(graphqlClient.execute(any(), any(), any(), any())).thenReturn(response); context.registerAdapter(Resource.class, GraphqlClient.class, (Function<Resource, GraphqlClient>) input -> input.getValueMap().get("cq:graphqlClient") != null ? graphqlClient : null); final List<FilterAttributeMetadata> filterAttributeMetadata = searchFilterServiceUnderTest .retrieveCurrentlyAvailableCommerceFilters(page); assertThat(filterAttributeMetadata).hasSize(0); }
@Override public List<FilterAttributeMetadata> retrieveCurrentlyAvailableCommerceFilters(final Page page) { Resource resource = new SyntheticResource(null, (String) null, SearchFilterService.class.getName()); MagentoGraphqlClient magentoGraphqlClient = MagentoGraphqlClient.create(resource, page); final List<__InputValue> availableFilters = fetchAvailableSearchFilters(magentoGraphqlClient); final List<Attribute> attributes = fetchAttributeMetadata(magentoGraphqlClient, availableFilters); FilterAttributeMetadataConverter converter = new FilterAttributeMetadataConverter(attributes); return availableFilters.stream().map(converter).collect(Collectors.toList()); }
SearchFilterServiceImpl implements SearchFilterService { @Override public List<FilterAttributeMetadata> retrieveCurrentlyAvailableCommerceFilters(final Page page) { Resource resource = new SyntheticResource(null, (String) null, SearchFilterService.class.getName()); MagentoGraphqlClient magentoGraphqlClient = MagentoGraphqlClient.create(resource, page); final List<__InputValue> availableFilters = fetchAvailableSearchFilters(magentoGraphqlClient); final List<Attribute> attributes = fetchAttributeMetadata(magentoGraphqlClient, availableFilters); FilterAttributeMetadataConverter converter = new FilterAttributeMetadataConverter(attributes); return availableFilters.stream().map(converter).collect(Collectors.toList()); } }
SearchFilterServiceImpl implements SearchFilterService { @Override public List<FilterAttributeMetadata> retrieveCurrentlyAvailableCommerceFilters(final Page page) { Resource resource = new SyntheticResource(null, (String) null, SearchFilterService.class.getName()); MagentoGraphqlClient magentoGraphqlClient = MagentoGraphqlClient.create(resource, page); final List<__InputValue> availableFilters = fetchAvailableSearchFilters(magentoGraphqlClient); final List<Attribute> attributes = fetchAttributeMetadata(magentoGraphqlClient, availableFilters); FilterAttributeMetadataConverter converter = new FilterAttributeMetadataConverter(attributes); return availableFilters.stream().map(converter).collect(Collectors.toList()); }  }
SearchFilterServiceImpl implements SearchFilterService { @Override public List<FilterAttributeMetadata> retrieveCurrentlyAvailableCommerceFilters(final Page page) { Resource resource = new SyntheticResource(null, (String) null, SearchFilterService.class.getName()); MagentoGraphqlClient magentoGraphqlClient = MagentoGraphqlClient.create(resource, page); final List<__InputValue> availableFilters = fetchAvailableSearchFilters(magentoGraphqlClient); final List<Attribute> attributes = fetchAttributeMetadata(magentoGraphqlClient, availableFilters); FilterAttributeMetadataConverter converter = new FilterAttributeMetadataConverter(attributes); return availableFilters.stream().map(converter).collect(Collectors.toList()); }  @Override List<FilterAttributeMetadata> retrieveCurrentlyAvailableCommerceFilters(final Page page); }
SearchFilterServiceImpl implements SearchFilterService { @Override public List<FilterAttributeMetadata> retrieveCurrentlyAvailableCommerceFilters(final Page page) { Resource resource = new SyntheticResource(null, (String) null, SearchFilterService.class.getName()); MagentoGraphqlClient magentoGraphqlClient = MagentoGraphqlClient.create(resource, page); final List<__InputValue> availableFilters = fetchAvailableSearchFilters(magentoGraphqlClient); final List<Attribute> attributes = fetchAttributeMetadata(magentoGraphqlClient, availableFilters); FilterAttributeMetadataConverter converter = new FilterAttributeMetadataConverter(attributes); return availableFilters.stream().map(converter).collect(Collectors.toList()); }  @Override List<FilterAttributeMetadata> retrieveCurrentlyAvailableCommerceFilters(final Page page);  }