use of org.candlepin.model.ProductCurator in project candlepin by candlepin.
the class OwnerResourceTest method testActivationKeyTooLongRelease.
@Test(expected = BadRequestException.class)
public void testActivationKeyTooLongRelease() {
OwnerCurator oc = mock(OwnerCurator.class);
ProductCurator pc = mock(ProductCurator.class);
Owner o = new Owner();
o.setKey("owner-key");
OwnerResource ownerres = new OwnerResource(oc, pc, null, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, this.modelTranslator);
when(oc.lookupByKey(anyString())).thenReturn(o);
ActivationKeyDTO key = new ActivationKeyDTO();
key.setReleaseVersion(TestUtil.getStringOfSize(256));
key = ownerres.createActivationKey(owner.getKey(), key);
}
use of org.candlepin.model.ProductCurator in project candlepin by candlepin.
the class OwnerResourceTest method testCreateUeberCertificateRegenerate.
@Test
public void testCreateUeberCertificateRegenerate() {
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(ucg.generate(eq(owner.getKey()), eq(principal))).thenReturn(entCert);
UeberCertificate result = resource.createUeberCertificate(principal, owner.getKey());
assertEquals(entCert, result);
}
use of org.candlepin.model.ProductCurator in project candlepin by candlepin.
the class OwnerResourceTest method testConflictOnDelete.
@Test(expected = ConflictException.class)
public void testConflictOnDelete() {
Owner o = mock(Owner.class);
OwnerCurator oc = mock(OwnerCurator.class);
ProductCurator pc = mock(ProductCurator.class);
OwnerManager ownerManager = mock(OwnerManager.class);
EventFactory eventFactory = mock(EventFactory.class);
OwnerResource or = new OwnerResource(oc, pc, null, null, i18n, null, eventFactory, null, null, null, poolManager, ownerManager, null, null, null, null, null, null, null, null, null, null, contentOverrideValidator, serviceLevelValidator, null, null, null, null, null, this.modelTranslator);
when(oc.lookupByKey(eq("testOwner"))).thenReturn(o);
ConstraintViolationException ce = new ConstraintViolationException(null, null, null);
PersistenceException pe = new PersistenceException(ce);
Mockito.doThrow(pe).when(ownerManager).cleanupAndDelete(eq(o), eq(true));
or.deleteOwner("testOwner", true, true);
}
use of org.candlepin.model.ProductCurator in project candlepin by candlepin.
the class PoolHelperTest method init.
@Before
public void init() {
pm = mock(PoolManager.class);
psa = mock(ProductServiceAdapter.class);
ent = mock(Entitlement.class);
productCurator = Mockito.mock(ProductCurator.class);
Configuration config = mock(Configuration.class);
when(config.getInt(eq(ConfigProperties.PRODUCT_CACHE_MAX))).thenReturn(100);
owner = TestUtil.createOwner();
}
use of org.candlepin.model.ProductCurator in project candlepin by candlepin.
the class OwnerProductResourceTest method testDeleteProductWithSubscriptions.
@Test(expected = BadRequestException.class)
public void testDeleteProductWithSubscriptions() {
OwnerCurator oc = mock(OwnerCurator.class);
OwnerProductCurator opc = mock(OwnerProductCurator.class);
ProductCurator pc = mock(ProductCurator.class);
I18n i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
OwnerProductResource pr = new OwnerProductResource(config, i18n, oc, null, opc, null, pc, null, this.modelTranslator);
Owner o = mock(Owner.class);
Product p = mock(Product.class);
when(oc.lookupByKey(eq("owner"))).thenReturn(o);
when(opc.getProductById(eq(o), eq("10"))).thenReturn(p);
Set<Subscription> subs = new HashSet<>();
Subscription s = mock(Subscription.class);
subs.add(s);
when(pc.productHasSubscriptions(eq(o), eq(p))).thenReturn(true);
pr.deleteProduct("owner", "10");
}
Aggregations