use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class ConsumerResourceIntegrationTest method setUp.
@Before
public void setUp() {
standardSystemType = consumerTypeCurator.create(new ConsumerType("standard-system"));
standardSystemTypeDTO = modelTranslator.translate(standardSystemType, ConsumerTypeDTO.class);
personType = consumerTypeCurator.create(new ConsumerType(ConsumerTypeEnum.PERSON));
personTypeDTO = modelTranslator.translate(personType, ConsumerTypeDTO.class);
owner = ownerCurator.create(new Owner("test-owner"));
ownerDTO = modelTranslator.translate(owner, OwnerDTO.class);
owner.setDefaultServiceLevel(DEFAULT_SERVICE_LEVEL);
ownerCurator.create(owner);
someuser = userCurator.create(new User(USER_NAME, "dontcare"));
ownerAdminRole = createAdminRole(owner);
ownerAdminRole.addUser(someuser);
roleCurator.create(ownerAdminRole);
List<Permission> perms = permFactory.createPermissions(someuser, ownerAdminRole.getPermissions());
principal = new UserPrincipal(USER_NAME, perms, false);
setupPrincipal(principal);
consumer = TestUtil.createConsumer(standardSystemType, owner);
consumerCurator.create(consumer);
product = TestUtil.createProduct();
product.setAttribute(Product.Attributes.SUPPORT_LEVEL, DEFAULT_SERVICE_LEVEL);
productCurator.create(product);
pool = createPool(owner, product, 10L, TestDateUtil.date(2010, 1, 1), TestDateUtil.date(2020, 12, 31));
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method createConsumerWithGuests.
private Consumer createConsumerWithGuests(Owner owner, String... guestIds) {
Consumer a = new Consumer();
ConsumerType ctype = new ConsumerType(ConsumerType.ConsumerTypeEnum.HYPERVISOR);
this.mockConsumerType(ctype);
a.setType(ctype);
a.setOwner(owner);
for (String guestId : guestIds) {
a.addGuestId(new GuestId(guestId));
}
return a;
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method consumerLastCheckin.
@Test
public void consumerLastCheckin() {
ConsumerType ct = new ConsumerType(ConsumerType.ConsumerTypeEnum.CANDLEPIN);
this.mockConsumerType(ct);
Consumer c = getFakeConsumer();
Date now = new Date();
c.setLastCheckin(now);
c.setType(ct);
when(this.consumerCurator.verifyAndLookupConsumer(c.getUuid())).thenReturn(c);
ConsumerDTO updated = new ConsumerDTO();
Date then = new Date(now.getTime() + 10000L);
updated.setLastCheckin(then);
resource.updateConsumer(c.getUuid(), updated, principal);
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class CriteriaRulesTest method manifestConsumerVirtOnlyNoRequiresHost.
@Test
public void manifestConsumerVirtOnlyNoRequiresHost() {
// create a manifest consumer
ConsumerType type = new ConsumerType(ConsumerType.ConsumerTypeEnum.CANDLEPIN);
consumerTypeCurator.create(type);
Consumer c = new Consumer("test-consumer", "test-user", owner, type);
consumerCurator.create(c);
Consumer host = createConsumer(owner);
host.addGuestId(new GuestId("GUESTUUID", host));
consumerCurator.update(host);
Product targetProduct = this.createProduct(owner);
Pool virtPool = this.createPool(owner, targetProduct, 1L, new Date(), new Date());
virtPool.setAttribute(Product.Attributes.VIRT_ONLY, "true");
virtPool.setAttribute(Pool.Attributes.REQUIRES_HOST, host.getUuid());
poolCurator.merge(virtPool);
poolCurator.flush();
List<Pool> results = poolCurator.listAvailableEntitlementPools(c, (String) null, (Collection<String>) null, null);
assertEquals(0, results.size());
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class CriteriaRulesTest method manifestConsumerVirtOnly.
@Test
public void manifestConsumerVirtOnly() {
// create a manifest consumer
ConsumerType type = new ConsumerType(ConsumerType.ConsumerTypeEnum.CANDLEPIN);
consumerTypeCurator.create(type);
Consumer c = new Consumer("test-consumer", "test-user", owner, type);
consumerCurator.create(c);
Consumer host = createConsumer(owner);
host.addGuestId(new GuestId("GUESTUUID", host));
consumerCurator.update(host);
Product targetProduct = this.createProduct(owner);
Pool virtPool = this.createPool(owner, targetProduct, 1L, new Date(), new Date());
virtPool.setAttribute(Product.Attributes.VIRT_ONLY, "true");
poolCurator.merge(virtPool);
poolCurator.flush();
List<Pool> results = poolCurator.listAvailableEntitlementPools(c, (String) null, (Collection<String>) null, null);
assertEquals(1, results.size());
}
Aggregations