use of org.candlepin.model.dto.PoolIdAndQuantity in project candlepin by candlepin.
the class EntitlerJob method bindByPool.
public static JobDetail bindByPool(String poolId, Consumer consumer, String ownerKey, Integer qty) {
PoolIdAndQuantity[] poolQuantities = new PoolIdAndQuantity[1];
poolQuantities[0] = new PoolIdAndQuantity(poolId, qty);
return bindByPoolAndQuantities(consumer, ownerKey, poolQuantities);
}
use of org.candlepin.model.dto.PoolIdAndQuantity in project candlepin by candlepin.
the class EntitlerJobTest method bindByPoolExec.
@Test
public void bindByPoolExec() throws JobExecutionException, EntitlementRefusedException {
String pool = "pool10";
PoolIdAndQuantity[] pQs = new PoolIdAndQuantity[1];
pQs[0] = new PoolIdAndQuantity(pool, 1);
JobDetail detail = EntitlerJob.bindByPoolAndQuantities(consumer, owner.getKey(), pQs);
JobExecutionContext ctx = mock(JobExecutionContext.class);
when(ctx.getMergedJobDataMap()).thenReturn(detail.getJobDataMap());
List<Entitlement> ents = new ArrayList<>();
Pool p = new Pool();
p.setId(pool);
Entitlement ent = new Entitlement();
ent.setPool(p);
ent.setQuantity(100);
ents.add(ent);
when(e.bindByPoolQuantities(eq(consumerUuid), anyMapOf(String.class, Integer.class))).thenReturn(ents);
EntitlerJob job = new EntitlerJob(e, null, pC, null);
injector.injectMembers(job);
job.execute(ctx);
verify(e).bindByPoolQuantities(eq(consumerUuid), anyMapOf(String.class, Integer.class));
verify(e).sendEvents(eq(ents));
ArgumentCaptor<Object> argumentCaptor = ArgumentCaptor.forClass(Object.class);
verify(ctx).setResult(argumentCaptor.capture());
List<PoolIdAndQuantity> result = (List<PoolIdAndQuantity>) argumentCaptor.getValue();
assertEquals(1, result.size());
assertEquals(pool, result.get(0).getPoolId());
assertEquals(100, result.get(0).getQuantity().intValue());
}
use of org.candlepin.model.dto.PoolIdAndQuantity in project candlepin by candlepin.
the class EntitlerJobTest method bindByPoolSetup.
@Test
public void bindByPoolSetup() {
String pool = "pool10";
PoolIdAndQuantity[] pQs = new PoolIdAndQuantity[1];
pQs[0] = new PoolIdAndQuantity(pool, 1);
JobDetail detail = EntitlerJob.bindByPoolAndQuantities(consumer, owner.getKey(), pQs);
assertNotNull(detail);
PoolIdAndQuantity[] resultPools = (PoolIdAndQuantity[]) detail.getJobDataMap().get("pool_and_quantities");
assertEquals("pool10", resultPools[0].getPoolId());
assertEquals(1, resultPools[0].getQuantity().intValue());
assertEquals(consumerUuid, detail.getJobDataMap().get(JobStatus.TARGET_ID));
assertTrue(detail.getKey().getName().startsWith("bind_by_pool_"));
}
Aggregations