Search in sources :

Example 1 with EntitlementCurator

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

the class OwnerResourceTest method testCreateUeberCertificateFromScratch.

@Test
public void testCreateUeberCertificateFromScratch() {
    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(oc.lookupByKey(eq("admin"))).thenReturn(owner);
    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 2 with EntitlementCurator

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

the class ConsumerResourceTest method unbindByInvalidPoolIdShouldFail.

/**
 * Basic test. If invalid id is given, should throw
 * {@link NotFoundException}
 */
@Test(expected = NotFoundException.class)
public void unbindByInvalidPoolIdShouldFail() {
    Consumer consumer = createConsumer(createOwner());
    ConsumerCurator consumerCurator = mock(ConsumerCurator.class);
    when(consumerCurator.verifyAndLookupConsumer(eq("fake-uuid"))).thenReturn(consumer);
    EntitlementCurator entitlementCurator = mock(EntitlementCurator.class);
    when(mockEntitlementCurator.listByConsumerAndPoolId(eq(consumer), any(String.class))).thenReturn(new ArrayList<>());
    ConsumerResource consumerResource = new ConsumerResource(mockConsumerCurator, mockConsumerTypeCurator, null, null, null, mockEntitlementCurator, null, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, this.config, null, null, null, consumerBindUtil, null, null, this.factValidator, null, consumerEnricher, migrationProvider, translator);
    consumerResource.unbindByPool("fake-uuid", "Run Forest!");
}
Also used : EntitlementCurator(org.candlepin.model.EntitlementCurator) Consumer(org.candlepin.model.Consumer) Matchers.anyString(org.mockito.Matchers.anyString) ConsumerCurator(org.candlepin.model.ConsumerCurator) Test(org.junit.Test)

Example 3 with EntitlementCurator

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

Aggregations

ConsumerCurator (org.candlepin.model.ConsumerCurator)3 EntitlementCurator (org.candlepin.model.EntitlementCurator)3 Test (org.junit.Test)3 ConsumerPrincipal (org.candlepin.auth.ConsumerPrincipal)2 Principal (org.candlepin.auth.Principal)2 UserPrincipal (org.candlepin.auth.UserPrincipal)2 CandlepinPoolManager (org.candlepin.controller.CandlepinPoolManager)2 EntitlementCertificateCurator (org.candlepin.model.EntitlementCertificateCurator)2 Owner (org.candlepin.model.Owner)2 OwnerCurator (org.candlepin.model.OwnerCurator)2 ProductCurator (org.candlepin.model.ProductCurator)2 UeberCertificate (org.candlepin.model.UeberCertificate)2 UeberCertificateCurator (org.candlepin.model.UeberCertificateCurator)2 UeberCertificateGenerator (org.candlepin.model.UeberCertificateGenerator)2 Consumer (org.candlepin.model.Consumer)1 Matchers.anyString (org.mockito.Matchers.anyString)1