Search in sources :

Example 6 with CandlepinPoolManager

use of org.candlepin.controller.CandlepinPoolManager 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 7 with CandlepinPoolManager

use of org.candlepin.controller.CandlepinPoolManager in project candlepin by candlepin.

the class RegenEntitlementCertsJobTest method execute.

@Test
public void execute() throws Exception {
    // prep
    CandlepinPoolManager pm = mock(CandlepinPoolManager.class);
    JobExecutionContext jec = mock(JobExecutionContext.class);
    OwnerCurator oc = mock(OwnerCurator.class);
    JobDetail detail = mock(JobDetail.class);
    JobDataMap jdm = mock(JobDataMap.class);
    String ownerId = "foo_owner";
    String prodId = "bar_prod";
    boolean lazyRegen = true;
    Owner owner = new Owner(ownerId);
    CandlepinQuery cqmock = mock(CandlepinQuery.class);
    when(cqmock.list()).thenReturn(Arrays.asList(owner));
    when(oc.listAll()).thenReturn(cqmock);
    when(jdm.getString(eq(RegenProductEntitlementCertsJob.PROD_ID))).thenReturn(prodId);
    when(jdm.getBoolean(eq(RegenProductEntitlementCertsJob.LAZY_REGEN))).thenReturn(lazyRegen);
    when(detail.getJobDataMap()).thenReturn(jdm);
    when(jec.getJobDetail()).thenReturn(detail);
    // test
    RegenProductEntitlementCertsJob recj = new RegenProductEntitlementCertsJob(pm, oc);
    injector.injectMembers(recj);
    recj.execute(jec);
    // verification
    verify(pm).regenerateCertificatesOf(eq(owner), eq(prodId), eq(lazyRegen));
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) JobDetail(org.quartz.JobDetail) JobDataMap(org.quartz.JobDataMap) Owner(org.candlepin.model.Owner) JobExecutionContext(org.quartz.JobExecutionContext) CandlepinQuery(org.candlepin.model.CandlepinQuery) CandlepinPoolManager(org.candlepin.controller.CandlepinPoolManager) Test(org.junit.Test)

Aggregations

CandlepinPoolManager (org.candlepin.controller.CandlepinPoolManager)7 Test (org.junit.Test)7 Owner (org.candlepin.model.Owner)3 OwnerCurator (org.candlepin.model.OwnerCurator)3 HashMap (java.util.HashMap)2 ConsumerPrincipal (org.candlepin.auth.ConsumerPrincipal)2 Principal (org.candlepin.auth.Principal)2 UserPrincipal (org.candlepin.auth.UserPrincipal)2 Consumer (org.candlepin.model.Consumer)2 ConsumerCurator (org.candlepin.model.ConsumerCurator)2 EntitlementCertificateCurator (org.candlepin.model.EntitlementCertificateCurator)2 EntitlementCurator (org.candlepin.model.EntitlementCurator)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 IOException (java.io.IOException)1 CandlepinQuery (org.candlepin.model.CandlepinQuery)1 ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)1 Entitlement (org.candlepin.model.Entitlement)1