use of org.candlepin.dto.api.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());
}
Aggregations