@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 testQueryWithHighlightMultipleFields() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByTextHighlightMultipleFields", String.class); Assert.assertThat( Arrays.asList("field_1", "field_2", "field_3"), IsEqual.equalTo(method.getHighlightFieldNames())); }
@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 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 testQueryWithEmptyHighlight() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByTextLike", String.class); Assert.assertTrue(method.isHighlightQuery()); Assert.assertNull(method.getHighlightFormatter()); Assert.assertNull(method.getHighlightQuery()); Assert.assertNull(method.getHighlighSnipplets()); Assert.assertThat(method.getHighlightFieldNames(), IsEmptyCollection.empty()); Assert.assertNull(method.getHighlightFragsize()); Assert.assertNull(method.getHighlightPrefix()); Assert.assertNull(method.getHighlightPostfix()); }
@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 testWithMultipleFieldFacets() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByNameFacetOnPopularityAndPrice", String.class); Assert.assertFalse(method.hasAnnotatedQuery()); Assert.assertFalse(method.hasProjectionFields()); Assert.assertTrue(method.hasFacetFields()); Assert.assertFalse(method.hasFacetQueries()); Assert.assertEquals(2, method.getFacetFields().size()); Assert.assertFalse(method.hasAnnotatedNamedQueryName()); Assert.assertFalse(method.hasFilterQuery()); }
@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 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 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()); }
/** @see DATASOLR-144 */ @Test public void testDeleteAttrbiteOfAnnotatedQueryIsFalseByDefault() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByAnnotatedQuery", String.class); Assert.assertFalse(method.isDeleteQuery()); }
/** @see DATASOLR-144 */ @Test public void testDeleteAttrbiteOfAnnotatedQueryIsDiscoveredCorrectlty() throws Exception { SolrQueryMethod method = getQueryMethodByName("removeByAnnotatedQuery"); Assert.assertTrue(method.isDeleteQuery()); }
@Test public void testQueryWithHighlightPostfix() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByTextHighlightPostfix", String.class); Assert.assertEquals("{postfix}", method.getHighlightPostfix()); }
@Test public void testQueryWithNegativeHighlightFragsize() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByTextNegativeHighlightFragsize", String.class); Assert.assertNull(method.getHighlightFragsize()); }
@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 testWithFacetPrefix() throws Exception { SolrQueryMethod method = getQueryMethodByName("findAllFacetOnNameWithPrefix"); Assert.assertEquals(1, method.getFacetFields().size()); Assert.assertEquals("ip", method.getFacetPrefix()); }
@Test public void testQueryWithRequestHandler() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByText", String.class); Assert.assertEquals("/instock", method.getRequestHandler()); }
@Test public void testQueryWithDefType() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByNameEndingWith", String.class); Assert.assertEquals("lucene", method.getDefType()); }
@Test public void testQueryWithNegativeTimeAllowed() throws Exception { SolrQueryMethod method = getQueryMethodByName("findAllWithNegativeTimeRestriction", String.class); Assert.assertNull(method.getTimeAllowed()); }
@Test public void testQueryWithPositiveTimeAllowed() throws Exception { SolrQueryMethod method = getQueryMethodByName("findAllWithPositiveTimeRestriction", String.class); Assert.assertEquals(Integer.valueOf(250), method.getTimeAllowed()); }
@Test public void testWithQueryDefaultOperator() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByNameStringWith", String.class); Assert.assertEquals( org.springframework.data.solr.core.query.Query.Operator.NONE, method.getDefaultOperator()); }
@Test public void testWithMultipleQueryFacetsLimitAndMinCount() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByNameFacetOnAvailableQueryMinCount3Limit25", 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(25), method.getFacetLimit()); Assert.assertEquals(Integer.valueOf(3), method.getFacetMinCount()); Assert.assertEquals("inStock:true", method.getFacetQueries().get(0)); Assert.assertEquals("inStock:false", method.getFacetQueries().get(1)); }
@Test public void testQueryWithHighlightFormatter() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByTextHighlightFormatter", String.class); Assert.assertEquals("simple", method.getHighlightFormatter()); }
@Test public void testQueryWithHighlightQuery() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByTextHighlightQuery", String.class); Assert.assertEquals("field_1:value*", method.getHighlightQuery()); }
@Test public void testQueryWithHighlightFragsize() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByTextHighlightFragsize", String.class); Assert.assertEquals(Integer.valueOf(3), method.getHighlightFragsize()); }
public StringBasedSolrQuery(SolrQueryMethod method, SolrOperations solrOperations) { this(method.getAnnotatedQuery(), method, solrOperations); }
@Test public void testWithoutFacetPrefix() throws Exception { SolrQueryMethod method = getQueryMethodByName("findByNameFacetOnPopularity", String.class); Assert.assertNull(method.getFacetPrefix()); }