Package org.candlepin.model

Examples of org.candlepin.model.Consumer


    }

    @Test
    public void preEntitlementNoInstanceCapableListWarn() {
        // Test with sockets to make sure that they are skipped.
        Consumer c = TestUtil.createConsumer();
        Set<ConsumerCapability> caps = new HashSet<ConsumerCapability>();
        c.setCapabilities(caps);
        c.getType().setManifest(true);

        Product prod = TestUtil.createProduct();
        prod.setAttribute("instance_multiplier", "2");
        Pool p = TestUtil.createPool(prod);
View Full Code Here


    }

    @Test
    public void cannotExportProduct() throws NoSuchMethodException {
        Entitlement entitlement = mock(Entitlement.class);
        Consumer consumer = mock(Consumer.class);
        ConsumerType type = mock(ConsumerType.class);
        Pool pool = new Pool();
        pool.setProductId("12345");
        pool.setAttribute("pool_derived", "true");

        when(entitlement.getPool()).thenReturn(pool);
        when(entitlement.getConsumer()).thenReturn(consumer);
        when(consumer.getType()).thenReturn(type);
        when(type.isManifest()).thenReturn(true);

        assertFalse(exportRules.canExport(entitlement));
    }
View Full Code Here

        assertEquals(range2.getEndDate(), validRange.getEndDate());
    }

    @Test
    public void validRangeWithMultipleWhereExpiredEntitlementOverlaps() {
        Consumer c = mockConsumer(PRODUCT_1);

        Calendar cal = Calendar.getInstance();
        Date now = cal.getTime();
        DateRange range1 = rangeRelativeToDate(now, -4, 2);
        DateRange range2 = rangeRelativeToDate(now, -7, -3);

        c.addEntitlement(mockEntitlement(c, PRODUCT_1, range2, PRODUCT_1));
        c.addEntitlement(mockEntitlement(c, PRODUCT_1, range1, PRODUCT_1));

        List<Entitlement> ents = new LinkedList<Entitlement>(c.getEntitlements());
        mockEntCurator(c, ents);

        ComplianceStatus status = compliance.getStatus(c, now);
        ConsumerInstalledProductEnricher calculator =
            new ConsumerInstalledProductEnricher(c, status, compliance);
View Full Code Here

    }

    @Test
    public void canExportProductConsumer() throws NoSuchMethodException {
        Entitlement entitlement = mock(Entitlement.class);
        Consumer consumer = mock(Consumer.class);
        ConsumerType consumerType = mock(ConsumerType.class);
        Pool pool = mock(Pool.class);
        Product product = mock(Product.class);
        Set<PoolAttribute> attributes = new HashSet<PoolAttribute>();
        attributes.add(new PoolAttribute("pool_derived", "true"));


        when(entitlement.getPool()).thenReturn(pool);
        when(entitlement.getConsumer()).thenReturn(consumer);
        when(pool.getProductId()).thenReturn("12345");
        when(product.getAttributes()).thenReturn(new HashSet<ProductAttribute>());
        when(pool.getAttributes()).thenReturn(attributes);
        when(consumer.getType()).thenReturn(consumerType);
        when(consumerType.getLabel()).thenReturn("system");

        assertTrue(exportRules.canExport(entitlement));
    }
View Full Code Here

    }

    @Test
    public void preEntitlementSuccessInstanceCapable() {
        // Test with sockets to make sure that they are skipped.
        Consumer c = TestUtil.createConsumer();
        Set<ConsumerCapability> caps = new HashSet<ConsumerCapability>();
        ConsumerCapability cc = new ConsumerCapability(c, "instance_multiplier");
        caps.add(cc);
        c.setCapabilities(caps);
        c.getType().setManifest(true);

        Product prod = TestUtil.createProduct();
        prod.setAttribute("instance_multiplier", "2");
        Pool p = TestUtil.createPool(prod);
View Full Code Here

    }

    @Test
    public void canExportProductVirt() throws NoSuchMethodException {
        Entitlement entitlement = mock(Entitlement.class);
        Consumer consumer = mock(Consumer.class);
        ConsumerType consumerType = mock(ConsumerType.class);
        Pool pool = mock(Pool.class);
        Product product = mock(Product.class);
        Set<PoolAttribute> attributes = new HashSet<PoolAttribute>();

        when(entitlement.getPool()).thenReturn(pool);
        when(entitlement.getConsumer()).thenReturn(consumer);
        when(pool.getProductId()).thenReturn("12345");
        when(product.getAttributes()).thenReturn(new HashSet<ProductAttribute>());
        when(pool.getAttributes()).thenReturn(attributes);
        when(consumer.getType()).thenReturn(consumerType);
        when(consumerType.getLabel()).thenReturn("candlepin");

        assertTrue(exportRules.canExport(entitlement));
    }
View Full Code Here

        assertEquals(range1.getEndDate(), validRange.getEndDate());
    }

    @Test
    public void validRangeIsNullWhenOnlyFutureEntitlementExists() {
        Consumer c = mockConsumer(PRODUCT_1);

        Calendar cal = Calendar.getInstance();
        Date now = cal.getTime();
        DateRange range1 = rangeRelativeToDate(now, 4, 2);

        c.addEntitlement(mockEntitlement(c, PRODUCT_1, range1, PRODUCT_1));

        List<Entitlement> ents = new LinkedList<Entitlement>(c.getEntitlements());
        mockEntCurator(c, ents);

        ComplianceStatus status = compliance.getStatus(c, now);
        ConsumerInstalledProductEnricher calculator =
            new ConsumerInstalledProductEnricher(c, status, compliance);
View Full Code Here

        assertEquals(0, results.getWarnings().size());
    }

    @Test
    public void preEntitlementShouldNotAllowConsumptionFromDerivedPools() {
        Consumer c = TestUtil.createConsumer();
        c.getType().setManifest(true);

        Product prod = TestUtil.createProduct();
        Pool p = TestUtil.createPool(prod);
        p.setAttribute("virt_only", "true");
        p.setAttribute("pool_derived", "true");
View Full Code Here

        assertNull(validRange);
    }

    @Test
    public void validRangeIsNullWhenOnlyExpiredEntitlementExists() {
        Consumer c = mockConsumer(PRODUCT_1);

        Calendar cal = Calendar.getInstance();
        Date now = cal.getTime();
        DateRange range1 = rangeRelativeToDate(now, -4, -2);

        c.addEntitlement(mockEntitlement(c, PRODUCT_1, range1, PRODUCT_1));

        List<Entitlement> ents = new LinkedList<Entitlement>(c.getEntitlements());
        mockEntCurator(c, ents);

        ComplianceStatus status = compliance.getStatus(c, now);
        ConsumerInstalledProductEnricher calculator =
            new ConsumerInstalledProductEnricher(c, status, compliance);
View Full Code Here

        assertEquals("pool.not.available.to.manifest.consumers", error.getResourceKey());
    }

    @Test
    public void preEntitlementShouldNotAllowListOfDerivedPools() {
        Consumer c = TestUtil.createConsumer();
        c.getType().setManifest(true);

        Product prod = TestUtil.createProduct();
        Pool p = TestUtil.createPool(prod);
        p.setAttribute("virt_only", "true");
        p.setAttribute("pool_derived", "true");
View Full Code Here

TOP

Related Classes of org.candlepin.model.Consumer

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.