@Test
  public void testProductCRUD() {

    // create local product object
    Product product = SolrTestUtils.createProduct(PRODUCT_ID);

    // save product to Solr Index and confirm index count increased by 1
    repo.save(product);
    Assert.assertEquals(INITIAL_RECORD_COUNT + 1, repo.count());

    // find single product from Solr
    Product loaded = repo.findOne(Integer.toString(PRODUCT_ID));
    Assert.assertEquals(product.getName(), loaded.getName());

    // update product name in Solr and confirm index count not changed
    loaded.setName("changed named");
    repo.save(loaded);
    Assert.assertEquals(INITIAL_RECORD_COUNT + 1, repo.count());

    // retrieve product from Solr and confirm name change
    loaded = repo.findOne(Integer.toString(PRODUCT_ID));
    Assert.assertEquals("changed named", loaded.getName());

    // delete the test product in Solr and confirm index count equal to initial count
    repo.delete(loaded);
    Assert.assertEquals(INITIAL_RECORD_COUNT, repo.count());
  }
  @Test
  public void highlightedResultsShouldContainTermsInBold() {
    List<Product> baseList = SolrTestUtils.createProductList(10);
    repo.save(baseList);

    HighlightPage<Product> highlightProductPage =
        productService.findByHighlightedName("product", new PageRequest(0, 20));
    assertTrue(containsSnipplet(highlightProductPage, "<b>product</b>"));
  }
  @Test
  public void simpleQueryTest() {
    List<Product> baseList = SolrTestUtils.createProductList(10);
    repo.save(baseList);
    Assert.assertEquals(baseList.size(), TEST_RECORD_COUNT);
    Assert.assertEquals(INITIAL_RECORD_COUNT + TEST_RECORD_COUNT, repo.count());

    List<Product> productsByCategory = repo.findProductsBySimpleQuery("cat:test");
    Assert.assertEquals(TEST_RECORD_COUNT, productsByCategory.size());
  }
  @Test
  public void testCustomQueries() {

    // Named Query from named-queries.properties
    List<Product> products = repo.findByNameOrCategory(SOLR_STRING, sortByIdDesc());
    Assert.assertEquals(1, products.size());

    // Method Name Query test for findByPopularityGreaterThanEqual()
    Product product = SolrTestUtils.createProduct(PRODUCT_ID);
    repo.save(product);

    Page<Product> popularProducts =
        repo.findByPopularityGreaterThanEqual(10000, new PageRequest(0, 10));
    Assert.assertEquals(1, popularProducts.getTotalElements());
    Assert.assertEquals(Integer.toString(PRODUCT_ID), popularProducts.getContent().get(0).getId());
  }