use of org.candlepin.model.ConsumerCapability in project candlepin by candlepin.
the class CapabilityTranslatorTest method initSourceObject.
@Override
protected ConsumerCapability initSourceObject() {
ConsumerCapability source = new ConsumerCapability();
source.setName("test_name");
return source;
}
use of org.candlepin.model.ConsumerCapability 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.ConsumerCapability in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method consumerChangeDetection.
@Test
public void consumerChangeDetection() {
Consumer existing = getFakeConsumer();
Set<ConsumerCapability> caps1 = new HashSet<>();
Set<ConsumerCapability> caps2 = new HashSet<>();
ConsumerCapability cca = new ConsumerCapability(existing, "capability_a");
ConsumerCapability ccb = new ConsumerCapability(existing, "capability_b");
ConsumerCapability ccc = new ConsumerCapability(existing, "capability_c");
caps1.add(cca);
caps1.add(ccb);
caps1.add(ccc);
caps2.add(ccb);
existing.setCapabilities(caps1);
Consumer update = getFakeConsumer();
update.setCapabilities(caps1);
assertFalse(resource.performConsumerUpdates(this.translator.translate(update, ConsumerDTO.class), existing, testMigration));
update.setCapabilities(caps2);
assertTrue(resource.performConsumerUpdates(this.translator.translate(update, ConsumerDTO.class), existing, testMigration));
// need a new consumer here, can't null out capabilities
update = getFakeConsumer();
assertFalse(resource.performConsumerUpdates(this.translator.translate(update, ConsumerDTO.class), existing, testMigration));
}
use of org.candlepin.model.ConsumerCapability in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method preEntitlementSuccessInstanceCapable.
@Test
public void preEntitlementSuccessInstanceCapable() {
// Test with sockets to make sure that they are skipped.
Consumer c = this.createMockConsumer(true);
Set<ConsumerCapability> caps = new HashSet<>();
ConsumerCapability cc = new ConsumerCapability(c, "instance_multiplier");
caps.add(cc);
c.setCapabilities(caps);
Product prod = TestUtil.createProduct();
prod.setAttribute(Product.Attributes.INSTANCE_MULTIPLIER, "2");
Pool p = TestUtil.createPool(prod);
ValidationResult results = enforcer.preEntitlement(c, p, 1, CallerType.BEST_POOLS);
assertNotNull(results);
assertEquals(0, results.getErrors().size());
assertEquals(0, results.getWarnings().size());
}
use of org.candlepin.model.ConsumerCapability in project candlepin by candlepin.
the class ManifestEntitlementRulesTest method preEntitlementNoRamCapableBindError.
@Test
public void preEntitlementNoRamCapableBindError() {
// Test with sockets to make sure that they are skipped.
Consumer c = this.createMockConsumer(true);
c.setFact("memory.memtotal", "2000000");
Set<ConsumerCapability> caps = new HashSet<>();
c.setCapabilities(caps);
Product prod = TestUtil.createProduct();
prod.setAttribute(Product.Attributes.RAM, "2");
Pool p = TestUtil.createPool(prod);
p.setId("poolId");
ValidationResult results = enforcer.preEntitlement(c, p, 1, CallerType.BIND);
assertNotNull(results);
assertEquals(0, results.getWarnings().size());
ValidationError error = results.getErrors().get(0);
assertEquals("rulefailed.ram.unsupported.by.consumer", error.getResourceKey());
}
Aggregations