use of org.candlepin.model.Owner in project candlepin by candlepin.
the class ProductManagerTest method testUpdateProductConvergeWithExisting.
@Test
@Parameters({ "false", "true" })
public void testUpdateProductConvergeWithExisting(boolean regenCerts) {
Owner owner1 = this.createOwner("test-owner-1", "Test Owner 1");
Owner owner2 = this.createOwner("test-owner-2", "Test Owner 2");
Product product1 = this.createProduct("p1", "prod1", owner1);
Product product2 = this.createProduct("p1", "updated product", owner2);
ProductDTO update = TestUtil.createProductDTO("p1", "updated product");
assertTrue(this.ownerProductCurator.isProductMappedToOwner(product1, owner1));
assertFalse(this.ownerProductCurator.isProductMappedToOwner(product2, owner1));
assertFalse(this.ownerProductCurator.isProductMappedToOwner(product1, owner2));
assertTrue(this.ownerProductCurator.isProductMappedToOwner(product2, owner2));
Product output = this.productManager.updateProduct(update, owner1, regenCerts);
assertEquals(output.getUuid(), product2.getUuid());
assertFalse(this.ownerProductCurator.isProductMappedToOwner(product1, owner1));
assertTrue(this.ownerProductCurator.isProductMappedToOwner(product2, owner1));
assertFalse(this.ownerProductCurator.isProductMappedToOwner(product1, owner2));
assertTrue(this.ownerProductCurator.isProductMappedToOwner(product2, owner2));
if (regenCerts) {
verify(this.mockEntCertGenerator, times(1)).regenerateCertificatesOf(eq(Arrays.asList(owner1)), anyCollectionOf(Product.class), anyBoolean());
} else {
verifyZeroInteractions(this.mockEntCertGenerator);
}
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class ProductManagerTest method testCreateProduct.
@Test
public void testCreateProduct() {
Owner owner = this.createOwner("test-owner", "Test Owner");
ProductDTO dto = TestUtil.createProductDTO("p1", "prod1");
assertNull(this.ownerProductCurator.getProductById(owner, "p1"));
Product output = this.productManager.createProduct(dto, owner);
assertEquals(output, this.ownerProductCurator.getProductById(owner, "p1"));
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class ProductManagerTest method testCreateProductThatAlreadyExists.
@Test(expected = IllegalStateException.class)
public void testCreateProductThatAlreadyExists() {
Owner owner = this.createOwner("test-owner", "Test Owner");
ProductDTO dto = TestUtil.createProductDTO("p1", "prod1");
Product output = this.productManager.createProduct(dto, owner);
assertNotNull(output);
assertEquals(output, this.ownerProductCurator.getProductById(owner, dto.getId()));
this.productManager.createProduct(dto, owner);
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class ProductManagerTest method testUpdateProduct.
@Test
@Parameters({ "false", "true" })
public void testUpdateProduct(boolean regenCerts) {
Owner owner = this.createOwner("test-owner", "Test Owner");
Product product = this.createProduct("p1", "prod1", owner);
ProductDTO update = TestUtil.createProductDTO("p1", "new product name");
Product output = this.productManager.updateProduct(update, owner, regenCerts);
assertNotEquals(output.getUuid(), product.getUuid());
assertEquals(output.getName(), update.getName());
// We expect the original to be kept around as an orphan until the orphan removal job
// gets around to removing them
assertNotNull(this.productCurator.find(product.getUuid()));
assertEquals(0, this.ownerProductCurator.getOwnerCount(product));
assertNotNull(this.ownerProductCurator.getProductById(owner, product.getId()));
if (regenCerts) {
// TODO: Is there a better way to do this? We won't know the exact product instance,
// we just know that a product should be refreshed as a result of this operation.
verify(this.mockEntCertGenerator, times(1)).regenerateCertificatesOf(eq(Arrays.asList(owner)), anyCollectionOf(Product.class), anyBoolean());
} else {
verifyZeroInteractions(this.mockEntCertGenerator);
}
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class ProductManagerTest method testUpdateProductDivergeFromExisting.
@Test
@Parameters({ "false", "true" })
public void testUpdateProductDivergeFromExisting(boolean regenCerts) {
Owner owner1 = this.createOwner("test-owner-1", "Test Owner 1");
Owner owner2 = this.createOwner("test-owner-2", "Test Owner 2");
Product product = this.createProduct("p1", "prod1", owner1, owner2);
ProductDTO update = TestUtil.createProductDTO("p1", "updated product");
assertTrue(this.ownerProductCurator.isProductMappedToOwner(product, owner1));
assertTrue(this.ownerProductCurator.isProductMappedToOwner(product, owner2));
Product output = this.productManager.updateProduct(update, owner1, regenCerts);
assertNotEquals(output.getUuid(), product.getUuid());
assertTrue(this.ownerProductCurator.isProductMappedToOwner(output, owner1));
assertFalse(this.ownerProductCurator.isProductMappedToOwner(output, owner2));
assertFalse(this.ownerProductCurator.isProductMappedToOwner(product, owner1));
assertTrue(this.ownerProductCurator.isProductMappedToOwner(product, owner2));
if (regenCerts) {
verify(this.mockEntCertGenerator, times(1)).regenerateCertificatesOf(eq(Arrays.asList(owner1)), anyCollectionOf(Product.class), anyBoolean());
} else {
verifyZeroInteractions(this.mockEntCertGenerator);
}
}
Aggregations