Codota Logo
TermFacetExpression.resultPath
Code IndexAdd Codota to your IDE (free)

How to use
resultPath
method
in
io.sphere.sdk.search.TermFacetExpression

Best Java code snippets using io.sphere.sdk.search.TermFacetExpression.resultPath (Showing top 10 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
FileOutputStream f =
  • Codota IconFile file;new FileOutputStream(file)
  • Codota IconString name;new FileOutputStream(name)
  • Codota IconFile file;new FileOutputStream(file, true)
  • Smart code suggestions by Codota
}
origin: io.sphere.sdk.jvm/common

@SuppressWarnings("unchecked")
public <V> Optional<TermFacetResult<V>> getTermFacetResult(final TermFacetExpression<T, V> facetExpression) {
  return getFacetResult(facetExpression.resultPath()).map(facetResult -> {
    if (facetResult instanceof TermFacetResult) {
      return (TermFacetResult) facetResult;
    } else {
      // TODO Use another type of exception once exception task is finished
      throw new RuntimeException("Facet result is not of type TermFacetResult: " + facetResult);
    }
  });
}
origin: commercetools/commercetools-jvm-sdk

public TermFacetResult getFacetResult(final TermFacetExpression<T> facetExpression) {
  return getTermFacetResult(facetExpression.resultPath());
}
origin: commercetools/commercetools-jvm-sdk

private <T> void testPagedSearchResult(final Consumer<PagedSearchResult<T>> test) {
  final Map<String, FacetResult> facets = new HashMap<>();
  facets.put(TERM_FACET_EXPR.resultPath(), TERM_FACET_RESULT);
  facets.put(RANGE_FACET_EXPR.resultPath(), RANGE_FACET_RESULT);
  facets.put(FILTERED_FACET_EXPR.resultPath(), FILTERED_FACET_RESULT);
  final PagedSearchResult<T> result = pagedSearchResult(facets);
  test.accept(result);
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void buildsTermFacetExpressionWithAlias() throws Exception {
  final TermFacetExpression<Object> facet = TermFacetExpression.of(ATTRIBUTE_PATH + AS_ALIAS);
  assertThat(facet.expression()).isEqualTo(ATTRIBUTE_PATH + AS_ALIAS);
  assertThat(facet.attributePath()).isEqualTo(ATTRIBUTE_PATH);
  assertThat(facet.value()).isNull();
  assertThat(facet.alias()).isEqualTo(ALIAS);
  assertThat(facet.resultPath()).isEqualTo(ALIAS);
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void buildsTermFacetExpression() throws Exception {
  final TermFacetExpression<Object> facet = TermFacetExpression.of(ATTRIBUTE_PATH);
  assertThat(facet.expression()).isEqualTo(ATTRIBUTE_PATH);
  assertThat(facet.attributePath()).isEqualTo(ATTRIBUTE_PATH);
  assertThat(facet.value()).isNull();
  assertThat(facet.alias()).isNull();
  assertThat(facet.resultPath()).isEqualTo(ATTRIBUTE_PATH);
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void rangeFacetResult() throws Exception {
  testPagedSearchResult(result -> {
    assertThat(result.getFacetResult(RANGE_FACET_EXPR)).isEqualTo(RANGE_FACET_RESULT);
    assertThat(result.getRangeFacetResult("non-existent")).isNull();
    assertThatThrownBy(() -> result.getRangeFacetResult(TERM_FACET_EXPR.resultPath()))
        .isInstanceOf(IllegalArgumentException.class);
    assertThatThrownBy(() -> result.getRangeFacetResult(FILTERED_FACET_EXPR.resultPath()))
        .isInstanceOf(IllegalArgumentException.class);
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void filteredFacetResult() throws Exception {
  testPagedSearchResult(result -> {
    assertThat(result.getFacetResult(FILTERED_FACET_EXPR)).isEqualTo(FILTERED_FACET_RESULT);
    assertThat(result.getFilteredFacetResult("non-existent")).isNull();
    assertThatThrownBy(() -> result.getFilteredFacetResult(TERM_FACET_EXPR.resultPath()))
        .isInstanceOf(IllegalArgumentException.class);
    assertThatThrownBy(() -> result.getFilteredFacetResult(RANGE_FACET_EXPR.resultPath()))
        .isInstanceOf(IllegalArgumentException.class);
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void buildsTermFacetExpressionWithAlias() throws Exception {
  final TermFacetExpression<Object> facet = TermFacetSearchModel.of(ATTRIBUTE_PATH, ofString()).withAlias(ALIAS).allTerms();
  assertThat(facet.expression()).isEqualTo(ATTRIBUTE_PATH + AS_ALIAS);
  assertThat(facet.attributePath()).isEqualTo(ATTRIBUTE_PATH);
  assertThat(facet.value()).isNull();
  assertThat(facet.alias()).isEqualTo(ALIAS);
  assertThat(facet.resultPath()).isEqualTo(ALIAS);
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void buildsTermFacetExpression() throws Exception {
  final TermFacetExpression<Object> facet = TermFacetSearchModel.of(ATTRIBUTE_PATH, ofString()).allTerms();
  assertThat(facet.expression()).isEqualTo(ATTRIBUTE_PATH);
  assertThat(facet.attributePath()).isEqualTo(ATTRIBUTE_PATH);
  assertThat(facet.value()).isNull();
  assertThat(facet.alias()).isNull();
  assertThat(facet.resultPath()).isEqualTo(ATTRIBUTE_PATH);
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void termFacetsSupportsAlias() throws Exception {
  final String allFacetAlias = "my-facet";
  final String blueFacetAlias = "my-blue-facet";
  final TermFacetExpression<ProductProjection> allFacetExpr = PRODUCT_MODEL.allVariants().attribute().ofString(ATTR_NAME_COLOR).withAlias(allFacetAlias).allTerms();
  final FilteredFacetExpression<ProductProjection> blueFacetExpr = PRODUCT_MODEL.allVariants().attribute().ofString(ATTR_NAME_COLOR).withAlias(blueFacetAlias).onlyTerm("blue");
  final ProductProjectionSearch search = ProductProjectionSearch.ofStaged()
      .plusFacets(allFacetExpr)
      .plusFacets(blueFacetExpr);
  testResult(search, result -> {
    final TermFacetResult allFacetResult = result.getFacetResult(allFacetExpr);
    final FilteredFacetResult blueFacetResult = result.getFilteredFacetResult(blueFacetAlias);
    assertThat(allFacetExpr.resultPath()).isEqualTo(allFacetAlias);
    assertThat(blueFacetExpr.resultPath()).isEqualTo(blueFacetAlias);
    assertThat(allFacetResult.getTerms()).isEqualTo(asList(TermStats.of("blue", 2L), TermStats.of("red", 1L)));
    assertThat(blueFacetResult.getCount()).isEqualTo(2);
  });
}
io.sphere.sdk.searchTermFacetExpressionresultPath

Popular methods of TermFacetExpression

  • expression
  • of
  • <init>
  • alias
  • attributePath
  • toSphereFacet
  • value

Popular in Java

  • Running tasks concurrently on multiple threads
  • putExtra (Intent)
  • runOnUiThread (Activity)
  • getContentResolver (Context)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • ImageIO (javax.imageio)
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now