use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class PreEntitlementRulesTest method missingConsumerArchitectureShouldNotGenerateWarningForNonSystem.
@Test
public void missingConsumerArchitectureShouldNotGenerateWarningForNonSystem() {
String nonSystemType = "somethingElse";
Product product = TestUtil.createProduct(productId, "A product for testing");
product.setAttribute(Product.Attributes.ARCHITECTURE, "x86_64");
product.setAttribute(Pool.Attributes.REQUIRES_CONSUMER_TYPE, nonSystemType);
Pool pool = TestUtil.createPool(owner, product);
pool.setId("fakeid" + TestUtil.randomInt());
ConsumerType ctype = this.mockConsumerType(new ConsumerType(nonSystemType));
consumer.setType(ctype);
ValidationResult result = enforcer.preEntitlement(consumer, pool, 1);
assertFalse(result.hasErrors());
assertFalse(result.hasWarnings());
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class ConsumerTypeResourceTest method testCreateType.
@Test
public void testCreateType() {
String label = "test_label";
ConsumerType existing = this.consumerTypeCurator.lookupByLabel(label);
// Verify it doesn't exist already
assertNull(existing);
ConsumerTypeDTO dto = new ConsumerTypeDTO();
dto.setLabel(label);
dto.setManifest(true);
// Create the type with our DTO
ConsumerTypeDTO output = this.consumerTypeResource.create(dto);
assertNotNull(output);
assertEquals(dto.getLabel(), output.getLabel());
assertEquals(dto.isManifest(), output.isManifest());
// Flush & clear DB state
this.consumerTypeCurator.flush();
this.consumerTypeCurator.clear();
// Ensure the type actually hit the DB
existing = this.consumerTypeCurator.lookupByLabel(label);
assertNotNull(existing);
assertEquals(dto.getLabel(), existing.getLabel());
assertEquals(dto.isManifest(), existing.isManifest());
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class ConsumerTypeResourceTest method testUpdateTypeUpdatesLabelButNotManifest.
@Test
public void testUpdateTypeUpdatesLabelButNotManifest() {
String label = "updated_label";
boolean manifest = this.testType.isManifest();
ConsumerTypeDTO dto = new ConsumerTypeDTO();
dto.setId(this.testType.getId());
dto.setLabel(label);
// Update the type with our DTO
ConsumerTypeDTO output = this.consumerTypeResource.update(dto);
assertNotNull(output);
assertEquals(dto.getLabel(), output.getLabel());
assertEquals(manifest, output.isManifest());
// Flush & clear DB state
this.consumerTypeCurator.flush();
this.consumerTypeCurator.clear();
// Ensure the update actually hit the DB
ConsumerType existing = this.consumerTypeCurator.lookupByLabel(label);
assertNotNull(existing);
assertEquals(dto.getLabel(), existing.getLabel());
assertEquals(manifest, existing.isManifest());
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class EntitlementResourceTest method migrateEntitlementSameOwnerFail.
@Test(expected = BadRequestException.class)
public void migrateEntitlementSameOwnerFail() {
ConsumerType ct = TestUtil.createConsumerType();
ct.setManifest(true);
this.mockConsumerType(ct);
Entitlement e = TestUtil.createEntitlement();
Owner owner2 = new Owner("admin2");
owner.setId(TestUtil.randomString());
owner2.setId(TestUtil.randomString());
Consumer sourceConsumer = new Consumer("source-consumer", "bill", owner, ct);
Consumer destConsumer = new Consumer("destination-consumer", "bill", owner2, ct);
e.setConsumer(sourceConsumer);
e.setQuantity(25);
when(entitlementCurator.find(eq(e.getId()))).thenReturn(e);
when(consumerCurator.verifyAndLookupConsumer(eq(destConsumer.getUuid()))).thenReturn(destConsumer);
entResource.migrateEntitlement(e.getId(), destConsumer.getUuid(), 15);
}
use of org.candlepin.model.ConsumerType in project candlepin by candlepin.
the class EntitlementResourceTest method migrateEntitlementDestinationConsumerFail.
@Test(expected = BadRequestException.class)
public void migrateEntitlementDestinationConsumerFail() {
ConsumerType ct = TestUtil.createConsumerType();
ct.setManifest(true);
this.mockConsumerType(ct);
Entitlement e = TestUtil.createEntitlement();
Consumer sourceConsumer = new Consumer("source-consumer", "bill", owner, ct);
e.setConsumer(sourceConsumer);
e.setQuantity(25);
when(entitlementCurator.find(eq(e.getId()))).thenReturn(e);
when(consumerCurator.verifyAndLookupConsumer(eq(consumer.getUuid()))).thenReturn(consumer);
entResource.migrateEntitlement(e.getId(), consumer.getUuid(), 15);
}
Aggregations