Package org.candlepin.policy

Examples of org.candlepin.policy.ValidationResult


    @Test
    public void physOnlyVirtualConsumer() {
        Pool pool = setupPhysOnlyPool();
        consumer.setFact("virt.is_guest", "true");

        ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
        assertTrue(result.hasWarnings());
        assertEquals(1, result.getWarnings().size());
        assertEquals("rulewarning.physical.only",
            result.getWarnings().get(0).getResourceKey());
    }
View Full Code Here


    @Test
    public void hypervisorForSystemNotGenerateError() {
        Pool pool = setupProductWithConsumerTypeAttribute(ConsumerTypeEnum.SYSTEM);
        consumer.setType(new ConsumerType(ConsumerTypeEnum.HYPERVISOR));

        ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
        assertFalse(result.hasErrors());
        assertFalse(result.hasWarnings());
    }
View Full Code Here

    @Test
    public void systemForHypervisorGeneratesError() {
        Pool pool = setupProductWithConsumerTypeAttribute(ConsumerTypeEnum.HYPERVISOR);
        consumer.setType(new ConsumerType(ConsumerTypeEnum.SYSTEM));

        ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
        assertTrue(result.hasErrors());
        assertFalse(result.hasWarnings());
    }
View Full Code Here

        Entitlement e = new Entitlement(pool, consumer, 1);
        consumer.addEntitlement(e);

        when(this.prodAdapter.getProductById(productId)).thenReturn(product);

        ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);

        assertTrue(result.hasErrors());
        assertFalse(result.isSuccessful());
    }
View Full Code Here

        consumer.setFact("cpu.cpu_socket(s)", "1");
        consumer.setFact("cpu.core(s)_per_socket", "10");

        when(this.prodAdapter.getProductById(productId)).thenReturn(product);

        ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);

        assertFalse(result.hasErrors());
        assertFalse(result.hasWarnings());
        assertTrue(result.isSuccessful());
    }
View Full Code Here

        consumer.setFact("cpu.cpu_socket(s)", "2");
        consumer.setFact("cpu.core(s)_per_socket", "10");

        when(this.prodAdapter.getProductById(productId)).thenReturn(product);

        ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);

        assertFalse(result.hasErrors());
        assertTrue(result.hasWarnings());
        assertTrue(result.isSuccessful());
        assertEquals("rulewarning.unsupported.number.of.cores",
            result.getWarnings().get(0).getResourceKey());
    }
View Full Code Here

        consumer.setFacts(new HashMap<String, String>());
        consumer.setFact("memory.memtotal", "16777216");

        when(this.prodAdapter.getProductById(productId)).thenReturn(product);

        ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);

        assertFalse(result.hasErrors());
        assertFalse(result.hasWarnings());
        assertTrue(result.isSuccessful());
    }
View Full Code Here

        consumer.setFacts(new HashMap<String, String>());
        consumer.setFact("memory.memtotal", "16777216");

        when(this.prodAdapter.getProductById(productId)).thenReturn(product);

        ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);

        assertFalse(result.hasErrors());
        assertTrue(result.hasWarnings());
        assertTrue(result.isSuccessful());
        assertEquals("rulewarning.unsupported.ram",
            result.getWarnings().get(0).getResourceKey());
    }
View Full Code Here

        consumer.setFacts(new HashMap<String, String>());
        consumer.setFact("cpu.cpu_socket(s)", "1");

        when(this.prodAdapter.getProductById(productId)).thenReturn(product);

        ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);

        assertFalse(result.hasErrors());
        assertFalse(result.hasWarnings());
        assertTrue(result.isSuccessful());
    }
View Full Code Here

        consumer.setFacts(new HashMap<String, String>());
        consumer.setFact("cpu.cpu_socket(s)", "4");

        when(this.prodAdapter.getProductById(productId)).thenReturn(product);

        ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);

        assertFalse(result.hasErrors());
        assertTrue(result.hasWarnings());
        assertTrue(result.isSuccessful());
        assertEquals("rulewarning.unsupported.number.of.sockets",
            result.getWarnings().get(0).getResourceKey());
    }
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.