use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class ComplianceStatusHasherTest method ensureDifferentHashWhenConsumerEntitlementChanges.
@Test
public void ensureDifferentHashWhenConsumerEntitlementChanges() {
Consumer consumer = createConsumer(owner);
ComplianceStatus testStatus = createInitialStatus(consumer);
assertEquals(initialHash, generateHash(testStatus, consumer));
Entitlement ent = consumer.getEntitlements().iterator().next();
String id = ent.getId();
Integer quantity = ent.getQuantity();
// Check the ID
ent.setId("somethhing_differerent");
assertNotEquals(initialHash, generateHash(testStatus, consumer));
ent.setId(id);
assertEquals(initialHash, generateHash(testStatus, consumer));
// Check the quantity
ent.setQuantity(112);
assertNotEquals(initialHash, generateHash(testStatus, consumer));
ent.setQuantity(quantity);
assertEquals(initialHash, generateHash(testStatus, consumer));
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class ComplianceStatusHasherTest method ensureDifferentHashWhenPartiallyCompliantProductsChange.
@Test
public void ensureDifferentHashWhenPartiallyCompliantProductsChange() {
Consumer consumer = createConsumer(owner);
ComplianceStatus testStatus = createInitialStatus(consumer);
assertEquals(initialHash, generateHash(testStatus, consumer));
Entitlement ent = createEntitlement(Calendar.getInstance(), owner, consumer, "test-ent");
HashSet<Entitlement> ents = new HashSet<>();
ents.add(ent);
testStatus.getPartiallyCompliantProducts().put(ent.getPool().getProductId(), ents);
assertNotEquals(initialHash, generateHash(testStatus, consumer));
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class ComplianceStatusHasherTest method ensureDifferentHashWhenPartialStacksChange.
@Test
public void ensureDifferentHashWhenPartialStacksChange() {
Consumer consumer = createConsumer(owner);
ComplianceStatus testStatus = createInitialStatus(consumer);
assertEquals(initialHash, generateHash(testStatus, consumer));
Entitlement ent = createEntitlement(Calendar.getInstance(), owner, consumer, "test-ent");
HashSet<Entitlement> ents = new HashSet<>();
ents.add(ent);
testStatus.getPartialStacks().put("p-stack-2", ents);
assertNotEquals(initialHash, generateHash(testStatus, consumer));
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class ComplianceStatusHasherTest method ensureDifferentHashWhenCompliantProductCountChanges.
@Test
public void ensureDifferentHashWhenCompliantProductCountChanges() {
Consumer consumer = createConsumer(owner);
ComplianceStatus testStatus = createInitialStatus(consumer);
assertEquals(initialHash, generateHash(testStatus, consumer));
Set<Entitlement> ents = testStatus.getCompliantProducts().remove("p3");
assertFalse(testStatus.getCompliantProducts().containsKey("p3"));
assertNotEquals(initialHash, generateHash(testStatus, consumer));
testStatus.getCompliantProducts().put("p3", ents);
assertEquals(initialHash, generateHash(testStatus, consumer));
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class HostedVirtLimitEntitlementRulesTest method noBonusPoolsForHostedNonDistributorBinds.
/*
* Bonus pools should not be created when we are in a hosted scenario without
* distributor binds.
*/
@Test
public void noBonusPoolsForHostedNonDistributorBinds() {
when(config.getBoolean(ConfigProperties.STANDALONE)).thenReturn(false);
Subscription s = createVirtLimitSub("virtLimitProduct", 10, "unlimited");
Pool p = TestUtil.copyFromSub(s);
when(poolManagerMock.isManaged(eq(p))).thenReturn(true);
List<Pool> pools = poolRules.createAndEnrichPools(p, new LinkedList<>());
assertEquals(2, pools.size());
Pool physicalPool = pools.get(0);
physicalPool.setId("physical");
Pool virtBonusPool = pools.get(1);
virtBonusPool.setId("virt");
assertEquals(new Long(10), physicalPool.getQuantity());
assertEquals(0, physicalPool.getAttributes().size());
// Quantity on bonus pool should be -1:
assertEquals(new Long(-1), virtBonusPool.getQuantity());
assertEquals("true", virtBonusPool.getAttributeValue(Product.Attributes.VIRT_ONLY));
assertEquals("unlimited", virtBonusPool.getProduct().getAttributeValue(Product.Attributes.VIRT_LIMIT));
Entitlement e = new Entitlement(physicalPool, consumer, owner, 1);
Map<String, Entitlement> entitlements = new HashMap<>();
entitlements.put(physicalPool.getId(), e);
Map<String, PoolQuantity> poolQuantityMap = new HashMap<>();
poolQuantityMap.put(physicalPool.getId(), new PoolQuantity(physicalPool, 1));
enforcer.postEntitlement(poolManagerMock, consumer, owner, entitlements, null, false, poolQuantityMap);
verify(poolManagerMock, never()).createPool(any(Pool.class));
verify(poolManagerMock, never()).updatePoolQuantity(any(Pool.class), anyInt());
enforcer.postUnbind(consumer, poolManagerMock, e);
verify(poolManagerMock, never()).updatePoolQuantity(any(Pool.class), anyInt());
verify(poolManagerMock, never()).setPoolQuantity(any(Pool.class), anyLong());
}
Aggregations