Package org.candlepin.model

Examples of org.candlepin.model.EntitlementCertificate


        Entitlement tempE = new Entitlement();
        tempE.getCertificates().addAll(e.getCertificates());
        e.getCertificates().clear();
        // below call creates new certificates and saves it to the backend.
        try {
            EntitlementCertificate generated = this.generateEntitlementCertificate(
                e.getPool(), e, ueberCertificate);
            e.setDirty(false);
            entitlementCurator.merge(e);
            for (EntitlementCertificate ec : tempE.getCertificates()) {
                if (log.isDebugEnabled()) {
                    log.debug("Deleting entitlementCertificate: #" + ec.getId());
                }
                this.entitlementCertificateCurator.delete(ec);
            }

            // send entitlement changed event.
            this.sink.queueEvent(this.eventFactory.entitlementChanged(e));
            if (log.isDebugEnabled()) {
                log.debug("Generated entitlementCertificate: #" + generated.getId());
            }
        }
        catch (CertificateSizeException cse) {
            e.getCertificates().addAll(tempE.getCertificates());
            log.warn("The certificate cannot be regenerated at this time: " +
View Full Code Here


            consumerCuratorMock, certCuratorMock, complianceRules, autobindRules,
            activationKeyRules));

        when(entCertAdapterMock.generateEntitlementCert(any(Entitlement.class),
            any(Subscription.class), any(Product.class))).thenReturn(
                new EntitlementCertificate());

        dummyComplianceStatus = new ComplianceStatus(new Date());
        when(complianceRules.getStatus(any(Consumer.class), any(Date.class))).thenReturn(
            dummyComplianceStatus);
    }
View Full Code Here

    public void filterEntitlementCert() {
        List<Entitlement> allEnts = new LinkedList<Entitlement>();

        Entitlement e = new Entitlement();
        Set<EntitlementCertificate> entCerts = new HashSet<EntitlementCertificate>();
        EntitlementCertificate cert = new EntitlementCertificate();
        cert.setCert("FILTERME");
        cert.setKey("FILTERME");
        entCerts.add(cert);
        e.setCertificates(entCerts);

        allEnts.add(e);
View Full Code Here

        Pool pool = TestUtil.createPool(o, p, providedProducts, 5);
        providedProduct.setPool(pool);
        poolCurator.create(pool);

        Consumer c = createConsumer(o);
        EntitlementCertificate cert = createEntitlementCertificate("key", "certificate");
        Entitlement ent = createEntitlement(o, c, pool, cert);
        entitlementCurator.create(ent);
    }
View Full Code Here

        poolCurator.create(pool);

        Consumer consumer = createConsumer(owner);
        consumerCurator.create(consumer);

        EntitlementCertificate cert = createEntitlementCertificate("key", "certificate");
        Entitlement ent = createEntitlement(owner, consumer, pool, cert);
        entitlementCurator.create(ent);

        List<String> productIds = new ArrayList<String>();
        productIds.add(provided.getId());
View Full Code Here

        product = TestUtil.createProduct();
        pool = TestUtil.createPool(owner, product);

        consumer = TestUtil.createConsumer(owner);
        Entitlement e = TestUtil.createEntitlement(owner, consumer, pool,
            new EntitlementCertificate());

        Set<Entitlement> entSet = new HashSet<Entitlement>();
        entSet.add(e);

        pool.setEntitlements(entSet);
View Full Code Here

        pool.setProductAttribute(SOCKET_ATTRIBUTE, "2", product.getId());
        pool.setQuantity(10L);
        Product product1 = TestUtil.createProduct();
        Pool pool1 = TestUtil.createPool(owner, product1);
        Entitlement e = TestUtil.createEntitlement(owner, consumer, pool1,
            new EntitlementCertificate());

        Set<Entitlement> entSet = new HashSet<Entitlement>();
        entSet.add(e);
        pool1.setEntitlements(entSet);
        pool1.setProductAttribute("multi-entitlement", "yes", product1.getId());
View Full Code Here

        return TestUtil.createEntitlement(owner, consumer, pool, cert);
    }

    protected EntitlementCertificate createEntitlementCertificate(String key,
        String cert) {
        EntitlementCertificate toReturn = new EntitlementCertificate();
        CertificateSerial certSerial = new CertificateSerial(new Date());
        certSerialCurator.create(certSerial);
        toReturn.setKeyAsBytes(key.getBytes());
        toReturn.setCertAsBytes(cert.getBytes());
        toReturn.setSerial(certSerial);
        return toReturn;
    }
View Full Code Here

            new HashSet<DerivedProvidedProduct>();
        subProvidedProducts.add(subProvided1);

        Pool pool = TestUtil.createPool(owner, parentProduct, provided, subProduct.getId(),
            subProvidedProducts, 3);
        EntitlementCertificate cert = createEntitlementCertificate("my-test-key",
            "my-cert");
        Entitlement ent = TestUtil.createEntitlement(owner, consumer, pool, cert);
        ent.setQuantity(3);

        Reader reader = mock(Reader.class);
        when(om.readValue(reader, Entitlement.class)).thenReturn(ent);

        // Create our expected products
        Map<String, Product> productsById = new HashMap<String, Product>();
        productsById.put(parentProduct.getId(), parentProduct);
        productsById.put(pp1.getProductId(),
            TestUtil.createProduct(pp1.getProductId(), pp1.getProductName()));
        productsById.put(subProduct.getId(), subProduct);
        productsById.put(subProvided1.getProductId(), TestUtil.createProduct(
            subProvided1.getProductId(), subProvided1.getProductName()));

        Meta meta = new Meta();
        meta.setCdnLabel("test-cdn");
        Cdn testCdn = new Cdn("test-cdn",
            "Test CDN", "https://test.url.com");
        when(cdnCurator.lookupByLabel("test-cdn")).thenReturn(testCdn);

        Subscription sub = importer.importObject(om, reader, owner,
            productsById, consumerDto, meta);

        assertEquals(pool.getId(), sub.getUpstreamPoolId());
        assertEquals(consumer.getUuid(), sub.getUpstreamConsumerId());
        assertEquals(ent.getId(), sub.getUpstreamEntitlementId());

        assertEquals(owner, sub.getOwner());
        assertEquals(ent.getStartDate(), sub.getStartDate());
        assertEquals(ent.getEndDate(), sub.getEndDate());

        assertEquals(pool.getAccountNumber(), sub.getAccountNumber());
        assertEquals(pool.getContractNumber(), sub.getContractNumber());
        assertEquals(pool.getOrderNumber(), sub.getOrderNumber());

        assertEquals(ent.getQuantity().intValue(), sub.getQuantity().intValue());

        assertEquals(parentProduct, sub.getProduct());
        assertEquals(provided.size(), sub.getProvidedProducts().size());
        assertEquals(pp1.getProductId(), sub.getProvidedProducts().
            iterator().next().getId());

        assertEquals(subProduct, sub.getDerivedProduct());
        assertEquals(1, sub.getDerivedProvidedProducts().size());
        assertEquals(subProvided1.getProductId(), sub.getDerivedProvidedProducts().
            iterator().next().getId());

        assertNotNull(sub.getCertificate());
        CertificateSerial serial = sub.getCertificate().getSerial();
        assertEquals(cert.getSerial().isCollected(), serial.isCollected());
        assertEquals(cert.getSerial().getExpiration(), serial.getExpiration());
        assertEquals(cert.getSerial().getCreated(), serial.getCreated());
        assertEquals(cert.getSerial().getUpdated(), serial.getUpdated());

        assertEquals(sub.getCdn().getLabel(), meta.getCdnLabel());
    }
View Full Code Here

        return sub;
    }

    protected EntitlementCertificate createEntitlementCertificate(String key,
        String cert) {
        EntitlementCertificate toReturn = new EntitlementCertificate();
        CertificateSerial certSerial = new CertificateSerial(new Date());
        certSerial.setCollected(true);
        certSerial.setUpdated(new Date());
        certSerial.setCreated(new Date());
        toReturn.setKeyAsBytes(key.getBytes());
        toReturn.setCertAsBytes(cert.getBytes());
        toReturn.setSerial(certSerial);
        return toReturn;
    }
View Full Code Here

TOP

Related Classes of org.candlepin.model.EntitlementCertificate

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.