@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()); }
@Override public Product getProduct(String Id) { return productRepo.findOne(Id); }