use of org.candlepin.policy.js.compliance.ComplianceStatus in project candlepin by candlepin.
the class ComplianceStatusHasherTest method ensureDifferentHashWhenReasonKeyChange.
@Test
public void ensureDifferentHashWhenReasonKeyChange() {
Consumer consumer = createConsumer(owner);
ComplianceStatus testStatus = createInitialStatus(consumer);
assertEquals(initialHash, generateHash(testStatus, consumer));
ComplianceReason reason = testStatus.getReasons().iterator().next();
reason.setKey("FOOF");
assertNotEquals(initialHash, generateHash(testStatus, consumer));
}
use of org.candlepin.policy.js.compliance.ComplianceStatus in project candlepin by candlepin.
the class ComplianceStatusHasherTest method createInitialStatus.
private ComplianceStatus createInitialStatus(Consumer consumer) {
// Need to make sure that dates are exactly the same
// as this method will be called more than once.
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 2001);
cal.set(Calendar.MONTH, 4);
cal.set(Calendar.DATE, 12);
cal.set(Calendar.HOUR, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
ComplianceStatus initialStatus = new ComplianceStatus(cal.getTime());
addMonths(cal, 4);
initialStatus.addNonCompliantProduct("p1");
initialStatus.addNonCompliantProduct("p2");
initialStatus.addCompliantProduct("p3", createEntitlement(cal, owner, consumer, "p3"));
initialStatus.addCompliantProduct("p4", createEntitlement(cal, owner, consumer, "p4"));
initialStatus.addPartiallyCompliantProduct("p5", createEntitlement(cal, owner, consumer, "p5"));
initialStatus.addPartialStack("p-stack", createEntitlement(cal, owner, consumer, "p6"));
ComplianceReason reason1 = createReason("TEST-REASON-1");
initialStatus.getReasons().add(reason1);
ComplianceReason reason2 = createReason("TEST-REASON-2");
initialStatus.getReasons().add(reason2);
return initialStatus;
}
use of org.candlepin.policy.js.compliance.ComplianceStatus 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.policy.js.compliance.ComplianceStatus in project candlepin by candlepin.
the class ComplianceStatusHasherTest method ensureDifferentHashWhenNonCompliantProductsChange.
@Test
public void ensureDifferentHashWhenNonCompliantProductsChange() {
Consumer consumer = createConsumer(owner);
ComplianceStatus testStatus = createInitialStatus(consumer);
assertEquals(initialHash, generateHash(testStatus, consumer));
testStatus.getNonCompliantProducts().clear();
assertNotEquals(initialHash, generateHash(testStatus, consumer));
testStatus.addNonCompliantProduct("p1");
testStatus.addNonCompliantProduct("p2");
assertEquals(initialHash, generateHash(testStatus, consumer));
assertTrue(testStatus.getNonCompliantProducts().remove("p1"));
assertNotEquals(initialHash, generateHash(testStatus, consumer));
}
use of org.candlepin.policy.js.compliance.ComplianceStatus 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));
}
Aggregations