use of org.candlepin.model.ConsumerCurator in project candlepin by candlepin.
the class OwnerResourceTest method testCreateUeberCertificateFromScratch.
@Test
public void testCreateUeberCertificateFromScratch() {
Principal principal = setupPrincipal(owner, Access.ALL);
Owner owner = TestUtil.createOwner();
UeberCertificate entCert = mock(UeberCertificate.class);
OwnerCurator oc = mock(OwnerCurator.class);
ProductCurator pc = mock(ProductCurator.class);
ConsumerCurator cc = mock(ConsumerCurator.class);
EntitlementCurator ec = mock(EntitlementCurator.class);
CandlepinPoolManager cpm = mock(CandlepinPoolManager.class);
EntitlementCertificateCurator ecc = mock(EntitlementCertificateCurator.class);
UeberCertificateCurator uc = mock(UeberCertificateCurator.class);
UeberCertificateGenerator ucg = mock(UeberCertificateGenerator.class);
OwnerResource resource = new OwnerResource(oc, pc, null, cc, i18n, null, null, null, null, null, cpm, null, null, null, null, null, ecc, ec, uc, ucg, null, null, null, null, null, null, null, null, null, this.modelTranslator);
when(oc.lookupByKey(eq("admin"))).thenReturn(owner);
when(ucg.generate(eq(owner.getKey()), eq(principal))).thenReturn(entCert);
UeberCertificate result = resource.createUeberCertificate(principal, owner.getKey());
assertEquals(entCert, result);
}
use of org.candlepin.model.ConsumerCurator in project candlepin by candlepin.
the class HypervisorUpdateJobTest method init.
@Before
public void init() {
super.init();
i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.READ_PROPERTIES | I18nFactory.FALLBACK);
owner = mock(Owner.class);
principal = mock(Principal.class);
ownerCurator = mock(OwnerCurator.class);
consumerCurator = mock(ConsumerCurator.class);
consumerResource = mock(ConsumerResource.class);
consumerTypeCurator = mock(ConsumerTypeCurator.class);
subAdapter = mock(SubscriptionServiceAdapter.class);
complianceRules = mock(ComplianceRules.class);
when(owner.getId()).thenReturn("joe");
ConsumerType ctype = new ConsumerType(ConsumerTypeEnum.HYPERVISOR);
ctype.setId("test-ctype");
when(consumerTypeCurator.lookupByLabel(eq(ConsumerTypeEnum.HYPERVISOR.getLabel()))).thenReturn(ctype);
when(consumerTypeCurator.lookupByLabel(eq(ConsumerTypeEnum.HYPERVISOR.getLabel()), anyBoolean())).thenReturn(ctype);
when(owner.getKey()).thenReturn("joe");
when(principal.getUsername()).thenReturn("joe user");
testMigration = new GuestMigration(consumerCurator);
migrationProvider = Providers.of(testMigration);
hypervisorJson = "{\"hypervisors\":" + "[{" + "\"name\" : \"hypervisor_999\"," + "\"hypervisorId\" : {\"hypervisorId\":\"uuid_999\"}," + "\"guestIds\" : [{\"guestId\" : \"guestId_1_999\"}]" + "}]}";
}
use of org.candlepin.model.ConsumerCurator in project candlepin by candlepin.
the class ConsumerResourceTest method unbindByInvalidSerialShouldFail.
@Test(expected = NotFoundException.class)
public void unbindByInvalidSerialShouldFail() {
Consumer consumer = createConsumer(createOwner());
ConsumerCurator consumerCurator = mock(ConsumerCurator.class);
when(consumerCurator.verifyAndLookupConsumer(eq("fake uuid"))).thenReturn(consumer);
when(mockEntitlementCurator.find(any(Serializable.class))).thenReturn(null);
ConsumerResource consumerResource = new ConsumerResource(mockConsumerCurator, mockConsumerTypeCurator, null, null, null, mockEntitlementCurator, null, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, this.config, null, null, null, consumerBindUtil, null, null, this.factValidator, null, consumerEnricher, migrationProvider, translator);
consumerResource.unbindBySerial("fake uuid", Long.valueOf(1234L));
}
use of org.candlepin.model.ConsumerCurator 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.model.ConsumerCurator 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