@Test public void testRetrieveMetadata() { 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(29); FilterAttributeMetadata price = filterAttributeMetadata.stream().filter(f -> f.getAttributeCode().equals("price")).findFirst() .get(); assertThat(price.getFilterInputType()).isEqualTo("FilterRangeTypeInput"); assertThat(price.getAttributeType()).isEqualTo("Float"); assertThat(price.getAttributeInputType()).isEqualTo("price"); FilterAttributeMetadata material = filterAttributeMetadata.stream().filter(f -> f.getAttributeCode().equals("material")).findFirst() .get(); assertThat(material.getFilterInputType()).isEqualTo("FilterEqualTypeInput"); assertThat(material.getAttributeType()).isEqualTo("String"); assertThat(material.getAttributeInputType()).isEqualTo("multiselect"); FilterAttributeMetadata newAttr = filterAttributeMetadata.stream().filter(f -> f.getAttributeCode().equals("new")).findFirst() .get(); assertThat(newAttr.getFilterInputType()).isEqualTo("FilterEqualTypeInput"); assertThat(newAttr.getAttributeType()).isEqualTo("Int"); assertThat(newAttr.getAttributeInputType()).isEqualTo("boolean"); }
@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);  }