use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class PreEntitlementRulesTest method unmappedGuestFuturePoolDate.
@Test
public void unmappedGuestFuturePoolDate() {
ConsumerType ctype = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.SYSTEM));
Date fourHoursFromNow = new Date(new Date().getTime() + 4L * 60L * 60L * 1000L);
Pool pool = setupUnmappedGuestPool();
pool.setStartDate(fourHoursFromNow);
Consumer consumer = new Consumer("test newborn consumer", "test user", owner, ctype);
consumer.setFact("virt.is_guest", "true");
consumer.setCreated(new Date());
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1, CallerType.BIND);
assertTrue(result.hasErrors());
assertEquals(1, result.getErrors().size());
assertEquals("virt.guest.cannot.bind.future.unmapped.guest.pool", result.getErrors().get(0).getResourceKey());
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class PreEntitlementRulesTest method unmappedGuestGoodDate.
@Test
public void unmappedGuestGoodDate() {
ConsumerType ctype = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.SYSTEM));
Pool pool = setupUnmappedGuestPool();
Consumer newborn = new Consumer("test newborn consumer", "test user", owner, ctype);
newborn.setFact("virt.is_guest", "true");
newborn.setCreated(new Date());
ValidationResult result = enforcer.preEntitlement(newborn, pool, 1);
assertFalse(result.hasErrors());
assertFalse(result.hasWarnings());
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class PreEntitlementRulesTest method devPoolConsumerDoesNotMatch.
@Test
public void devPoolConsumerDoesNotMatch() {
// Another consumer we'll make a dev pool for:
ConsumerType ctype = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.SYSTEM));
Consumer otherConsumer = new Consumer("test consumer", "test user", owner, ctype);
Pool pool = setupDevConsumerRestrictedPool(otherConsumer);
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertFalse(result.hasWarnings());
assertEquals(1, result.getErrors().size());
assertEquals("consumer.does.not.match.pool.consumer.requirement", result.getErrors().get(0).getResourceKey());
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class PreEntitlementRulesTest method mismatchingConsumerTypeShouldGenerateError.
@Test
public void mismatchingConsumerTypeShouldGenerateError() {
ConsumerType ctype = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.PERSON));
Pool pool = setupProductWithConsumerTypeAttribute(ConsumerTypeEnum.DOMAIN);
consumer.setType(ctype);
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertTrue(result.hasErrors());
assertFalse(result.hasWarnings());
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class PreEntitlementRulesTest method unmappedGuestBadDate.
@Test
public void unmappedGuestBadDate() {
ConsumerType ctype = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.SYSTEM));
Pool pool = setupUnmappedGuestPool();
Consumer tooOld = new Consumer("test newborn consumer", "test user", owner, ctype);
tooOld.setFact("virt.is_guest", "true");
Date twentyFiveHoursAgo = new Date(new Date().getTime() - 25L * 60L * 60L * 1000L);
tooOld.setCreated(twentyFiveHoursAgo);
ValidationResult result = enforcer.preEntitlement(tooOld, pool, 1);
assertTrue(result.hasErrors());
assertEquals(1, result.getErrors().size());
assertEquals("virt.guest.cannot.use.unmapped.guest.pool.not.new", result.getErrors().get(0).getResourceKey());
}
Aggregations