Search in sources :

Example 11 with ProductCurator

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

the class OwnerResourceTest method testActivationKeyTooLongRelease.

@Test(expected = BadRequestException.class)
public void testActivationKeyTooLongRelease() {
    OwnerCurator oc = mock(OwnerCurator.class);
    ProductCurator pc = mock(ProductCurator.class);
    Owner o = new Owner();
    o.setKey("owner-key");
    OwnerResource ownerres = new OwnerResource(oc, pc, null, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, this.modelTranslator);
    when(oc.lookupByKey(anyString())).thenReturn(o);
    ActivationKeyDTO key = new ActivationKeyDTO();
    key.setReleaseVersion(TestUtil.getStringOfSize(256));
    key = ownerres.createActivationKey(owner.getKey(), key);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ActivationKeyDTO(org.candlepin.dto.api.v1.ActivationKeyDTO) ProductCurator(org.candlepin.model.ProductCurator) Test(org.junit.Test)

Example 12 with ProductCurator

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

the class OwnerResourceTest method testCreateUeberCertificateRegenerate.

@Test
public void testCreateUeberCertificateRegenerate() {
    Principal principal = setupPrincipal(owner, Access.ALL);
    Owner owner = TestUtil.createOwner();
    UeberCertificate entCert = mock(UeberCertificate.class);
    OwnerCurator oc = mock(OwnerCurator.class);
    ProductCurator pc = mock(ProductCurator.class);
    ConsumerCurator cc = mock(ConsumerCurator.class);
    EntitlementCurator ec = mock(EntitlementCurator.class);
    CandlepinPoolManager cpm = mock(CandlepinPoolManager.class);
    EntitlementCertificateCurator ecc = mock(EntitlementCertificateCurator.class);
    UeberCertificateCurator uc = mock(UeberCertificateCurator.class);
    UeberCertificateGenerator ucg = mock(UeberCertificateGenerator.class);
    OwnerResource resource = new OwnerResource(oc, pc, null, cc, i18n, null, null, null, null, null, cpm, null, null, null, null, null, ecc, ec, uc, ucg, null, null, null, null, null, null, null, null, null, this.modelTranslator);
    when(ucg.generate(eq(owner.getKey()), eq(principal))).thenReturn(entCert);
    UeberCertificate result = resource.createUeberCertificate(principal, owner.getKey());
    assertEquals(entCert, result);
}
Also used : EntitlementCurator(org.candlepin.model.EntitlementCurator) OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) UeberCertificate(org.candlepin.model.UeberCertificate) ProductCurator(org.candlepin.model.ProductCurator) UeberCertificateCurator(org.candlepin.model.UeberCertificateCurator) EntitlementCertificateCurator(org.candlepin.model.EntitlementCertificateCurator) UeberCertificateGenerator(org.candlepin.model.UeberCertificateGenerator) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) ConsumerCurator(org.candlepin.model.ConsumerCurator) CandlepinPoolManager(org.candlepin.controller.CandlepinPoolManager) Test(org.junit.Test)

Example 13 with ProductCurator

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

the class OwnerResourceTest method testConflictOnDelete.

@Test(expected = ConflictException.class)
public void testConflictOnDelete() {
    Owner o = mock(Owner.class);
    OwnerCurator oc = mock(OwnerCurator.class);
    ProductCurator pc = mock(ProductCurator.class);
    OwnerManager ownerManager = mock(OwnerManager.class);
    EventFactory eventFactory = mock(EventFactory.class);
    OwnerResource or = new OwnerResource(oc, pc, null, null, i18n, null, eventFactory, null, null, null, poolManager, ownerManager, null, null, null, null, null, null, null, null, null, null, contentOverrideValidator, serviceLevelValidator, null, null, null, null, null, this.modelTranslator);
    when(oc.lookupByKey(eq("testOwner"))).thenReturn(o);
    ConstraintViolationException ce = new ConstraintViolationException(null, null, null);
    PersistenceException pe = new PersistenceException(ce);
    Mockito.doThrow(pe).when(ownerManager).cleanupAndDelete(eq(o), eq(true));
    or.deleteOwner("testOwner", true, true);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ProductCurator(org.candlepin.model.ProductCurator) PersistenceException(javax.persistence.PersistenceException) EventFactory(org.candlepin.audit.EventFactory) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) OwnerManager(org.candlepin.controller.OwnerManager) Test(org.junit.Test)

Example 14 with ProductCurator

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

the class PoolHelperTest method init.

@Before
public void init() {
    pm = mock(PoolManager.class);
    psa = mock(ProductServiceAdapter.class);
    ent = mock(Entitlement.class);
    productCurator = Mockito.mock(ProductCurator.class);
    Configuration config = mock(Configuration.class);
    when(config.getInt(eq(ConfigProperties.PRODUCT_CACHE_MAX))).thenReturn(100);
    owner = TestUtil.createOwner();
}
Also used : Configuration(org.candlepin.common.config.Configuration) ProductCurator(org.candlepin.model.ProductCurator) Entitlement(org.candlepin.model.Entitlement) PoolManager(org.candlepin.controller.PoolManager) ProductServiceAdapter(org.candlepin.service.ProductServiceAdapter) Before(org.junit.Before)

Example 15 with ProductCurator

use of org.candlepin.model.ProductCurator 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

ProductCurator (org.candlepin.model.ProductCurator)15 Owner (org.candlepin.model.Owner)10 OwnerCurator (org.candlepin.model.OwnerCurator)10 Test (org.junit.Test)10 Before (org.junit.Before)4 ConsumerPrincipal (org.candlepin.auth.ConsumerPrincipal)3 Principal (org.candlepin.auth.Principal)3 UserPrincipal (org.candlepin.auth.UserPrincipal)3 ActivationKeyDTO (org.candlepin.dto.api.v1.ActivationKeyDTO)3 ProductCachedSerializationModule (org.candlepin.jackson.ProductCachedSerializationModule)3 HashSet (java.util.HashSet)2 CandlepinPoolManager (org.candlepin.controller.CandlepinPoolManager)2 PoolManager (org.candlepin.controller.PoolManager)2 ConsumerCurator (org.candlepin.model.ConsumerCurator)2 EntitlementCertificateCurator (org.candlepin.model.EntitlementCertificateCurator)2 EntitlementCurator (org.candlepin.model.EntitlementCurator)2 Product (org.candlepin.model.Product)2 UeberCertificate (org.candlepin.model.UeberCertificate)2 UeberCertificateCurator (org.candlepin.model.UeberCertificateCurator)2 UeberCertificateGenerator (org.candlepin.model.UeberCertificateGenerator)2