Examples of ExampleSolrBean


Examples of org.springframework.data.solr.ExampleSolrBean

    Assert.assertEquals(Integer.valueOf(11), recalled.getPopularity());
  }

  @Test
  public void testPartialUpdateSetMultipleValuesToMultivaluedField() {
    ExampleSolrBean toInsert = createDefaultExampleBean();
    toInsert.setPopularity(10);
    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.setValueOfField("cat", Arrays.asList("spring", "data", "solr"));
    solrTemplate.saveBean(update);
    solrTemplate.commit();

    Assert.assertEquals(1, solrTemplate.count(ALL_DOCUMENTS_QUERY));

    ExampleSolrBean recalled = solrTemplate.queryForObject(DEFAULT_BEAN_OBJECT_QUERY, ExampleSolrBean.class);

    Assert.assertEquals(toInsert.getId(), recalled.getId());

    Assert.assertEquals(3, recalled.getCategory().size());
    Assert.assertEquals(Arrays.asList("spring", "data", "solr"), recalled.getCategory());

    Assert.assertEquals(toInsert.getName(), recalled.getName());
    Assert.assertEquals(toInsert.getPopularity(), recalled.getPopularity());
  }
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

    Assert.assertEquals(toInsert.getPopularity(), recalled.getPopularity());
  }

  @Test
  public void testPartialUpdateSetEmptyCollectionToMultivaluedFieldRemovesValuesFromDocument() {
    ExampleSolrBean toInsert = createDefaultExampleBean();
    toInsert.setCategory(Arrays.asList("spring", "data", "solr"));
    toInsert.setPopularity(10);
    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.setValueOfField("cat", Collections.emptyList());

    solrTemplate.saveBean(update);
    solrTemplate.commit();

    Assert.assertEquals(1, solrTemplate.count(ALL_DOCUMENTS_QUERY));

    ExampleSolrBean recalled = solrTemplate.queryForObject(DEFAULT_BEAN_OBJECT_QUERY, ExampleSolrBean.class);
    Assert.assertEquals(toInsert.getId(), recalled.getId());

    Assert.assertEquals(0, recalled.getCategory().size());

    Assert.assertEquals(toInsert.getName(), recalled.getName());
    Assert.assertEquals(toInsert.getPopularity(), recalled.getPopularity());
  }
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

    Assert.assertEquals(toInsert.getPopularity(), recalled.getPopularity());
  }

  @Test
  public void testPartialUpdateAddMultipleValuesToMultivaluedField() {
    ExampleSolrBean toInsert = createDefaultExampleBean();
    toInsert.setPopularity(10);
    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.addValueToField("cat", Arrays.asList("spring", "data", "solr"));

    solrTemplate.saveBean(update);
    solrTemplate.commit();

    Assert.assertEquals(1, solrTemplate.count(ALL_DOCUMENTS_QUERY));

    ExampleSolrBean recalled = solrTemplate.queryForObject(DEFAULT_BEAN_OBJECT_QUERY, ExampleSolrBean.class);

    Assert.assertEquals(toInsert.getId(), recalled.getId());

    Assert.assertEquals(4, recalled.getCategory().size());
    Assert.assertEquals(Arrays.asList(toInsert.getCategory().get(0), "spring", "data", "solr"), recalled.getCategory());

    Assert.assertEquals(toInsert.getName(), recalled.getName());
    Assert.assertEquals(toInsert.getPopularity(), recalled.getPopularity());
  }
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

  @Test
  public void testPartialUpdateWithMultipleDocuments() {
    List<ExampleSolrBean> values = new ArrayList<ExampleSolrBean>(10);
    for (int i = 0; i < 10; i++) {
      ExampleSolrBean toBeInserted = createExampleBeanWithId(Integer.toString(i));
      toBeInserted.setPopularity(10);
      values.add(toBeInserted);
    }
    solrTemplate.saveBeans(values);
    solrTemplate.commit();
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

    }
  }

  @Test
  public void testPartialUpdateSetWithNullAtTheEnd() {
    ExampleSolrBean toInsert = createDefaultExampleBean();
    toInsert.setPopularity(10);
    toInsert.setCategory(Arrays.asList("cat-1"));
    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    ExampleSolrBean loaded = solrTemplate.queryForObject(DEFAULT_BEAN_OBJECT_QUERY, ExampleSolrBean.class);

    Assert.assertEquals(1, loaded.getCategory().size());

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.setValueOfField("popularity", 500);
    update.setValueOfField("cat", Arrays.asList("cat-1", "cat-2", "cat-3"));
    update.setValueOfField("name", null);

    solrTemplate.saveBean(update);
    solrTemplate.commit();

    loaded = solrTemplate.queryForObject(DEFAULT_BEAN_OBJECT_QUERY, ExampleSolrBean.class);
    Assert.assertEquals(Integer.valueOf(500), loaded.getPopularity());
    Assert.assertEquals(3, loaded.getCategory().size());
    Assert.assertNull(loaded.getName());
  }
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

    Assert.assertNull(loaded.getName());
  }

  @Test
  public void testPartialUpdateSetWithNullInTheMiddle() {
    ExampleSolrBean toInsert = createDefaultExampleBean();
    toInsert.setPopularity(10);
    toInsert.setCategory(Arrays.asList("cat-1"));
    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    ExampleSolrBean loaded = solrTemplate.queryForObject(DEFAULT_BEAN_OBJECT_QUERY, ExampleSolrBean.class);

    Assert.assertEquals(1, loaded.getCategory().size());

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.setValueOfField("popularity", 500);
    update.setValueOfField("name", null);
    update.setValueOfField("cat", Arrays.asList("cat-1", "cat-2", "cat-3"));

    solrTemplate.saveBean(update);
    solrTemplate.commit();

    loaded = solrTemplate.queryForObject(DEFAULT_BEAN_OBJECT_QUERY, ExampleSolrBean.class);
    Assert.assertEquals(Integer.valueOf(500), loaded.getPopularity());
    Assert.assertNull(loaded.getName());
    Assert.assertEquals(3, loaded.getCategory().size());
  }
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

    Assert.assertEquals(3, loaded.getCategory().size());
  }

  @Test
  public void testPartialUpdateWithVersion() {
    ExampleSolrBean toInsert = createDefaultExampleBean();

    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
    update.setVersion(1L);
    update.setValueOfField("popularity", 500);

    solrTemplate.saveBean(update);
    solrTemplate.commit();

    ExampleSolrBean loaded = solrTemplate.queryForObject(DEFAULT_BEAN_OBJECT_QUERY, ExampleSolrBean.class);
    Assert.assertEquals(Integer.valueOf(500), loaded.getPopularity());
  }
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

    Assert.assertEquals(Integer.valueOf(500), loaded.getPopularity());
  }

  @Test(expected = UncategorizedSolrException.class)
  public void testPartialUpdateWithInvalidVersion() {
    ExampleSolrBean toInsert = createDefaultExampleBean();

    solrTemplate.saveBean(toInsert);
    solrTemplate.commit();

    PartialUpdate update = new PartialUpdate("id", DEFAULT_BEAN_ID);
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

    solrTemplate.ping();
  }

  @Test
  public void testRollback() {
    ExampleSolrBean toInsert = createDefaultExampleBean();
    solrTemplate.saveBean(toInsert);
    ExampleSolrBean recalled = solrTemplate.queryForObject(new SimpleQuery(new Criteria("id").is("1")),
        ExampleSolrBean.class);
    Assert.assertNull(recalled);

    solrTemplate.rollback();
    recalled = solrTemplate.queryForObject(new SimpleQuery(new Criteria("id").is("1")), ExampleSolrBean.class);
View Full Code Here

Examples of org.springframework.data.solr.ExampleSolrBean

  @Test
  public void testFacetQueryWithFacetQueries() {
    List<ExampleSolrBean> values = new ArrayList<ExampleSolrBean>();
    for (int i = 0; i < 10; i++) {
      ExampleSolrBean bean = createExampleBeanWithId(Integer.toString(i));
      bean.setInStock(i % 2 == 0);
      values.add(bean);
    }
    solrTemplate.saveBeans(values);
    solrTemplate.commit();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.