Search in sources :

Example 96 with Entitlement

use of org.candlepin.model.Entitlement in project candlepin by candlepin.

the class ComplianceRulesTest method isEntPartiallyCompliantNonOverriddenVirtLimit.

@Test
public void isEntPartiallyCompliantNonOverriddenVirtLimit() {
    Consumer c = mockConsumer(PRODUCT_1, PRODUCT_2);
    for (int i = 0; i < 5; i++) {
        c.addGuestId(new GuestId("" + i, c, activeGuestAttrs));
    }
    List<Entitlement> ents = new LinkedList<>();
    Entitlement mockServerEntitlement = mockEntitlement(c, TestUtil.createProduct("Awesome OS server"), PRODUCT_1, PRODUCT_2);
    mockServerEntitlement.getPool().getProduct().setAttribute(Product.Attributes.GUEST_LIMIT, "4");
    ents.add(mockServerEntitlement);
    mockEntCurator(c, ents);
    // The guest limit has not been modified, should not be compliant.
    assertFalse(compliance.isEntitlementCompliant(c, mockServerEntitlement, new Date()));
}
Also used : Consumer(org.candlepin.model.Consumer) GuestId(org.candlepin.model.GuestId) Entitlement(org.candlepin.model.Entitlement) LinkedList(java.util.LinkedList) Date(java.util.Date) Test(org.junit.Test)

Example 97 with Entitlement

use of org.candlepin.model.Entitlement in project candlepin by candlepin.

the class ComplianceRulesTest method isStackFullyCompliantOverriddenVirtLimit.

@Test
public void isStackFullyCompliantOverriddenVirtLimit() {
    Consumer c = mockConsumer(PRODUCT_1, PRODUCT_2);
    for (int i = 0; i < 5; i++) {
        c.addGuestId(new GuestId("" + i, c, activeGuestAttrs));
    }
    List<Entitlement> ents = new LinkedList<>();
    Entitlement mockServerEntitlement = mockStackedEntitlement(c, "mockServerStack", PRODUCT_1, PRODUCT_2);
    mockServerEntitlement.getPool().getProduct().setAttribute(Product.Attributes.GUEST_LIMIT, "4");
    mockServerEntitlement.getPool().getProduct().setAttribute(Product.Attributes.SOCKETS, "2");
    mockServerEntitlement.setQuantity(4);
    ents.add(mockServerEntitlement);
    Entitlement mockHypervisorEntitlement = mockEntitlement(c, TestUtil.createProduct("Awesome Enterprise Hypervisor"), PRODUCT_1, PRODUCT_2);
    mockHypervisorEntitlement.getPool().getProduct().setAttribute(Product.Attributes.GUEST_LIMIT, "-1");
    ents.add(mockHypervisorEntitlement);
    // Now that we've added the hypervisor,
    // the base guest_limit of 4 should be overridden
    assertTrue(compliance.isStackCompliant(c, "mockServerStack", ents));
}
Also used : Consumer(org.candlepin.model.Consumer) GuestId(org.candlepin.model.GuestId) Entitlement(org.candlepin.model.Entitlement) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 98 with Entitlement

use of org.candlepin.model.Entitlement in project candlepin by candlepin.

the class ComplianceRulesTest method mockFullyEntitledConsumer.

private Consumer mockFullyEntitledConsumer() {
    Consumer c = mockConsumer(PRODUCT_1, PRODUCT_2);
    List<Entitlement> ents = new LinkedList<>();
    ents.add(mockEntitlement(c, TestUtil.createProduct("Awesome Product"), PRODUCT_1, PRODUCT_2));
    mockEntCurator(c, ents);
    return c;
}
Also used : Consumer(org.candlepin.model.Consumer) Entitlement(org.candlepin.model.Entitlement) LinkedList(java.util.LinkedList)

Example 99 with Entitlement

use of org.candlepin.model.Entitlement in project candlepin by candlepin.

the class ComplianceRulesTest method productCoveredWhenSingleEntitlementCoversCores.

// Cores with not-stackable entitlement tests
@Test
public void productCoveredWhenSingleEntitlementCoversCores() {
    Consumer c = mockConsumer(PRODUCT_1);
    c.setFact("cpu.core(s)_per_socket", "4");
    Entitlement ent = mockEntitlement(c, PRODUCT_1);
    ent.getPool().getProduct().setAttribute(Product.Attributes.CORES, "32");
    mockEntCurator(c, Arrays.asList(ent));
    ComplianceStatus status = compliance.getStatus(c, TestUtil.createDate(2011, 8, 30));
    assertEquals(0, status.getNonCompliantProducts().size());
    assertEquals(0, status.getPartiallyCompliantProducts().size());
    assertEquals(1, status.getCompliantProducts().size());
    assertTrue(status.getCompliantProducts().keySet().contains(PRODUCT_1.getId()));
    assertEquals(ComplianceStatus.GREEN, status.getStatus());
}
Also used : Consumer(org.candlepin.model.Consumer) Entitlement(org.candlepin.model.Entitlement) Test(org.junit.Test)

Example 100 with Entitlement

use of org.candlepin.model.Entitlement in project candlepin by candlepin.

the class ComplianceRulesTest method stackIsCompliant.

@Test
public void stackIsCompliant() {
    Consumer c = mockConsumer(PRODUCT_1);
    c.setFact("cpu.cpu_socket(s)", "2");
    List<Entitlement> ents = new LinkedList<>();
    ents.add(mockStackedEntitlement(c, STACK_ID_1, TestUtil.createProduct("Awesome Product"), PRODUCT_1));
    assertTrue(compliance.isStackCompliant(c, STACK_ID_1, ents));
}
Also used : Consumer(org.candlepin.model.Consumer) Entitlement(org.candlepin.model.Entitlement) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

Entitlement (org.candlepin.model.Entitlement)301 Test (org.junit.Test)201 Consumer (org.candlepin.model.Consumer)164 Pool (org.candlepin.model.Pool)125 LinkedList (java.util.LinkedList)84 Product (org.candlepin.model.Product)68 Date (java.util.Date)62 ArrayList (java.util.ArrayList)61 HashSet (java.util.HashSet)59 HashMap (java.util.HashMap)55 Owner (org.candlepin.model.Owner)44 PoolQuantity (org.candlepin.model.PoolQuantity)35 ConsumerType (org.candlepin.model.ConsumerType)34 List (java.util.List)30 ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)24 Matchers.anyString (org.mockito.Matchers.anyString)17 Set (java.util.Set)16 Subscription (org.candlepin.model.dto.Subscription)16 ApiOperation (io.swagger.annotations.ApiOperation)15 ApiResponses (io.swagger.annotations.ApiResponses)15