use of org.candlepin.controller.Entitler in project candlepin by candlepin.
the class ConsumerResourceTest method futureHealing.
@Test
public void futureHealing() throws Exception {
Owner o = createOwner();
o.setId(TestUtil.randomString());
Consumer c = createConsumer(o);
SubscriptionServiceAdapter sa = mock(SubscriptionServiceAdapter.class);
Entitler e = mock(Entitler.class);
ConsumerCurator cc = mock(ConsumerCurator.class);
ConsumerInstalledProduct cip = mock(ConsumerInstalledProduct.class);
Set<ConsumerInstalledProduct> products = new HashSet<>();
products.add(cip);
when(mockOwnerCurator.findOwnerById(eq(o.getId()))).thenReturn(o);
when(cip.getProductId()).thenReturn("product-foo");
when(sa.hasUnacceptedSubscriptionTerms(eq(o))).thenReturn(false);
when(cc.verifyAndLookupConsumerWithEntitlements(eq(c.getUuid()))).thenReturn(c);
ConsumerResource cr = new ConsumerResource(cc, mockConsumerTypeCurator, null, sa, this.mockOwnerServiceAdapter, null, null, null, null, null, null, null, null, null, null, null, mockOwnerCurator, null, e, null, null, null, null, this.config, null, null, null, consumerBindUtil, null, null, this.factValidator, null, consumerEnricher, migrationProvider, translator);
String dtStr = "2011-09-26T18:10:50.184081+00:00";
Date dt = ResourceDateParser.parseDateString(dtStr);
cr.bind(c.getUuid(), null, null, null, null, null, false, dtStr, null);
AutobindData data = AutobindData.create(c, o).on(dt);
verify(e).bindByProducts(eq(data));
}
use of org.candlepin.controller.Entitler in project candlepin by candlepin.
the class ConsumerResourceTest method testProductNoPool.
@Test
public void testProductNoPool() throws Exception {
Owner o = createOwner();
o.setId(TestUtil.randomString());
Consumer c = createConsumer(o);
SubscriptionServiceAdapter sa = mock(SubscriptionServiceAdapter.class);
Entitler e = mock(Entitler.class);
ConsumerCurator cc = mock(ConsumerCurator.class);
String[] prodIds = { "notthere" };
when(sa.hasUnacceptedSubscriptionTerms(eq(o))).thenReturn(false);
when(cc.verifyAndLookupConsumerWithEntitlements(eq("fakeConsumer"))).thenReturn(c);
when(e.bindByProducts(any(AutobindData.class))).thenReturn(null);
when(mockOwnerCurator.findOwnerById(eq(o.getId()))).thenReturn(o);
ConsumerResource cr = new ConsumerResource(cc, mockConsumerTypeCurator, null, sa, this.mockOwnerServiceAdapter, null, null, null, i18n, null, null, null, null, null, null, null, mockOwnerCurator, null, e, null, null, null, null, this.config, null, null, null, consumerBindUtil, null, null, this.factValidator, null, consumerEnricher, migrationProvider, translator);
Response r = cr.bind("fakeConsumer", null, prodIds, null, null, null, false, null, null);
assertEquals(null, r.getEntity());
}
Aggregations