Search in sources :

Example 1 with OwnerProductCurator

use of org.candlepin.model.OwnerProductCurator in project candlepin by candlepin.

the class OwnerProductResourceTest method testDeleteProductWithSubscriptions.

@Test(expected = BadRequestException.class)
public void testDeleteProductWithSubscriptions() {
    OwnerCurator oc = mock(OwnerCurator.class);
    OwnerProductCurator opc = mock(OwnerProductCurator.class);
    ProductCurator pc = mock(ProductCurator.class);
    I18n i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    OwnerProductResource pr = new OwnerProductResource(config, i18n, oc, null, opc, null, pc, null, this.modelTranslator);
    Owner o = mock(Owner.class);
    Product p = mock(Product.class);
    when(oc.lookupByKey(eq("owner"))).thenReturn(o);
    when(opc.getProductById(eq(o), eq("10"))).thenReturn(p);
    Set<Subscription> subs = new HashSet<>();
    Subscription s = mock(Subscription.class);
    subs.add(s);
    when(pc.productHasSubscriptions(eq(o), eq(p))).thenReturn(true);
    pr.deleteProduct("owner", "10");
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) OwnerProductCurator(org.candlepin.model.OwnerProductCurator) ProductCurator(org.candlepin.model.ProductCurator) Product(org.candlepin.model.Product) Subscription(org.candlepin.model.dto.Subscription) OwnerProductCurator(org.candlepin.model.OwnerProductCurator) I18n(org.xnap.commons.i18n.I18n) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

HashSet (java.util.HashSet)1 Owner (org.candlepin.model.Owner)1 OwnerCurator (org.candlepin.model.OwnerCurator)1 OwnerProductCurator (org.candlepin.model.OwnerProductCurator)1 Product (org.candlepin.model.Product)1 ProductCurator (org.candlepin.model.ProductCurator)1 Subscription (org.candlepin.model.dto.Subscription)1 Test (org.junit.Test)1 I18n (org.xnap.commons.i18n.I18n)1