Package org.candlepin.policy

Examples of org.candlepin.policy.ValidationResult


        ActivationKey key = new ActivationKey();
        key.addPool(genInstanceBased(), null);

        Pool pool = genPhysOnlyPool();
        // Should be a valid combination
        ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
        assertTrue(result.getWarnings().isEmpty());
        assertTrue(result.getErrors().isEmpty());
    }
View Full Code Here


    public void testAlreadyHasPhysAddingVirtQuantityInstanceBased() {
        ActivationKey key = new ActivationKey();
        key.addPool(genPhysOnlyPool(), new Long(1));

        Pool pool = genInstanceBased();
        ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
        assertTrue(result.getWarnings().isEmpty());
        assertEquals(1, result.getErrors().size());
        String expected = "rulefailed.invalid.quantity.instancebased.physical";
        assertEquals(expected, result.getErrors().get(0).getResourceKey());
        try {
            actKeyRules.validatePoolForActKey(key, pool, new Long(1));
            fail("Should have thrown an exception");
        }
        catch (BadRequestException bre) {
View Full Code Here

    public void testAllowsAddingVirtQuantityInstanceBased() {
        ActivationKey key = new ActivationKey();
        key.addPool(genPool(), new Long(1));

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

    @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";
        assertEquals(expected, result.getErrors().get(0).getResourceKey());
    }
View Full Code Here

        Pool pool = genPool();
        pool.setQuantity(5L);
        pool.setConsumed(4L);

        // Attempting to overconsume the pool
        ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(2));
        assertTrue(result.getWarnings().isEmpty());
        assertTrue(result.getErrors().isEmpty());
    }
View Full Code Here

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

        // Attempting to overconsume the pool
        ValidationResult result = actKeyRules.runPreActKey(key, instanceBased, null);
        assertTrue(result.getWarnings().isEmpty());
        assertEquals(1, result.getErrors().size());
        String expected = "rulefailed.insufficient.quantity";
        assertEquals(expected, result.getErrors().get(0).getResourceKey());
    }
View Full Code Here

        Pool pool = genPool();
        // Unlimited
        pool.setQuantity(-1L);
        pool.setConsumed(4L);

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

    @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());
        String expected = "rulefailed.actkey.cannot.use.person.pools";
        assertEquals(expected, result.getErrors().get(0).getResourceKey());
    }
View Full Code Here

        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());
        assertEquals(1, result.getErrors().size());
        String expected = "rulefailed.actkey.single.consumertype";
        assertEquals(expected, result.getErrors().get(0).getResourceKey());
    }
View Full Code Here

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

        Pool pool = genPoolForType("system");
        ValidationResult result = actKeyRules.runPreActKey(key, pool, new Long(1));
        assertTrue(result.getWarnings().isEmpty());
        assertTrue(result.getErrors().isEmpty());
    }
View Full Code Here

TOP

Related Classes of org.candlepin.policy.ValidationResult

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.