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));
}
Aggregations