use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class QuantityRulesTest method testPhysicalIgnoresPastConsumed.
@Test
public void testPhysicalIgnoresPastConsumed() {
pool.getProduct().setAttribute(Pool.Attributes.MULTI_ENTITLEMENT, "yes");
pool.getProduct().setAttribute(Product.Attributes.STACKING_ID, "1");
pool.getProduct().setAttribute(SOCKET_ATTRIBUTE, "1");
consumer.setFact(SOCKET_FACT, "4");
// Green now, but we will ask for suggested quantity on a date in the future:
Entitlement e = createValidEntitlement(pool);
e.setQuantity(4);
Set<Entitlement> ents = new HashSet<>();
ents.add(e);
consumer.setEntitlements(ents);
// Ask for quantity in the future, past the end of the current pool:
Calendar c = Calendar.getInstance();
c.setTime(pool.getEndDate());
Date futureDate = TestUtil.createDate(c.get(Calendar.YEAR) + 1, 1, 1);
SuggestedQuantity suggested = quantityRules.getSuggestedQuantity(pool, consumer, futureDate);
assertEquals(new Long(4), suggested.getSuggested());
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class RulesObjectMapperTest method filterEntitlementConsumer.
@Test
public void filterEntitlementConsumer() {
Entitlement e = new Entitlement();
Consumer c = new Consumer();
IdentityCertificate cert = new IdentityCertificate();
cert.setCert("FILTERMEPLEASE");
cert.setKey("KEY");
c.setIdCert(cert);
e.setConsumer(c);
context.put("entitlement", e);
String output = objMapper.toJsonString(context);
assertFalse(output.contains("consumer"));
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class RulesObjectMapperTest method filterEntitlementCert.
@Test
public void filterEntitlementCert() {
List<Entitlement> allEnts = new LinkedList<>();
Entitlement e = new Entitlement();
Set<EntitlementCertificate> entCerts = new HashSet<>();
EntitlementCertificate cert = new EntitlementCertificate();
cert.setCert("FILTERME");
cert.setKey("FILTERME");
entCerts.add(cert);
e.setCertificates(entCerts);
allEnts.add(e);
context.put("entitlements", allEnts);
String output = objMapper.toJsonString(context);
assertFalse(output.contains("FILTERME"));
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class ComplianceRulesTest method mockHostRestrictedEntitlement.
private Entitlement mockHostRestrictedEntitlement(Consumer consumer, String stackId, Product product, Product... providedProducts) {
Entitlement ent = this.mockBaseStackedEntitlement(consumer, stackId, product, providedProducts);
Pool pool = ent.getPool();
pool.setAttribute(Pool.Attributes.REQUIRES_HOST, "SOMEUUID");
pool.getProduct().setAttribute(Product.Attributes.SOCKETS, "2");
pool.getProduct().setAttribute(Product.Attributes.VCPU, "1");
return ent;
}
use of org.candlepin.model.Entitlement in project candlepin by candlepin.
the class ComplianceRulesTest method virtualStackedOnlyUsesVcpuAndRam.
@Test
public void virtualStackedOnlyUsesVcpuAndRam() {
Consumer c = mockConsumer(PRODUCT_1, PRODUCT_2);
c.setFact("virt.is_guest", "true");
c.setFact("cpu.core(s)_per_socket", "8");
c.setFact("cpu.cpu_socket(s)", "10");
// 8GB RAM
c.setFact("memory.memtotal", "8000000");
List<Entitlement> ents = new LinkedList<>();
Entitlement ent = mockBaseStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2);
ent.getPool().getProduct().setAttribute(Product.Attributes.CORES, "1");
ent.getPool().getProduct().setAttribute(Product.Attributes.RAM, "1");
ent.getPool().getProduct().setAttribute(Product.Attributes.SOCKETS, "1");
ent.getPool().getProduct().setAttribute(Product.Attributes.VCPU, "1");
ents.add(ent);
ents.get(0).setQuantity(1);
mockEntCurator(c, ents);
ComplianceStatus status = compliance.getStatus(c, TestUtil.createDate(2011, 8, 30));
assertEquals(ComplianceStatus.YELLOW, status.getStatus());
assertEquals(0, status.getNonCompliantProducts().size());
assertEquals(2, status.getPartiallyCompliantProducts().size());
assertEquals(0, status.getCompliantProducts().size());
assertTrue(status.getPartiallyCompliantProducts().keySet().contains(PRODUCT_1.getId()));
assertTrue(status.getPartiallyCompliantProducts().keySet().contains(PRODUCT_2.getId()));
// We should be partial because of ram and vcpus, nothing else
assertEquals(2, status.getReasons().size());
List<String> reasonKeys = new LinkedList<>();
for (ComplianceReason r : status.getReasons()) {
reasonKeys.add(r.getKey());
}
assertTrue(reasonKeys.contains("RAM"));
assertTrue(reasonKeys.contains("VCPU"));
}
Aggregations