use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class ConsumerTranslatorTest method verifyOutput.
@Override
protected void verifyOutput(Consumer source, ConsumerDTO dest, boolean childrenGenerated) {
if (source != null) {
assertEquals(source.getId(), dest.getId());
assertEquals(source.getUuid(), dest.getUuid());
assertEquals(source.getName(), dest.getName());
assertEquals(source.getUsername(), dest.getUsername());
assertEquals(source.getEntitlementStatus(), dest.getEntitlementStatus());
assertEquals(source.getServiceLevel(), dest.getServiceLevel());
assertEquals(source.getEntitlementCount(), (long) dest.getEntitlementCount());
assertEquals(source.getFacts(), dest.getFacts());
assertEquals(source.getLastCheckin(), dest.getLastCheckin());
assertEquals(source.isCanActivate(), dest.isCanActivate());
assertEquals(source.getContentTags(), dest.getContentTags());
assertEquals(source.isAutoheal(), dest.getAutoheal());
assertEquals(source.getRecipientOwnerKey(), dest.getRecipientOwnerKey());
assertEquals(source.getAnnotations(), dest.getAnnotations());
assertEquals(source.getContentAccessMode(), dest.getContentAccessMode());
if (childrenGenerated) {
ConsumerType ctype = this.mockConsumerTypeCurator.getConsumerType(source);
this.consumerTypeTranslatorTest.verifyOutput(ctype, dest.getType(), true);
Environment environment = this.mockEnvironmentCurator.getConsumerEnvironment(source);
this.environmentTranslatorTest.verifyOutput(environment, dest.getEnvironment(), true);
assertEquals(source.getReleaseVer().getReleaseVer(), dest.getReleaseVersion());
String destOwnerId = null;
if (dest.getOwner() != null) {
destOwnerId = dest.getOwner().getId();
}
assertEquals(source.getOwnerId(), destOwnerId);
this.hypervisorIdTranslatorTest.verifyOutput(source.getHypervisorId(), dest.getHypervisorId(), childrenGenerated);
this.certificateTranslatorTest.verifyOutput(source.getIdCert(), dest.getIdCert(), true);
if (source.getInstalledProducts() != null) {
for (ConsumerInstalledProduct cip : source.getInstalledProducts()) {
for (ConsumerInstalledProductDTO cipDTO : dest.getInstalledProducts()) {
assertNotNull(cip);
assertNotNull(cipDTO);
this.cipTranslatorTest.verifyOutput(cip, cipDTO, childrenGenerated);
}
}
} else {
assertNull(dest.getInstalledProducts());
}
if (source.getCapabilities() != null) {
for (ConsumerCapability cc : source.getCapabilities()) {
boolean verified = false;
for (CapabilityDTO ccDTO : dest.getCapabilities()) {
assertNotNull(cc);
assertNotNull(ccDTO);
if (cc.getName().contentEquals(ccDTO.getName())) {
this.capabilityTranslatorTest.verifyOutput(cc, ccDTO, childrenGenerated);
verified = true;
}
}
assertTrue(verified);
}
} else {
assertNull(dest.getCapabilities());
}
assertEquals(0, dest.getGuestIds().size());
} else {
assertNull(dest.getReleaseVersion());
assertNull(dest.getOwner());
assertNull(dest.getEnvironment());
assertNull(dest.getHypervisorId());
assertNull(dest.getType());
assertNull(dest.getIdCert());
assertNull(dest.getInstalledProducts());
assertNull(dest.getCapabilities());
assertNull(dest.getGuestIds());
}
} else {
assertNull(dest);
}
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class ConsumerTranslatorTest method verifyOutput.
@Override
protected void verifyOutput(Consumer source, ConsumerDTO dest, boolean childrenGenerated) {
if (source != null) {
assertEquals(source.getUuid(), dest.getUuid());
assertEquals(source.getName(), dest.getName());
assertEquals(source.getContentAccessMode(), dest.getContentAccessMode());
if (childrenGenerated) {
if (dest.getOwner() != null) {
assertEquals(source.getOwnerId(), dest.getOwner().getId());
} else {
assertNull(source.getOwnerId());
}
ConsumerType ctype = this.mockConsumerTypeCurator.getConsumerType(source);
this.consumerTypeTranslatorTest.verifyOutput(ctype, dest.getType(), true);
} else {
assertNull(dest.getOwner());
assertNull(dest.getType());
}
} else {
assertNull(dest);
}
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class TestUtil method createDistributor.
public static Consumer createDistributor(Owner owner) {
ConsumerType ctype = new ConsumerType(ConsumerType.ConsumerTypeEnum.CANDLEPIN);
ctype.setId("test-ctype-" + randomInt());
return createConsumer(ctype, owner);
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class ManifestManagerTest method createMockConsumer.
protected Consumer createMockConsumer(Owner owner, boolean manifestDistributor) {
ConsumerType type = manifestDistributor ? new ConsumerType(ConsumerType.ConsumerTypeEnum.CANDLEPIN) : new ConsumerType("test-consumer-type-" + TestUtil.randomInt());
type.setId("test-ctype-" + TestUtil.randomInt());
Consumer consumer = new Consumer("TestConsumer" + TestUtil.randomInt(), "User", owner, type);
when(consumerTypeCurator.getConsumerType(eq(consumer))).thenReturn(type);
when(consumerTypeCurator.find(eq(type.getId()))).thenReturn(type);
return consumer;
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class ManifestManagerTest method verifyConsumerIsDistributorBeforeGeneratingManifest.
@Test
public void verifyConsumerIsDistributorBeforeGeneratingManifest() throws Exception {
Consumer consumer = this.createMockConsumer(false);
ConsumerType ctype = consumerTypeCurator.getConsumerType(consumer);
Cdn cdn = new Cdn("test-cdn", "Test CDN", "");
String webAppPrefix = "webapp-prefix";
String apiUrl = "api-url";
Map<String, String> extData = new HashMap<>();
when(consumerCurator.verifyAndLookupConsumer(eq(consumer.getUuid()))).thenReturn(consumer);
when(cdnCurator.lookupByLabel(eq(cdn.getLabel()))).thenReturn(cdn);
try {
manager.generateManifest(consumer.getUuid(), cdn.getLabel(), webAppPrefix, apiUrl, extData);
fail("Expected ForbiddenException not thrown");
} catch (Exception e) {
assertTrue(e instanceof ForbiddenException);
String expectedMsg = String.format("Unit %s cannot be exported. A manifest cannot be made for " + "units of type \"%s\".", consumer.getUuid(), ctype.getLabel());
assertEquals(e.getMessage(), expectedMsg);
}
}
Aggregations