Package org.candlepin.model.activationkeys

Examples of org.candlepin.model.activationkeys.ActivationKey


        assertEquals(new Long(5), key.getPools().iterator().next().getQuantity());
    }

    @Test
    public void testNullPoolRelationship() {
        ActivationKey key = createActivationKey(owner);
        Product prod = TestUtil.createProduct();
        productCurator.create(prod);
        Pool pool = createPoolAndSub(owner, prod, 12L,
            new Date(), new Date(System.currentTimeMillis() + (365 * 24 * 60 * 60 * 1000)));
        key.addPool(pool, null);
        activationKeyCurator.create(key);
        activationKeyCurator.refresh(key);
        assertNotNull(poolCurator.getActivationKeysForPool(pool));
        assertNotNull(key.getPools());
        assertTrue("The count of pools should be 1", key.getPools().size() == 1);
        assertEquals(null, key.getPools().iterator().next().getQuantity());
    }
View Full Code Here


    public void setUp() {
        owner = new Owner("test-owner", "Test Owner");
        owner = ownerCurator.create(owner);
        ct = new ConsumerType(ConsumerTypeEnum.SYSTEM);
        ct = consumerTypeCurator.create(ct);
        key = new ActivationKey("a key", owner);
        activationKeyCurator.create(key);
    }
View Full Code Here

        assertEquals("remaining", remaining.get(0).getName());
    }

    @Test
    public void testRemoveByConsumer() {
        ActivationKey key2 = new ActivationKey("other key", owner);
        key2 = activationKeyCurator.create(key2);
        activationKeyContentOverrideCurator.create(new ActivationKeyContentOverride(key2,
            "test-repo", "gpgcheck", "1"));

        activationKeyContentOverrideCurator.create(new ActivationKeyContentOverride(key,
View Full Code Here

        List<Pool> pools = new ArrayList<Pool>();
        pools.add(pool);

        assertEquals(0, poolCurator.getActivationKeysForPool(pool).size());

        ActivationKey ak = TestUtil.createActivationKey(owner, pools);
        activationKeyCurator.create(ak);

        // test the pool and its inverse
        assertEquals(1, ak.getPools().size());
        assertEquals(1, poolCurator.getActivationKeysForPool(pool).size());
    }
View Full Code Here

    @Path("{activation_key_id}")
    @Produces(MediaType.APPLICATION_JSON)
    public ActivationKey getActivationKey(
        @PathParam("activation_key_id")
        @Verify(ActivationKey.class) String activationKeyId) {
        ActivationKey key = activationKeyCurator.verifyAndLookupKey(activationKeyId);

        return key;
    }
View Full Code Here

    @GET
    @Path("{activation_key_id}/pools")
    @Produces(MediaType.APPLICATION_JSON)
    public List<Pool> getActivationKeyPools(
        @PathParam("activation_key_id") String activationKeyId) {
        ActivationKey key = activationKeyCurator.verifyAndLookupKey(activationKeyId);
        List<Pool> pools = new ArrayList<Pool>();
        for (ActivationKeyPool akp : key.getPools()) {
            pools.add(akp.getPool());
        }
        return pools;
    }
View Full Code Here

    @Path("{activation_key_id}")
    @Produces(MediaType.APPLICATION_JSON)
    public ActivationKey updateActivationKey(
        @PathParam("activation_key_id") @Verify(ActivationKey.class) String activationKeyId,
        ActivationKey key) {
        ActivationKey toUpdate = activationKeyCurator.verifyAndLookupKey(activationKeyId);
        if (key.getName() != null) {
            toUpdate.setName(key.getName());
        }
        String serviceLevel = key.getServiceLevel();
        if (serviceLevel != null) {
            serviceLevelValidator.validate(toUpdate.getOwner(), serviceLevel);
            toUpdate.setServiceLevel(serviceLevel);
        }
        if (key.getReleaseVer() != null) {
            toUpdate.setReleaseVer(key.getReleaseVer());
        }
        if (key.getDescription() != null) {
            toUpdate.setDescription(key.getDescription());
        }
        if (key.isAutoAttach() != null) {
            toUpdate.setAutoAttach(key.isAutoAttach());
        }
        activationKeyCurator.merge(toUpdate);

        return toUpdate;
    }
View Full Code Here

    public ActivationKey addPoolToKey(
        @PathParam("activation_key_id") @Verify(ActivationKey.class) String activationKeyId,
        @PathParam("pool_id") @Verify(Pool.class) String poolId,
        @QueryParam("quantity") Long quantity) {

        ActivationKey key = activationKeyCurator.verifyAndLookupKey(activationKeyId);
        Pool pool = findPool(poolId);

        // Throws a BadRequestException if adding pool to key is a bad idea
        activationKeyRules.validatePoolForActKey(key, pool, quantity);
        key.addPool(pool, quantity);
        activationKeyCurator.update(key);
        return key;
    }
View Full Code Here

    @Produces(MediaType.APPLICATION_JSON)
    public ActivationKey removePoolFromKey(
        @PathParam("activation_key_id") @Verify(ActivationKey.class) String activationKeyId,
        @PathParam("pool_id")
        @Verify(Pool.class) String poolId) {
        ActivationKey key = activationKeyCurator.verifyAndLookupKey(activationKeyId);
        Pool pool = findPool(poolId);
        key.removePool(pool);
        activationKeyCurator.update(key);
        return key;
    }
View Full Code Here

    @Produces(MediaType.APPLICATION_JSON)
    public ActivationKey addProductIdToKey(
        @PathParam("activation_key_id") @Verify(ActivationKey.class) String activationKeyId,
        @PathParam("product_id") String productId) {

        ActivationKey key = activationKeyCurator.verifyAndLookupKey(activationKeyId);
        Product product = confirmProduct(productId);
        key.addProduct(product);
        activationKeyCurator.update(key);
        return key;
    }
View Full Code Here

TOP

Related Classes of org.candlepin.model.activationkeys.ActivationKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.