@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); }
@Override public void update() { String productIdentifier = "test-prod-7"; String indexName = "updatable"; Long pid = Long.valueOf(7); Product product = dao.read(pid); List<MetadataIndex> indexes = product.getIndexes(); product.setIdentifier(productIdentifier); for (MetadataIndex mi : indexes) { mi.setName(indexName); } dao.setIndexes(pid, indexes); dao.update(product); product = dao.read(pid); indexes = product.getIndexes(); Assert.assertNotNull(product); Assert.assertEquals(product.getIdentifier(), productIdentifier); for (MetadataIndex mi : indexes) { Assert.assertEquals(mi.getName(), indexName); } }