Search in sources :

Example 41 with ConsumerType

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));
}
Also used : Owner(org.candlepin.model.Owner) User(org.candlepin.model.User) OwnerDTO(org.candlepin.dto.api.v1.OwnerDTO) OwnerPermission(org.candlepin.auth.permissions.OwnerPermission) Permission(org.candlepin.auth.permissions.Permission) ConsumerType(org.candlepin.model.ConsumerType) ConsumerTypeDTO(org.candlepin.dto.api.v1.ConsumerTypeDTO) UserPrincipal(org.candlepin.auth.UserPrincipal) Before(org.junit.Before)

Example 42 with ConsumerType

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;
}
Also used : Consumer(org.candlepin.model.Consumer) GuestId(org.candlepin.model.GuestId) ConsumerType(org.candlepin.model.ConsumerType)

Example 43 with ConsumerType

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);
}
Also used : Consumer(org.candlepin.model.Consumer) ConsumerDTO(org.candlepin.dto.api.v1.ConsumerDTO) ConsumerType(org.candlepin.model.ConsumerType) Date(java.util.Date) Test(org.junit.Test)

Example 44 with ConsumerType

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());
}
Also used : Consumer(org.candlepin.model.Consumer) GuestId(org.candlepin.model.GuestId) Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) ConsumerType(org.candlepin.model.ConsumerType) Date(java.util.Date) Test(org.junit.Test)

Example 45 with ConsumerType

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());
}
Also used : Consumer(org.candlepin.model.Consumer) GuestId(org.candlepin.model.GuestId) Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) ConsumerType(org.candlepin.model.ConsumerType) Date(java.util.Date) Test(org.junit.Test)

Aggregations

ConsumerType (org.candlepin.model.ConsumerType)169 Consumer (org.candlepin.model.Consumer)92 Test (org.junit.Test)71 Owner (org.candlepin.model.Owner)53 Pool (org.candlepin.model.Pool)47 Entitlement (org.candlepin.model.Entitlement)33 ArrayList (java.util.ArrayList)29 Date (java.util.Date)27 HashMap (java.util.HashMap)24 HashSet (java.util.HashSet)24 ValidationResult (org.candlepin.policy.ValidationResult)22 ApiOperation (io.swagger.annotations.ApiOperation)21 Produces (javax.ws.rs.Produces)21 Before (org.junit.Before)20 ApiResponses (io.swagger.annotations.ApiResponses)19 Path (javax.ws.rs.Path)18 LinkedList (java.util.LinkedList)16 BadRequestException (org.candlepin.common.exceptions.BadRequestException)16 DeletedConsumer (org.candlepin.model.DeletedConsumer)16 Matchers.anyString (org.mockito.Matchers.anyString)16