Search in sources :

Example 6 with KeyValueParameter

use of org.candlepin.resteasy.parameter.KeyValueParameter in project candlepin by candlepin.

the class OwnerResourceTest method testCanFilterPoolsByAttribute.

@Test
public void testCanFilterPoolsByAttribute() throws Exception {
    Principal principal = setupPrincipal(owner, Access.ALL);
    Product p = this.createProduct(owner);
    Pool pool1 = TestUtil.createPool(owner, p);
    pool1.setAttribute(Product.Attributes.VIRT_ONLY, "true");
    poolCurator.create(pool1);
    Product p2 = this.createProduct(owner);
    p2.setAttribute(Product.Attributes.CORES, "12");
    productCurator.merge(p2);
    Pool pool2 = TestUtil.createPool(owner, p2);
    poolCurator.create(pool2);
    List<KeyValueParameter> params = new ArrayList<>();
    params.add(createKeyValueParam("cores", "12"));
    List<PoolDTO> pools = ownerResource.listPools(owner.getKey(), null, null, null, null, true, null, null, params, false, false, null, null, principal, null);
    assertEquals(1, pools.size());
    assertModelEqualsDTO(pool2, pools.get(0));
    params.clear();
    params.add(createKeyValueParam("virt_only", "true"));
    pools = ownerResource.listPools(owner.getKey(), null, null, null, null, true, null, null, params, false, false, null, null, principal, null);
    assertEquals(1, pools.size());
    assertModelEqualsDTO(pool1, pools.get(0));
}
Also used : ArrayList(java.util.ArrayList) Product(org.candlepin.model.Product) KeyValueParameter(org.candlepin.resteasy.parameter.KeyValueParameter) PoolDTO(org.candlepin.dto.api.v1.PoolDTO) Pool(org.candlepin.model.Pool) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) Test(org.junit.Test)

Aggregations

KeyValueParameter (org.candlepin.resteasy.parameter.KeyValueParameter)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)3 Inject (com.google.inject.Inject)2 Transactional (com.google.inject.persist.Transactional)2 Collections (java.util.Collections)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 CollectionUtils (org.apache.commons.collections.CollectionUtils)2 ConsumerPrincipal (org.candlepin.auth.ConsumerPrincipal)2 Principal (org.candlepin.auth.Principal)2 UserPrincipal (org.candlepin.auth.UserPrincipal)2 Configuration (org.candlepin.common.config.Configuration)2 BadRequestException (org.candlepin.common.exceptions.BadRequestException)2 NotFoundException (org.candlepin.common.exceptions.NotFoundException)2 PoolDTO (org.candlepin.dto.api.v1.PoolDTO)2