use of org.candlepin.policy.js.compliance.ComplianceReason in project candlepin by candlepin.
the class ComplianceStatusHasherTest method ensureDifferentHashWhenReasonAttributeChanges.
@Test
public void ensureDifferentHashWhenReasonAttributeChanges() {
Consumer consumer = createConsumer(owner);
ComplianceStatus testStatus = createInitialStatus(consumer);
assertEquals(initialHash, generateHash(testStatus, consumer));
ComplianceReason reason = testStatus.getReasons().iterator().next();
// Test new attribute map same values
Map<String, String> newAttrs = new HashMap<>();
newAttrs.putAll(reason.getAttributes());
reason.setAttributes(newAttrs);
assertEquals(initialHash, generateHash(testStatus, consumer));
// Test new value
newAttrs.put(reason.getKey() + "-attr", reason.getKey() + "-value");
assertEquals(initialHash, generateHash(testStatus, consumer));
newAttrs.put(reason.getKey() + "-attr", "new value");
assertNotEquals(initialHash, generateHash(testStatus, consumer));
// Test new attribute.
newAttrs.put("test-key", "test-value");
assertNotEquals(initialHash, generateHash(testStatus, consumer));
// Test attribute count.
newAttrs.clear();
assertNotEquals(initialHash, generateHash(testStatus, consumer));
}
use of org.candlepin.policy.js.compliance.ComplianceReason in project candlepin by candlepin.
the class ComplianceStatusHasherTest method createReason.
private ComplianceReason createReason(String key) {
ComplianceReason reason = new ComplianceReason();
reason.setKey(key);
reason.setMessage(key + ": This is a test!");
Map<String, String> attrs = new HashMap<>();
attrs.put(key + "-attr", key + "-value");
reason.setAttributes(attrs);
return reason;
}
Aggregations