Search in sources :

Example 6 with CertificateSerialDTO

use of org.candlepin.dto.manifest.v1.CertificateSerialDTO in project candlepin by candlepin.

the class ConsumerResourceIntegrationTest method testContentAccessExpireRegen.

@Test
public void testContentAccessExpireRegen() {
    owner.setContentAccessModeList(ContentAccessCertServiceAdapter.ORG_ENV_ACCESS_MODE);
    owner.setContentAccessMode(ContentAccessCertServiceAdapter.ORG_ENV_ACCESS_MODE);
    ownerCurator.merge(owner);
    consumer = TestUtil.createConsumer(standardSystemType, owner);
    consumer.setFact("system.certificate_version", "3.3");
    consumerCurator.create(consumer);
    List<CertificateDTO> serials = consumerResource.getEntitlementCertificates(consumer.getUuid(), null);
    assertEquals(1, serials.size());
    CertificateDTO original = serials.get(0);
    CertificateSerialDTO serialDTO = original.getSerial();
    CertificateSerial serial = new CertificateSerial(serialDTO.getId(), serialDTO.getExpiration());
    serial.setSerial(serialDTO.getSerial().longValue());
    serial.setCollected(serialDTO.isCollected());
    serial.setRevoked(serialDTO.isRevoked());
    Calendar cal = Calendar.getInstance();
    cal.setTime(serial.getExpiration());
    cal.add(Calendar.YEAR, -2);
    serial.setExpiration(cal.getTime());
    serialCurator.merge(serial);
    serials = consumerResource.getEntitlementCertificates(consumer.getUuid(), null);
    assertEquals(1, serials.size());
    CertificateDTO updated = serials.get(0);
    assert (updated instanceof CertificateDTO);
    assertFalse(original.getSerial().getId() == updated.getSerial().getId());
}
Also used : CertificateDTO(org.candlepin.dto.api.v1.CertificateDTO) CertificateSerialDTO(org.candlepin.dto.api.v1.CertificateSerialDTO) Calendar(java.util.Calendar) CertificateSerial(org.candlepin.model.CertificateSerial) Test(org.junit.Test)

Aggregations

CertificateSerial (org.candlepin.model.CertificateSerial)5 CertificateSerialDTO (org.candlepin.dto.api.v1.CertificateSerialDTO)4 Test (org.junit.Test)3 CertificateDTO (org.candlepin.dto.api.v1.CertificateDTO)2 CertificateSerialDTO (org.candlepin.dto.manifest.v1.CertificateSerialDTO)2 CertificateSerialCurator (org.candlepin.model.CertificateSerialCurator)2 Calendar (java.util.Calendar)1 HashSet (java.util.HashSet)1 BadRequestException (org.candlepin.common.exceptions.BadRequestException)1 BrandingDTO (org.candlepin.dto.manifest.v1.BrandingDTO)1 CertificateDTO (org.candlepin.dto.manifest.v1.CertificateDTO)1 EntitlementDTO (org.candlepin.dto.manifest.v1.EntitlementDTO)1 PoolDTO (org.candlepin.dto.manifest.v1.PoolDTO)1 Branding (org.candlepin.model.Branding)1 CandlepinQuery (org.candlepin.model.CandlepinQuery)1 CdnCertificate (org.candlepin.model.CdnCertificate)1 EmptyCandlepinQuery (org.candlepin.model.EmptyCandlepinQuery)1 EntitlementCertificate (org.candlepin.model.EntitlementCertificate)1 Owner (org.candlepin.model.Owner)1 Pool (org.candlepin.model.Pool)1