use of org.candlepin.model.GuestId in project candlepin by candlepin.
the class GuestIdResourceTest method deleteGuestNotFound.
/*
* Should behave just like deleteGuest with no consumer
*/
@Test
public void deleteGuestNotFound() {
GuestId guest = new GuestId("guest-id", consumer);
when(guestIdCurator.findByConsumerAndId(eq(consumer), eq(guest.getGuestId()))).thenReturn(guest);
when(consumerCurator.findByVirtUuid(guest.getGuestId(), consumer.getOwnerId())).thenReturn(null);
guestIdResource.deleteGuest(consumer.getUuid(), guest.getGuestId(), true, null);
Mockito.verify(guestIdCurator, Mockito.times(1)).delete(eq(guest));
Mockito.verify(consumerResource, Mockito.never()).checkForMigration(eq(consumer), any(Consumer.class));
}
use of org.candlepin.model.GuestId in project candlepin by candlepin.
the class ComplianceRulesTest method fullyCompliantOverriddenVirtLimit.
/*
* This test should behave more like the scenarios discussed in implementation.
* A base subscription with a virt limit of 4, and a hypervisor which overrides
* the unrelated subscriptions virt limit, making it unlimited as well.
*/
@Test
public void fullyCompliantOverriddenVirtLimit() {
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);
// Before we add the hypervisor, this product shouldn't be compliant
ComplianceStatus status = compliance.getStatus(c, TestUtil.createDate(2011, 8, 30));
// Should be partial
assertEquals("partial", status.getStatus());
assertEquals(2, status.getPartiallyCompliantProducts().size());
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);
mockEntCurator(c, ents);
// Now that we've added the hypervisor,
// the base guest_limit of 4 should be overridden
status = compliance.getStatus(c, TestUtil.createDate(2011, 8, 30));
assertEquals(0, status.getNonCompliantProducts().size());
assertEquals(2, status.getCompliantProducts().size());
assertEquals(0, status.getPartiallyCompliantProducts().size());
assertTrue(status.getCompliantProducts().keySet().contains(PRODUCT_1.getId()));
assertTrue(status.getCompliantProducts().keySet().contains(PRODUCT_2.getId()));
assertEquals(2, status.getCompliantProducts().get(PRODUCT_1.getId()).size());
assertEquals(2, status.getCompliantProducts().get(PRODUCT_2.getId()).size());
}
use of org.candlepin.model.GuestId in project candlepin by candlepin.
the class ComplianceRulesTest method virtLimitSingleEntitlementPartial.
@Test
public void virtLimitSingleEntitlementPartial() {
Consumer c = mockConsumer(PRODUCT_1);
c.setFact("cpu.core(s)_per_socket", "4");
for (int i = 0; i < 5; i++) {
c.addGuestId(new GuestId("" + i, c, activeGuestAttrs));
}
Entitlement ent = mockEntitlement(c, PRODUCT_1);
ent.getPool().getProduct().setAttribute(Product.Attributes.CORES, "32");
ent.getPool().getProduct().setAttribute(Product.Attributes.GUEST_LIMIT, "4");
mockEntCurator(c, Arrays.asList(ent));
ComplianceStatus status = compliance.getStatus(c, TestUtil.createDate(2011, 8, 30));
assertEquals(0, status.getNonCompliantProducts().size());
assertEquals(1, status.getPartiallyCompliantProducts().size());
assertEquals(0, status.getCompliantProducts().size());
assertTrue(status.getPartiallyCompliantProducts().keySet().contains(PRODUCT_1.getId()));
assertEquals(ComplianceStatus.YELLOW, status.getStatus());
}
use of org.candlepin.model.GuestId in project candlepin by candlepin.
the class ComplianceRulesTest method virtLimitSingleEntitlementCovered.
@Test
public void virtLimitSingleEntitlementCovered() {
Consumer c = mockConsumer(PRODUCT_1);
c.setFact("cpu.core(s)_per_socket", "4");
for (int i = 0; i < 5; i++) {
c.addGuestId(new GuestId("" + i, c, activeGuestAttrs));
}
Entitlement ent = mockEntitlement(c, PRODUCT_1);
ent.getPool().getProduct().setAttribute(Product.Attributes.CORES, "32");
ent.getPool().getProduct().setAttribute(Product.Attributes.GUEST_LIMIT, "8");
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()));
}
Aggregations