use of org.candlepin.policy.js.compliance.ComplianceStatus 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.policy.js.compliance.ComplianceStatus 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.policy.js.compliance.ComplianceStatus in project candlepin by candlepin.
the class ComplianceStatusHasherTest method ensureDifferentHashWhenReasonsChange.
@Test
public void ensureDifferentHashWhenReasonsChange() {
Consumer consumer = createConsumer(owner);
ComplianceStatus testStatus = createInitialStatus(consumer);
assertEquals(initialHash, generateHash(testStatus, consumer));
ComplianceReason reason = new ComplianceReason();
reason.setKey("TEST-REASON-KEY");
reason.setMessage("This is a test!");
testStatus.getReasons().add(reason);
assertNotEquals(initialHash, generateHash(testStatus, consumer));
}
use of org.candlepin.policy.js.compliance.ComplianceStatus in project candlepin by candlepin.
the class RulesObjectMapperTest method testComplianceStatusWithSourceConsumerInEnvV2.
/*
* Tests a bug found where consumer environment content is serialized without
* an environment (as it would be a circular dep), resulting in a null environment
* on the object and a very upset hashCode method.
*/
@Test
public void testComplianceStatusWithSourceConsumerInEnvV2() {
InputStream is = this.getClass().getResourceAsStream("/json/compliancestatus-with-env-v2.json");
String json = Util.readFile(is);
// Just need this to parse without error:
ComplianceStatus cs = objMapper.toObject(json, ComplianceStatus.class);
}
use of org.candlepin.policy.js.compliance.ComplianceStatus in project candlepin by candlepin.
the class ConsumerResourceTest method testIdCertGetsRegenerated.
@Test
public void testIdCertGetsRegenerated() throws Exception {
// using lconsumer simply to avoid hiding consumer. This should
// get renamed once we refactor this test suite.
IdentityCertServiceAdapter mockIdSvc = Mockito.mock(IdentityCertServiceAdapter.class);
EventSink sink = Mockito.mock(EventSinkImpl.class);
SubscriptionServiceAdapter ssa = Mockito.mock(SubscriptionServiceAdapter.class);
ComplianceRules rules = Mockito.mock(ComplianceRules.class);
Consumer consumer = createConsumer(createOwner());
ComplianceStatus status = new ComplianceStatus();
when(rules.getStatus(any(Consumer.class), any(Date.class), anyBoolean())).thenReturn(status);
// cert expires today which will trigger regen
consumer.setIdCert(createIdCert());
BigInteger origserial = consumer.getIdCert().getSerial().getSerial();
when(mockIdSvc.regenerateIdentityCert(consumer)).thenReturn(createIdCert());
ConsumerResource cr = new ConsumerResource(mockConsumerCurator, mockConsumerTypeCurator, null, ssa, this.mockOwnerServiceAdapter, null, mockIdSvc, null, null, sink, eventFactory, null, null, null, null, null, mockOwnerCurator, null, null, rules, null, null, null, this.config, null, null, null, consumerBindUtil, null, null, this.factValidator, null, consumerEnricher, migrationProvider, translator);
ConsumerDTO c = cr.getConsumer(consumer.getUuid());
assertFalse(origserial.equals(c.getIdCert().getSerial().getSerial()));
}
Aggregations