コード例 #1
0
 @Test
 public void testAnnotatedNamedQueryNameUsage() throws Exception {
   SolrQueryMethod method = getQueryMethodByName("findByAnnotatedNamedQueryName", String.class);
   Assert.assertFalse(method.hasAnnotatedQuery());
   Assert.assertTrue(method.hasAnnotatedNamedQueryName());
   Assert.assertFalse(method.hasFilterQuery());
   Assert.assertEquals("ProductRepository.namedQuery-1", method.getAnnotatedNamedQueryName());
 }
コード例 #2
0
 @Test
 public void testWithoutAnnotation() throws Exception {
   SolrQueryMethod method = getQueryMethodByName("findByName", String.class);
   Assert.assertFalse(method.hasAnnotatedQuery());
   Assert.assertFalse(method.hasFilterQuery());
   Assert.assertFalse(method.hasAnnotatedNamedQueryName());
   Assert.assertFalse(method.isHighlightQuery());
 }
コード例 #3
0
 @Test
 public void testAnnotatedQueryUsage() throws Exception {
   SolrQueryMethod method = getQueryMethodByName("findByAnnotatedQuery", String.class);
   Assert.assertTrue(method.hasAnnotatedQuery());
   Assert.assertFalse(method.hasAnnotatedNamedQueryName());
   Assert.assertFalse(method.hasProjectionFields());
   Assert.assertFalse(method.hasFilterQuery());
   Assert.assertEquals("name:?0", method.getAnnotatedQuery());
 }
コード例 #4
0
 @Test
 public void testAnnotatedQueryUsageWithoutExplicitAttribute() throws Exception {
   SolrQueryMethod method =
       getQueryMethodByName("findByAnnotatedQueryWithoutExplicitAttribute", String.class);
   Assert.assertTrue(method.hasAnnotatedQuery());
   Assert.assertFalse(method.hasAnnotatedNamedQueryName());
   Assert.assertFalse(method.hasFilterQuery());
   Assert.assertEquals("name:?0", method.getAnnotatedQuery());
 }
コード例 #5
0
 @Test
 public void testWithMultipleFieldsProjection() throws Exception {
   SolrQueryMethod method =
       getQueryMethodByName("findByAnnotatedQueryWithProjectionOnMultipleFields", String.class);
   Assert.assertTrue(method.hasAnnotatedQuery());
   Assert.assertTrue(method.hasProjectionFields());
   Assert.assertFalse(method.hasFilterQuery());
   Assert.assertEquals(2, method.getProjectionFields().size());
   Assert.assertFalse(method.hasAnnotatedNamedQueryName());
   Assert.assertEquals("name:?0", method.getAnnotatedQuery());
 }
コード例 #6
0
  @Test
  public void testWithSigleFilter() throws Exception {
    SolrQueryMethod method = getQueryMethodByName("findByNameStringWith", String.class);
    Assert.assertFalse(method.hasAnnotatedQuery());
    Assert.assertFalse(method.hasProjectionFields());
    Assert.assertFalse(method.hasFacetFields());
    Assert.assertFalse(method.hasAnnotatedNamedQueryName());
    Assert.assertTrue(method.hasFilterQuery());

    Assert.assertEquals(1, method.getFilterQueries().size());
  }
コード例 #7
0
  @Test
  public void testWithMultipleFilters() throws Exception {
    SolrQueryMethod method =
        getQueryMethodByName("findAllFilterAvailableTrueAndPopularityLessThan5", String.class);
    Assert.assertTrue(method.hasAnnotatedQuery());
    Assert.assertFalse(method.hasProjectionFields());
    Assert.assertFalse(method.hasFacetFields());
    Assert.assertFalse(method.hasAnnotatedNamedQueryName());
    Assert.assertTrue(method.hasFilterQuery());

    Assert.assertEquals(2, method.getFilterQueries().size());
  }
コード例 #8
0
 @Test
 public void testWithMultipleFieldPivot() throws Exception {
   SolrQueryMethod method =
       getQueryMethodByName("findByNamePivotOnField1VsField2AndField2VsField3");
   Assert.assertFalse(method.hasAnnotatedQuery());
   Assert.assertFalse(method.hasProjectionFields());
   Assert.assertFalse(method.hasFacetFields());
   Assert.assertTrue(method.hasPivotFields());
   Assert.assertFalse(method.hasFacetQueries());
   Assert.assertEquals(2, method.getPivotFields().size());
   Assert.assertFalse(method.hasAnnotatedNamedQueryName());
   Assert.assertFalse(method.hasFilterQuery());
 }
コード例 #9
0
  @Test
  public void testWithSingleFieldFacet() throws Exception {
    SolrQueryMethod method = getQueryMethodByName("findByNameFacetOnPopularity", String.class);
    Assert.assertFalse(method.hasAnnotatedQuery());
    Assert.assertFalse(method.hasProjectionFields());
    Assert.assertFalse(method.hasAnnotatedNamedQueryName());
    Assert.assertTrue(method.hasFacetFields());
    Assert.assertFalse(method.hasFacetQueries());
    Assert.assertFalse(method.hasFilterQuery());

    Assert.assertEquals(1, method.getFacetFields().size());
    Assert.assertEquals(Integer.valueOf(10), method.getFacetLimit());
    Assert.assertEquals(Integer.valueOf(1), method.getFacetMinCount());
  }
コード例 #10
0
  @Test
  public void testWithMultipleFieldFacetsLimitAndMinCount() throws Exception {
    SolrQueryMethod method =
        getQueryMethodByName("findByNameFacetOnPopularityAndPriceMinCount3Limit25", String.class);
    Assert.assertFalse(method.hasAnnotatedQuery());
    Assert.assertFalse(method.hasProjectionFields());
    Assert.assertTrue(method.hasFacetFields());
    Assert.assertFalse(method.hasFacetQueries());
    Assert.assertFalse(method.hasAnnotatedNamedQueryName());
    Assert.assertFalse(method.hasFilterQuery());

    Assert.assertEquals(2, method.getFacetFields().size());
    Assert.assertEquals(Integer.valueOf(25), method.getFacetLimit());
    Assert.assertEquals(Integer.valueOf(3), method.getFacetMinCount());
  }
コード例 #11
0
  @Test
  public void testWithMultipleFieldPivotsLimitAndMinCount() throws Exception {
    SolrQueryMethod method =
        getQueryMethodByName("findByNamePivotOnField1VsField2AndField2VsField3AndLimitAndMinCount");
    Assert.assertFalse(method.hasAnnotatedQuery());
    Assert.assertFalse(method.hasProjectionFields());
    Assert.assertFalse(method.hasFacetFields());
    Assert.assertTrue(method.hasPivotFields());
    Assert.assertFalse(method.hasFacetQueries());
    Assert.assertFalse(method.hasAnnotatedNamedQueryName());
    Assert.assertFalse(method.hasFilterQuery());

    Assert.assertEquals(2, method.getPivotFields().size());
    Assert.assertEquals(Integer.valueOf(25), method.getFacetLimit());
    Assert.assertEquals(Integer.valueOf(3), method.getFacetMinCount());
  }
コード例 #12
0
  @Test
  public void testWithMultipleQueryFacets() throws Exception {
    SolrQueryMethod method = getQueryMethodByName("findByNameFacetOnAvailableQuery", String.class);
    Assert.assertFalse(method.hasAnnotatedQuery());
    Assert.assertFalse(method.hasProjectionFields());
    Assert.assertFalse(method.hasAnnotatedNamedQueryName());
    Assert.assertFalse(method.hasFacetFields());
    Assert.assertTrue(method.hasFacetQueries());
    Assert.assertFalse(method.hasFilterQuery());

    Assert.assertEquals(0, method.getFacetFields().size());
    Assert.assertEquals(2, method.getFacetQueries().size());
    Assert.assertEquals(Integer.valueOf(10), method.getFacetLimit());
    Assert.assertEquals(Integer.valueOf(1), method.getFacetMinCount());
    Assert.assertEquals("inStock:true", method.getFacetQueries().get(0));
    Assert.assertEquals("inStock:false", method.getFacetQueries().get(1));
  }