Package org.candlepin.model.activationkeys

Examples of org.candlepin.model.activationkeys.ActivationKey


        assertTrue(result.getErrors().isEmpty());
    }

    @Test
    public void testActivationKeyRulesBadQuantity() {
        ActivationKey key = new ActivationKey();
        Pool pool = genPool();
        ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(-1));
        assertTrue(result.getWarnings().isEmpty());
        assertEquals(1, result.getErrors().size());
        String expected = "rulefailed.invalid.quantity";
View Full Code Here


     * the number of available subscriptions shouldn't matter, only
     * the total number
     */
    @Test
    public void testActivationKeyRulesSufficientQuantity() {
        ActivationKey key = new ActivationKey();
        Pool pool = genPool();
        pool.setQuantity(5L);
        pool.setConsumed(4L);

        // Attempting to overconsume the pool
View Full Code Here

     * Because the key can only be used on physical consumers, null quantity
     * should be evaluated to two, and there are at most one available.
     */
    @Test
    public void testActivationKeyRulesinSufficientQuantity() {
        ActivationKey key = new ActivationKey();
        Pool pool = genPhysOnlyPool();
        key.addPool(pool, 1L);

        Pool instanceBased = this.genInstanceBased();
        instanceBased.setQuantity(1L);
        instanceBased.setConsumed(0L);

View Full Code Here

        assertEquals(expected, result.getErrors().get(0).getResourceKey());
    }

    @Test
    public void testActivationKeyRulesUnlimitedQuantity() {
        ActivationKey key = new ActivationKey();
        Pool pool = genPool();
        // Unlimited
        pool.setQuantity(-1L);
        pool.setConsumed(4L);
View Full Code Here

    @Test(expected = BadRequestException.class)
    public void testCreatePersonConsumerWithActivationKey() {
        Consumer c = mock(Consumer.class);
        Owner o = mock(Owner.class);
        ActivationKey ak = mock(ActivationKey.class);
        NoAuthPrincipal nap = mock(NoAuthPrincipal.class);
        ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
        OwnerCurator oc = mock(OwnerCurator.class);
        ConsumerTypeCurator ctc = mock(ConsumerTypeCurator.class);
        ConsumerContentOverrideCurator ccoc = mock(ConsumerContentOverrideCurator.class);

        ConsumerType cType = new ConsumerType(ConsumerTypeEnum.PERSON);
        when(ak.getId()).thenReturn("testKey");
        when(o.getKey()).thenReturn("testOwner");
        when(akc.lookupForOwner(eq("testKey"), eq(o))).thenReturn(ak);
        when(oc.lookupByKey(eq("testOwner"))).thenReturn(o);
        when(c.getType()).thenReturn(cType);
        when(c.getName()).thenReturn("testConsumer");
View Full Code Here

        assertTrue(result.getErrors().isEmpty());
    }

    @Test
    public void testDoesntAllowPeoplePools() {
        ActivationKey key = new ActivationKey();
        Pool pool = genPoolForType("person");

        ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
        assertTrue(result.getWarnings().isEmpty());
        assertEquals(1, result.getErrors().size());
View Full Code Here

        assertEquals(expected, result.getErrors().get(0).getResourceKey());
    }

    @Test
    public void testDoesntAllowMismatchedConsumerTypePools() {
        ActivationKey key = new ActivationKey();
        key.addPool(genPoolForType("system"), 1L);

        Pool pool = genPoolForType("hypervisor");

        ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
        assertTrue(result.getWarnings().isEmpty());
View Full Code Here

        ownerCurator.create(owner);
    }

    @Test
    public void testCreate() {
        ActivationKey key = createActivationKey(owner);
        activationKeyCurator.create(key);
        assertNotNull(key.getId());
        assertNotNull(key.getName());
        assertNotNull(key.getServiceLevel());
        assertNotNull(key.getDescription());
        assertEquals(owner, key.getOwner());
    }
View Full Code Here

        assertEquals(owner, key.getOwner());
    }

    @Test
    public void testOwnerRelationship() {
        ActivationKey key = createActivationKey(owner);
        activationKeyCurator.create(key);
        ownerCurator.refresh(owner);
        assertNotNull(owner.getActivationKeys());
        assertTrue("The count of keys should be 1", owner.getActivationKeys().size() == 1);
    }
View Full Code Here

        assertTrue("The count of keys should be 1", owner.getActivationKeys().size() == 1);
    }

    @Test
    public void testPoolRelationship() {
        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, 5L);
        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(new Long(5), key.getPools().iterator().next().getQuantity());
    }
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.