Search in sources :

Example 21 with OwnerCurator

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

OwnerCurator (org.candlepin.model.OwnerCurator)21 Owner (org.candlepin.model.Owner)20 Test (org.junit.Test)19 ProductCurator (org.candlepin.model.ProductCurator)9 File (java.io.File)8 ImportFile (org.candlepin.sync.Importer.ImportFile)8 Principal (org.candlepin.auth.Principal)4 Date (java.util.Date)3 ConsumerPrincipal (org.candlepin.auth.ConsumerPrincipal)3 UserPrincipal (org.candlepin.auth.UserPrincipal)3 CandlepinPoolManager (org.candlepin.controller.CandlepinPoolManager)3 ActivationKeyDTO (org.candlepin.dto.api.v1.ActivationKeyDTO)3 ConsumerCurator (org.candlepin.model.ConsumerCurator)3 ConsumerType (org.candlepin.model.ConsumerType)3 ConsumerTypeCurator (org.candlepin.model.ConsumerTypeCurator)3 Product (org.candlepin.model.Product)3 Reader (java.io.Reader)2 HashMap (java.util.HashMap)2 StandardTranslator (org.candlepin.dto.StandardTranslator)2 ConsumerDTO (org.candlepin.dto.manifest.v1.ConsumerDTO)2