예제 #1
0
  @Override
  public void create() {
    String identifier = "test-create-product";
    String indexName = "index-name";
    String indexCategory = "category";
    String indexValue = "test";

    MetadataIndex mi = new MetadataIndex();
    mi.setName(indexName);
    mi.setCategory(indexCategory);
    mi.setQueryable(null);
    mi.setValue(indexValue);

    Product product = new Product();
    product.setIdentifier(identifier);
    product.setLocked(false);
    product.setProcessed(true);
    product.setIndexes(Arrays.asList(mi));
    try {
      product.setPath(new URL("file:/titi/tata"));
    } catch (MalformedURLException e) {
      Assert.fail(e.getMessage(), e);
    }

    Product createdProduct = dao.create(product);
    Assert.assertNotNull(createdProduct);
    Assert.assertEquals(dao.count(), (howMany() + 1));
    Assert.assertEquals(createdProduct.getUuid(), product.getUuid());

    List<MetadataIndex> indexes = createdProduct.getIndexes();
    Assert.assertEquals(indexes.size(), 1);
    Assert.assertEquals(indexes.get(0), mi);
  }
예제 #2
0
 @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
 @CacheEvict(
     value = {"indexes"},
     key = "#product_id")
 public void setIndexes(Long product_id, List<MetadataIndex> indexes) {
   Product product = productDao.read(product_id);
   product.setIndexes(indexes);
   productDao.update(product);
 }