Package org.springframework.data.solr.core.query

Examples of org.springframework.data.solr.core.query.Query


  }

  @Test
  public void testWithNullSort() {
    SimpleStringCriteria criteria = new SimpleStringCriteria("field_1:value_1");
    Query query = new SimpleQuery(criteria);
    query.addSort(null); // do this explicitly

    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertNull(solrQuery.getSortField());
    Assert.assertTrue(solrQuery.getSorts().isEmpty());
  }
View Full Code Here


  }

  @Test
  public void testWithSortAscOnSingleField() {
    SimpleStringCriteria criteria = new SimpleStringCriteria("field_1:value_1");
    Query query = new SimpleQuery(criteria);
    query.addSort(new Sort("field_2"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals("field_2 asc", solrQuery.getSortField());
    Assert.assertEquals(1, solrQuery.getSorts().size());
  }
View Full Code Here

  }

  @Test
  public void testWithSortDescOnSingleField() {
    SimpleStringCriteria criteria = new SimpleStringCriteria("field_1:value_1");
    Query query = new SimpleQuery(criteria);
    query.addSort(new Sort(Sort.Direction.DESC, "field_2"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals("field_2 desc", solrQuery.getSortField());
    Assert.assertEquals(1, solrQuery.getSorts().size());
  }
View Full Code Here

  }

  @Test
  public void testWithSortAscMultipleFields() {
    SimpleStringCriteria criteria = new SimpleStringCriteria("field_1:value_1");
    Query query = new SimpleQuery(criteria);
    query.addSort(new Sort("field_2", "field_3"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals("field_2 asc,field_3 asc", solrQuery.getSortField());
    Assert.assertEquals(2, solrQuery.getSorts().size());
  }
View Full Code Here

  }

  @Test
  public void testWithSortDescMultipleFields() {
    SimpleStringCriteria criteria = new SimpleStringCriteria("field_1:value_1");
    Query query = new SimpleQuery(criteria);
    query.addSort(new Sort(Sort.Direction.DESC, "field_2", "field_3"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals("field_2 desc,field_3 desc", solrQuery.getSortField());
    Assert.assertEquals(2, solrQuery.getSorts().size());
  }
View Full Code Here

  }

  @Test
  public void testWithSortMixedDirections() {
    SimpleStringCriteria criteria = new SimpleStringCriteria("field_1:value_1");
    Query query = new SimpleQuery(criteria);
    query.addSort(new Sort("field_1"));
    query.addSort(new Sort(Sort.Direction.DESC, "field_2", "field_3"));
    SolrQuery solrQuery = queryParser.constructSolrQuery(query);
    Assert.assertEquals("field_1 asc,field_2 desc,field_3 desc", solrQuery.getSortField());
    Assert.assertEquals(3, solrQuery.getSorts().size());
  }
View Full Code Here

   * @see DATASOLR-121
   */
  @Test
  public void testConvertGroupQueryResponseToGroupResultList() {
    GroupResponse groupResponse = Mockito.mock(GroupResponse.class);
    Query query = Mockito.mock(Query.class);
    SolrTemplate solrTemplate = Mockito.mock(SolrTemplate.class);
    GroupCommand groupCommand1 = Mockito.mock(GroupCommand.class);
    Group group1_1 = Mockito.mock(Group.class);
    SolrDocumentList group1_1DocumentList = Mockito.mock(SolrDocumentList.class);
    List<Object> documents1_1 = Arrays.asList(new Object());

    Mockito.when(response.getGroupResponse()).thenReturn(groupResponse);
    Mockito.when(groupResponse.getValues()).thenReturn(Arrays.asList(groupCommand1));
    Mockito.when(groupCommand1.getValues()).thenReturn(Arrays.asList(group1_1));
    Mockito.when(group1_1.getResult()).thenReturn(group1_1DocumentList);
    Mockito.when(group1_1.getGroupValue()).thenReturn("group1_1_value");
    Mockito.when(group1_1DocumentList.getNumFound()).thenReturn(3L);
    Mockito.when(solrTemplate.convertSolrDocumentListToBeans(group1_1DocumentList, Object.class)).thenReturn(
        documents1_1);
    Mockito.when(groupCommand1.getMatches()).thenReturn(1);
    Mockito.when(groupCommand1.getName()).thenReturn("group1_name");
    Mockito.when(groupCommand1.getNGroups()).thenReturn(2);

    GroupOptions groupOptions = new GroupOptions();
    groupOptions.setLimit(1);

    Mockito.when(query.getPageRequest()).thenReturn(new PageRequest(0, 1));
    Mockito.when(query.getGroupOptions()).thenReturn(groupOptions);

    Object group1Key = new Object();
    Map<String, Object> objectNames = new HashMap<String, Object>();
    objectNames.put("group1_name", group1Key);

View Full Code Here

   * @see DATASOLR-121
   */
  @Test
  public void testConvertGroupQueryResponseToGroupResultListWhenNoCountOfGroups() {
    GroupResponse groupResponse = Mockito.mock(GroupResponse.class);
    Query query = Mockito.mock(Query.class);
    SolrTemplate solrTemplate = Mockito.mock(SolrTemplate.class);
    GroupCommand groupCommand1 = Mockito.mock(GroupCommand.class);
    Group group1_1 = Mockito.mock(Group.class);
    SolrDocumentList group1_1DocumentList = Mockito.mock(SolrDocumentList.class);
    List<Object> documents1_1 = Arrays.asList(new Object());

    Mockito.when(response.getGroupResponse()).thenReturn(groupResponse);
    Mockito.when(groupResponse.getValues()).thenReturn(Arrays.asList(groupCommand1));
    Mockito.when(groupCommand1.getValues()).thenReturn(Arrays.asList(group1_1));
    Mockito.when(group1_1.getResult()).thenReturn(group1_1DocumentList);
    Mockito.when(group1_1.getGroupValue()).thenReturn("group1_1_value");
    Mockito.when(group1_1DocumentList.getNumFound()).thenReturn(3L);
    Mockito.when(solrTemplate.convertSolrDocumentListToBeans(group1_1DocumentList, Object.class)).thenReturn(
        documents1_1);
    Mockito.when(groupCommand1.getMatches()).thenReturn(1);
    Mockito.when(groupCommand1.getName()).thenReturn("group1_name");
    Mockito.when(groupCommand1.getNGroups()).thenReturn(null);

    GroupOptions groupOptions = new GroupOptions();
    groupOptions.setLimit(1);

    Mockito.when(query.getPageRequest()).thenReturn(new PageRequest(0, 1));
    Mockito.when(query.getGroupOptions()).thenReturn(groupOptions);

    Object group1Key = new Object();
    Map<String, Object> objectNames = new HashMap<String, Object>();
    objectNames.put("group1_name", group1Key);

View Full Code Here

TOP

Related Classes of org.springframework.data.solr.core.query.Query

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.