use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ConsumerBindUtilTest method registerPassWithKeyServiceLevelNotExistOtherKeysSucceed.
@Test
public void registerPassWithKeyServiceLevelNotExistOtherKeysSucceed() throws Exception {
List<ActivationKey> keys = mockActivationKeys();
ActivationKey key1 = new ActivationKey("key1", owner);
keys.add(key1);
key1.setServiceLevel("I don't exist");
Consumer consumer = new Consumer("sys.example.com", null, null, system);
doThrow(new BadRequestException("exception")).when(serviceLevelValidator).validate(eq(owner.getId()), eq(key1.getServiceLevel()));
consumerBindUtil.handleActivationKeys(consumer, keys, false);
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ConsumerBindUtilTest method mockActivationKeys.
private List<ActivationKey> mockActivationKeys() {
ActivationKey key1 = new ActivationKey("key1", owner);
ActivationKey key2 = new ActivationKey("key2", owner);
ActivationKey key3 = new ActivationKey("key3", owner);
List<ActivationKey> keys = new LinkedList<>();
keys.add(key1);
keys.add(key2);
keys.add(key3);
return keys;
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class EventSinkImplTest method emptyKeyShouldEmitSuccessfully.
@Test
public void emptyKeyShouldEmitSuccessfully() throws Exception {
ActivationKey key = TestUtil.createActivationKey(new Owner("deadbeef"), null);
eventSinkImpl.emitActivationKeyCreated(key);
eventSinkImpl.sendEvents();
verify(mockClientProducer).send(any(ClientMessage.class));
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class PoolManagerFunctionalTest method testListAllForActKeyExcludesErrors.
@Test
public void testListAllForActKeyExcludesErrors() {
Product p = TestUtil.createProduct("test-product", "Test Product");
productCurator.create(p);
ActivationKey ak = new ActivationKey();
Pool akpool = new Pool();
akpool.setAttribute(Pool.Attributes.PHYSICAL_ONLY, "true");
ak.addPool(akpool, 1L);
Page<List<Pool>> results = poolManager.listAvailableEntitlementPools(null, ak, parentSystem.getOwnerId(), null, null, null, true, new PoolFilterBuilder(), new PageRequest(), false, false, null);
assertEquals(4, results.getPageData().size());
// Creating a pool with no entitlements available, which does not trigger
// a rules error:
Pool pool = createPool(o, p, 0L, TestUtil.createDate(2000, 3, 2), TestUtil.createDate(2050, 3, 2));
poolCurator.create(pool);
results = poolManager.listAvailableEntitlementPools(null, ak, parentSystem.getOwnerId(), null, null, null, true, new PoolFilterBuilder(), new PageRequest(), false, false, null);
// Pool in error should not be included. Should have the same number of
// initial pools.
assertEquals(5, results.getPageData().size());
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class PoolCuratorTest method testActivationKeyList.
@Test
public void testActivationKeyList() {
Date activeOn = TestUtil.createDate(2011, 2, 2);
Pool pool = TestUtil.createPool(owner, product);
pool.setEndDate(activeOn);
poolCurator.create(pool);
List<Pool> pools = new ArrayList<>();
pools.add(pool);
assertEquals(0, poolCurator.getActivationKeysForPool(pool).size());
ActivationKey ak = TestUtil.createActivationKey(owner, pools);
activationKeyCurator.create(ak);
// test the pool and its inverse
assertEquals(1, ak.getPools().size());
assertEquals(1, poolCurator.getActivationKeysForPool(pool).size());
}
Aggregations