Package org.candlepin.model.activationkeys

Examples of org.candlepin.model.activationkeys.ActivationKey


    @Path("{activation_key_id}/product/{product_id}")
    @Produces(MediaType.APPLICATION_JSON)
    public ActivationKey removeProductIdFromKey(
        @PathParam("activation_key_id") @Verify(ActivationKey.class) String activationKeyId,
        @PathParam("product_id") String productId) {
        ActivationKey key = activationKeyCurator.verifyAndLookupKey(activationKeyId);
        Product product = confirmProduct(productId);
        key.removeProduct(product);
        activationKeyCurator.update(key);
        return key;
    }
View Full Code Here


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

        log.debug("Deleting info " + activationKeyId);

        activationKeyCurator.delete(key);
    }
View Full Code Here

        assertTrue(this.poolCurator.find(pool.getId()).getConsumed() == 9);
    }

    @Test
    public void testActivationKeyCreateRead() {
        ActivationKey key = new ActivationKey();
        key.setName("dd");
        key.setReleaseVer(new Release("release1"));
        key = ownerResource.createActivationKey(owner.getKey(), key);
        assertNotNull(key.getId());
        assertEquals(key.getOwner().getId(), owner.getId());
        assertEquals(key.getReleaseVer().getReleaseVer(), "release1");
        List<ActivationKey> keys = ownerResource.ownerActivationKeys(owner.getKey());
        assertEquals(1, keys.size());
    }
View Full Code Here

        assertEquals(1, keys.size());
    }

    @Test(expected = BadRequestException.class)
    public void testActivationKeyRequiresName() {
        ActivationKey key = new ActivationKey();
        Owner owner = createOwner();
        key.setOwner(owner);
        key = ownerResource.createActivationKey(owner.getKey(), key);
    }
View Full Code Here

        key = ownerResource.createActivationKey(owner.getKey(), key);
    }

    @Test(expected = BadRequestException.class)
    public void testActivationKeyTooLongRelease() {
        ActivationKey key = new ActivationKey();
        Owner owner = createOwner();
        key.setOwner(owner);
        key.setReleaseVer(new Release(TestUtil.getStringOfSize(256)));
        key = ownerResource.createActivationKey(owner.getKey(), key);
    }
View Full Code Here

            new UserPrincipal("JarjarBinks", null, true));
    }

    @Test(expected = BadRequestException.class)
    public void testActivationKeyNameUnique() {
        ActivationKey ak = mock(ActivationKey.class);
        ActivationKey akOld = mock(ActivationKey.class);
        ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
        Owner o = mock(Owner.class);
        OwnerCurator oc = mock(OwnerCurator.class);

        when(ak.getName()).thenReturn("testKey");
View Full Code Here

            .getInstance(ActivationKeyRules.class);
    }

    @Test(expected = BadRequestException.class)
    public void testCreateReadDelete() {
        ActivationKey key = new ActivationKey();
        Owner owner = createOwner();
        key.setOwner(owner);
        key.setName("dd");
        key.setServiceLevel("level1");
        key.setReleaseVer(new Release("release1"));
        activationKeyCurator.create(key);

        assertNotNull(key.getId());
        key = activationKeyResource.getActivationKey(key.getId());
        assertNotNull(key);
        key.setName("JarJarBinks");
        key.setServiceLevel("level2");
        key.setReleaseVer(new Release("release2"));
        key = activationKeyResource.updateActivationKey(key.getId(), key);
        key = activationKeyResource.getActivationKey(key.getId());
        assertEquals("JarJarBinks", key.getName());
        assertEquals("level2", key.getServiceLevel());
        assertEquals("release2", key.getReleaseVer().getReleaseVer());
        activationKeyResource.deleteActivationKey(key.getId());
        key = activationKeyResource.getActivationKey(key.getId());
    }
View Full Code Here

        activationKeyResource.deleteActivationKey("JarJarBinks");
    }

    @Test
    public void testAddingRemovingPools() {
        ActivationKey key = new ActivationKey();
        Owner owner = createOwner();
        Product product = TestUtil.createProduct();
        productCurator.create(product);
        Pool pool = createPoolAndSub(owner, product, 10L, new Date(), new Date());
        key.setOwner(owner);
        key.setName("dd");
        key = activationKeyCurator.create(key);
        assertNotNull(key.getId());
        activationKeyResource.addPoolToKey(key.getId(), pool.getId(), 1L);
        assertTrue(key.getPools().size() == 1);
        activationKeyResource.removePoolFromKey(key.getId(), pool.getId());
        assertTrue(key.getPools().size() == 0);
    }
View Full Code Here

        assertTrue(key.getPools().size() == 0);
    }

    @Test(expected = BadRequestException.class)
    public void testActivationKeyWithNonMultiPool() {
        ActivationKey ak = genActivationKey();
        ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
        Pool p = genPool();
        p.setProductAttribute("multi-entitlement", "no", "id");
        PoolManager poolManager = mock(PoolManager.class);
View Full Code Here

        akr.addPoolToKey("testKey", "testPool", 2L);
    }

    @Test(expected = BadRequestException.class)
    public void testActivationKeyWithNegPoolQuantity() {
        ActivationKey ak = genActivationKey();
        ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
        Pool p = genPool();
        p.setQuantity(10L);
        PoolManager poolManager = mock(PoolManager.class);
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.