Search in sources :

Example 1 with Cdn

use of org.candlepin.model.Cdn in project candlepin by candlepin.

the class CdnImporter method store.

/**
 * @param cdnSet Set of CDN's.
 */
public void store(Set<Cdn> cdnSet) {
    log.debug("Creating/updating cdns");
    for (Cdn cdn : cdnSet) {
        Cdn existing = curator.lookupByLabel(cdn.getLabel());
        if (existing == null) {
            log.debug("Creating CDN: {}", cdn);
            curator.create(cdn);
        } else {
            log.debug("Updating CDN: {}", cdn);
            existing.setName(cdn.getName());
            existing.setUrl(cdn.getUrl());
            curator.merge(existing);
        }
    }
}
Also used : Cdn(org.candlepin.model.Cdn)

Example 2 with Cdn

use of org.candlepin.model.Cdn in project candlepin by candlepin.

the class CdnImporter method createObject.

public Cdn createObject(ObjectMapper mapper, Reader reader) throws IOException {
    Cdn cdn = mapper.readValue(reader, Cdn.class);
    cdn.setId(null);
    return cdn;
}
Also used : Cdn(org.candlepin.model.Cdn)

Example 3 with Cdn

use of org.candlepin.model.Cdn in project candlepin by candlepin.

the class CdnManagerTest method updateCdn.

@Test
public void updateCdn() throws Exception {
    Cdn cdn = createCdn("test_cdn");
    assertEquals("Test CDN", cdn.getName());
    cdn.setName("Updated CDN");
    manager.updateCdn(cdn);
    Cdn fetched = curator.lookupByLabel(cdn.getLabel());
    assertNotNull(fetched);
    assertEquals(cdn.getLabel(), fetched.getLabel());
    assertEquals("Updated CDN", fetched.getName());
}
Also used : Cdn(org.candlepin.model.Cdn) Test(org.junit.Test)

Example 4 with Cdn

use of org.candlepin.model.Cdn in project candlepin by candlepin.

the class CdnManagerTest method cdnCertSerialIsRevokedOnCdnDeletion.

@Test
public void cdnCertSerialIsRevokedOnCdnDeletion() throws Exception {
    Cdn cdn = createCdn("test_cdn");
    CertificateSerial serial = cdn.getCertificate().getSerial();
    assertNotNull(serial);
    assertFalse(serial.isRevoked());
    manager.deleteCdn(cdn);
    CertificateSerial fetched = certSerialCurator.find(serial.getId());
    assertNotNull(fetched);
    assertTrue(fetched.isRevoked());
}
Also used : CertificateSerial(org.candlepin.model.CertificateSerial) Cdn(org.candlepin.model.Cdn) Test(org.junit.Test)

Example 5 with Cdn

use of org.candlepin.model.Cdn in project candlepin by candlepin.

the class CdnManagerTest method testCreateCdn.

@Test
public void testCreateCdn() throws Exception {
    Cdn cdn = createCdn("test_cdn");
    Cdn fetched = curator.lookupByLabel(cdn.getLabel());
    assertNotNull(fetched);
    assertEquals("test_cdn", fetched.getLabel());
}
Also used : Cdn(org.candlepin.model.Cdn) Test(org.junit.Test)

Aggregations

Cdn (org.candlepin.model.Cdn)26 Test (org.junit.Test)16 Consumer (org.candlepin.model.Consumer)11 HashMap (java.util.HashMap)7 Owner (org.candlepin.model.Owner)7 File (java.io.File)5 BadRequestException (org.candlepin.common.exceptions.BadRequestException)5 ArrayList (java.util.ArrayList)4 Event (org.candlepin.audit.Event)4 ForbiddenException (org.candlepin.common.exceptions.ForbiddenException)4 NotFoundException (org.candlepin.common.exceptions.NotFoundException)4 CertificateSerial (org.candlepin.model.CertificateSerial)4 ConsumerType (org.candlepin.model.ConsumerType)4 Entitlement (org.candlepin.model.Entitlement)4 ManifestFile (org.candlepin.sync.file.ManifestFile)3 ApiOperation (io.swagger.annotations.ApiOperation)2 Reader (java.io.Reader)2 Date (java.util.Date)2 Consumes (javax.ws.rs.Consumes)2 Produces (javax.ws.rs.Produces)2