use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ActivationKeyResourceTest method testActivationKeyWithNullQuantity.
@Test
public void testActivationKeyWithNullQuantity() {
ActivationKey ak = genActivationKey();
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Pool p = genPool();
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", null);
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ConsumerResourceCreationTest method mockActivationKeys.
private List<String> mockActivationKeys() {
ActivationKey key1 = new ActivationKey("key1", owner);
when(activationKeyCurator.lookupForOwner("key1", owner)).thenReturn(key1);
List<String> keys = new LinkedList<>();
keys.add(key1.getName());
return keys;
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ActivationKeyRulesTest method testActivationKeyRules.
@Test
public void testActivationKeyRules() {
ActivationKey key = new ActivationKey();
key.addPool(genPool(), new Long(1));
key.addPool(genPool(), new Long(1));
Pool pool = genPool();
ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
assertTrue(result.getErrors().isEmpty());
assertTrue(result.getWarnings().isEmpty());
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ActivationKeyRulesTest method testPhysicalOnlyOnKeyWithNullInstanceBased.
/*
* Similar to above, but because quantity of the instance based
* subscription is null, it will attempt to bind the correct
* amount for physical or virtual systems.
*/
@Test
public void testPhysicalOnlyOnKeyWithNullInstanceBased() {
ActivationKey key = new ActivationKey();
key.addPool(genInstanceBased(), null);
Pool pool = genPhysOnlyPool();
// Should be a valid combination
ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
assertTrue(result.getWarnings().isEmpty());
assertTrue(result.getErrors().isEmpty());
}
use of org.candlepin.model.activationkeys.ActivationKey in project candlepin by candlepin.
the class ActivationKeyRulesTest method testActivationKeyRulesBadQuantity.
@Test
public void testActivationKeyRulesBadQuantity() {
ActivationKey key = new ActivationKey();
Pool pool = genPool();
ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(-1));
assertTrue(result.getWarnings().isEmpty());
assertEquals(1, result.getErrors().size());
String expected = "rulefailed.invalid.quantity";
assertEquals(expected, result.getErrors().get(0).getResourceKey());
}
Aggregations