Search in sources :

Example 1 with Entitler

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));
}
Also used : Owner(org.candlepin.model.Owner) Consumer(org.candlepin.model.Consumer) ConsumerInstalledProduct(org.candlepin.model.ConsumerInstalledProduct) AutobindData(org.candlepin.resource.dto.AutobindData) Matchers.anyString(org.mockito.Matchers.anyString) Entitler(org.candlepin.controller.Entitler) SubscriptionServiceAdapter(org.candlepin.service.SubscriptionServiceAdapter) ConsumerCurator(org.candlepin.model.ConsumerCurator) Date(java.util.Date) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with Entitler

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());
}
Also used : Response(javax.ws.rs.core.Response) Owner(org.candlepin.model.Owner) Consumer(org.candlepin.model.Consumer) AutobindData(org.candlepin.resource.dto.AutobindData) Matchers.anyString(org.mockito.Matchers.anyString) Entitler(org.candlepin.controller.Entitler) SubscriptionServiceAdapter(org.candlepin.service.SubscriptionServiceAdapter) ConsumerCurator(org.candlepin.model.ConsumerCurator) Test(org.junit.Test)

Aggregations

Entitler (org.candlepin.controller.Entitler)2 Consumer (org.candlepin.model.Consumer)2 ConsumerCurator (org.candlepin.model.ConsumerCurator)2 Owner (org.candlepin.model.Owner)2 AutobindData (org.candlepin.resource.dto.AutobindData)2 SubscriptionServiceAdapter (org.candlepin.service.SubscriptionServiceAdapter)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 Date (java.util.Date)1 HashSet (java.util.HashSet)1 Response (javax.ws.rs.core.Response)1 ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)1