@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()); }
@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()); }
@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()); }
@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()); }
@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()); }
@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()); }
@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()); }
@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()); }
@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()); }
@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()); }
@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()); }
@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)); }