@Test
  public void testSaveProduct() {
    // setup product
    Product product = new Product();
    product.setDescription("Spring Framework Guru Shirt");
    product.setPrice(new BigDecimal("18.95"));
    product.setProductId("1234");

    // save product, verify has ID value after save
    assertNull(product.getId()); // null before save
    productRepository.save(product);
    assertNotNull(product.getId()); // not null after save

    // fetch from DB
    Product fetchedProduct = productRepository.findOne(product.getId());

    // should not be null
    assertNotNull(fetchedProduct);

    // should equal
    assertEquals(product.getId(), fetchedProduct.getId());
    assertEquals(product.getDescription(), fetchedProduct.getDescription());

    // update description and save
    fetchedProduct.setDescription("New Description");
    productRepository.save(fetchedProduct);

    // get from DB, should be updated
    Product fetchedUpdatedProduct = productRepository.findOne(fetchedProduct.getId());
    assertEquals(fetchedProduct.getDescription(), fetchedUpdatedProduct.getDescription());

    // verify count of products in DB
    long productCount = productRepository.count();
    assertEquals(productCount, 1);

    // get all products, list should only have one
    Iterable<Product> products = productRepository.findAll();

    int count = 0;

    for (Product p : products) {
      count++;
    }

    assertEquals(count, 1);
  }
 private void createProductListAndOffersMap() {
   productList = new ArrayList<>();
   offersMap = new HashMap<>();
   List<Long> productsId = optimizationParams.getProductsId();
   for (Long productId : productsId) {
     Product product = productRepository.findOne(productId);
     if (product != null) {
       List<Offer> offerList = offerRepository.findByIdProduct(productId);
       if (offerList.size() > 0) {
         productList.add(product);
         offersMap.put(product, offerList);
       } else {
         missedProductList.add(new MissedProduct(product.getName()));
       }
     } else {
       missedProductList.add(new MissedProduct("Id: " + productId));
     }
   }
 }
 @Test
 public void testFindOneThatDoesNotExist() {
   Assert.assertNull(repo.findOne(POPULAR_AVAILABLE_PRODUCT.getId().concat("XX-XX-XX")));
 }
 @Test
 public void testFindOne() {
   ProductBean found = repo.findOne(POPULAR_AVAILABLE_PRODUCT.getId());
   Assert.assertEquals(POPULAR_AVAILABLE_PRODUCT.getId(), found.getId());
 }