use of org.candlepin.model.activationkeys.ActivationKeyCurator in project candlepin by candlepin.
the class OwnerResourceTest method testActivationKeyNameUnique.
@Test(expected = BadRequestException.class)
public void testActivationKeyNameUnique() {
ActivationKeyDTO ak = mock(ActivationKeyDTO.class);
ActivationKey akOld = mock(ActivationKey.class);
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Owner o = mock(Owner.class);
OwnerCurator oc = mock(OwnerCurator.class);
ProductCurator pc = mock(ProductCurator.class);
when(ak.getName()).thenReturn("testKey");
when(akc.lookupForOwner(eq("testKey"), eq(o))).thenReturn(akOld);
when(oc.lookupByKey(eq("testOwner"))).thenReturn(o);
OwnerResource ownerres = new OwnerResource(oc, pc, akc, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, contentOverrideValidator, null, null, null, null, null, null, this.modelTranslator);
ownerres.createActivationKey("testOwner", ak);
}
use of org.candlepin.model.activationkeys.ActivationKeyCurator in project candlepin by candlepin.
the class ConsumerResourceTest method testCreatePersonConsumerWithActivationKey.
@Test(expected = BadRequestException.class)
public void testCreatePersonConsumerWithActivationKey() {
ConsumerType ctype = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.PERSON));
ConsumerTypeDTO ctypeDto = this.translator.translate(ctype, ConsumerTypeDTO.class);
Owner owner = this.createOwner();
Consumer consumer = this.createConsumer(owner, ctype);
ConsumerDTO consumerDto = this.translator.translate(consumer, ConsumerDTO.class);
ActivationKey ak = mock(ActivationKey.class);
NoAuthPrincipal nap = mock(NoAuthPrincipal.class);
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
ConsumerContentOverrideCurator ccoc = mock(ConsumerContentOverrideCurator.class);
when(ak.getId()).thenReturn("testKey");
when(akc.lookupForOwner(eq(owner.getKey()), eq(owner))).thenReturn(ak);
ConsumerResource cr = new ConsumerResource(null, mockConsumerTypeCurator, null, null, null, null, null, null, i18n, null, null, null, null, null, null, null, mockOwnerCurator, akc, null, null, null, null, null, this.config, null, null, null, consumerBindUtil, null, null, this.factValidator, null, consumerEnricher, migrationProvider, translator);
cr.create(consumerDto, nap, null, owner.getKey(), "testKey", true);
}
use of org.candlepin.model.activationkeys.ActivationKeyCurator in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithDiffHostReqPools.
@Test
public void testActivationKeyWithDiffHostReqPools() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
PoolManager poolManager = mock(PoolManager.class);
Pool p1 = genPool();
p1.setAttribute(Pool.Attributes.REQUIRES_HOST, "host1");
Pool p2 = genPool();
p2.setAttribute(Pool.Attributes.REQUIRES_HOST, "host2");
ak.addPool(p2, 1L);
when(akc.verifyAndLookupKey(eq("testKey"))).thenReturn(ak);
when(poolManager.find(eq("testPool1"))).thenReturn(p1);
ActivationKeyResource akr = new ActivationKeyResource(akc, i18n, poolManager, serviceLevelValidator, activationKeyRules, null, new ProductCachedSerializationModule(productCurator), this.modelTranslator);
akr.addPoolToKey("testKey", "testPool1", 1L);
}
use of org.candlepin.model.activationkeys.ActivationKeyCurator in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithNegPoolQuantity.
@Test(expected = BadRequestException.class)
public void testActivationKeyWithNegPoolQuantity() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Pool p = genPool();
p.setQuantity(10L);
PoolManager poolManager = mock(PoolManager.class);
when(akc.verifyAndLookupKey(eq("testKey"))).thenReturn(ak);
when(poolManager.find(eq("testPool"))).thenReturn(p);
ActivationKeyResource akr = new ActivationKeyResource(akc, i18n, poolManager, serviceLevelValidator, activationKeyRules, null, new ProductCachedSerializationModule(productCurator), this.modelTranslator);
akr.addPoolToKey("testKey", "testPool", -3L);
}
use of org.candlepin.model.activationkeys.ActivationKeyCurator in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithNonPersonConsumerType.
@Test
public void testActivationKeyWithNonPersonConsumerType() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Pool p = genPool();
p.getProduct().setAttribute(Pool.Attributes.REQUIRES_CONSUMER_TYPE, "candlepin");
PoolManager poolManager = mock(PoolManager.class);
when(akc.verifyAndLookupKey(eq("testKey"))).thenReturn(ak);
when(poolManager.find(eq("testPool"))).thenReturn(p);
ActivationKeyResource akr = new ActivationKeyResource(akc, i18n, poolManager, serviceLevelValidator, activationKeyRules, null, new ProductCachedSerializationModule(productCurator), this.modelTranslator);
assertNotNull(akr.addPoolToKey("testKey", "testPool", 1L));
}
Aggregations