Package org.springframework.data.solr.repository

Examples of org.springframework.data.solr.repository.ProductBean


  @Test
  public void testCdiRepository() {
    Assert.assertNotNull(repository);

    ProductBean bean = new ProductBean();
    bean.setId("id-1");
    bean.setName("cidContainerTest-1");

    repository.save(bean);

    Assert.assertTrue(repository.exists(bean.getId()));

    ProductBean retrieved = repository.findOne(bean.getId());
    Assert.assertNotNull(retrieved);
    Assert.assertEquals(bean.getId(), retrieved.getId());
    Assert.assertEquals(bean.getName(), retrieved.getName());

    Assert.assertEquals(1, repository.count());

    Assert.assertTrue(repository.exists(bean.getId()));
View Full Code Here


    Assert.assertNotNull(repository);
  }

  @Test
  public void testCRUDOperations() throws InterruptedException {
    ProductBean initial = createProductBean("1");

    ProductBeanRepository repository = factory.getRepository(ProductBeanRepository.class);
    Assert.assertEquals(0, repository.count());

    repository.save(initial);
    Assert.assertEquals(1, repository.count());

    ProductBean loaded = repository.findOne(initial.getId());
    Assert.assertEquals(initial.getName(), loaded.getName());

    loaded.setName("name changed");
    repository.save(loaded);
    Assert.assertEquals(1, repository.count());

    loaded = repository.findOne(initial.getId());
    Assert.assertEquals("name changed", loaded.getName());

    repository.delete(loaded);

    Thread.sleep(100);
    Assert.assertEquals(0, repository.count());
View Full Code Here

    Assert.assertEquals(0, repository.count());
  }

  @Test
  public void testAnnotatedQuery() {
    ProductBean initial = createProductBean("1");

    ProductBeanRepository repository = factory.getRepository(ProductBeanRepository.class);
    repository.save(initial);

    Page<ProductBean> result = repository.findByAnnotatedQuery("na", new PageRequest(0, 5));
View Full Code Here

    Assert.assertEquals(1, result.getContent().size());
  }

  @Test
  public void testScoredAnnotatedQuery() {
    ProductBean initial = createProductBean("1");

    ProductBeanRepository repository = factory.getRepository(ProductBeanRepository.class);
    repository.save(initial);

    ScoredPage<ProductBean> result = repository.findByAnnotatedQuery1("na", new PageRequest(0, 5));
View Full Code Here

    Assert.assertEquals(Float.valueOf(1), result.getMaxScore());
  }

  @Test
  public void testPartTreeQuery() {
    ProductBean availableProduct = createProductBean("1");
    ProductBean unavailableProduct = createProductBean("2");
    unavailableProduct.setAvailable(false);

    ProductBeanRepository repository = factory.getRepository(ProductBeanRepository.class);

    repository.save(Arrays.asList(availableProduct, unavailableProduct));
    Assert.assertEquals(2, repository.count());
View Full Code Here

    Assert.assertEquals(availableProduct.getId(), result.getContent().get(0).getId());
  }

  @Test
  public void testCollectionResultQuery() {
    ProductBean availableProduct = createProductBean("1");
    ProductBean unavailableProduct = createProductBean("2");
    unavailableProduct.setAvailable(false);

    ProductBeanRepository repository = factory.getRepository(ProductBeanRepository.class);

    repository.save(Arrays.asList(availableProduct, unavailableProduct));
    Assert.assertEquals(2, repository.count());
View Full Code Here

    Assert.assertEquals(availableProduct.getId(), result.get(0).getId());
  }

  @Test
  public void testSingleResultQuery() {
    ProductBean initial = createProductBean("1");

    ProductBeanRepository repository = factory.getRepository(ProductBeanRepository.class);
    repository.save(initial);

    ProductBean result = repository.findSingleElement(initial.getId());

    Assert.assertEquals(initial.getId(), result.getId());
    Assert.assertEquals(initial.getName(), result.getName());
  }
View Full Code Here

    Assert.assertEquals(initial.getId(), result.getId());
    Assert.assertEquals(initial.getName(), result.getName());
  }

  private ProductBean createProductBean(String id) {
    ProductBean initial = new ProductBean();
    initial.setId(id);
    initial.setAvailable(true);
    initial.setName("name-" + id);
    return initial;
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.solr.repository.ProductBean

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.