Search in sources :

Example 61 with PoolQuantity

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

the class AutobindRulesTest method instanceAutobindForPhysicalNoSocketFact.

@Test
public void instanceAutobindForPhysicalNoSocketFact() {
    List<Pool> pools = createInstanceBasedPool();
    List<PoolQuantity> bestPools = autobindRules.selectBestPools(consumer, new String[] { productId }, pools, compliance, null, new HashSet<>(), false);
    assertEquals(1, bestPools.size());
    PoolQuantity q = bestPools.get(0);
    assertEquals(new Integer(2), q.getQuantity());
}
Also used : PoolQuantity(org.candlepin.model.PoolQuantity) Pool(org.candlepin.model.Pool) Test(org.junit.Test)

Example 62 with PoolQuantity

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

the class AutobindRulesTest method testPoolQuantityCompare.

@Test
public void testPoolQuantityCompare() {
    Product prod = mockProduct(productId, "some prod", "2");
    Pool pool1 = TestUtil.createPool(owner, prod, 10);
    pool1.setId("1234");
    PoolQuantity pq1 = new PoolQuantity(pool1, 5);
    PoolQuantity pq2 = new PoolQuantity(pool1, 7);
    assertEquals(-1, pq1.compareTo(pq2));
}
Also used : PoolQuantity(org.candlepin.model.PoolQuantity) Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) Test(org.junit.Test)

Example 63 with PoolQuantity

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

the class AutobindRulesTest method testPoolQuantityCompareEqual.

@Test
public void testPoolQuantityCompareEqual() {
    Product prod = mockProduct(productId, "some prod", "2");
    Pool pool1 = TestUtil.createPool(owner, prod, 10);
    pool1.setId("1234");
    PoolQuantity pq1 = new PoolQuantity(pool1, 5);
    PoolQuantity pq2 = new PoolQuantity(pool1, 5);
    assertEquals(0, pq1.compareTo(pq2));
}
Also used : PoolQuantity(org.candlepin.model.PoolQuantity) Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) Test(org.junit.Test)

Example 64 with PoolQuantity

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

the class AutobindRulesTest method autobindForPhysicalSocketPicksBestFitBalance.

@Test
public void autobindForPhysicalSocketPicksBestFitBalance() {
    List<Pool> pools = createSocketPool(3, 100, "1");
    pools.addAll(createSocketPool(5, 100, "2"));
    setupConsumer("8", false);
    List<PoolQuantity> bestPools = autobindRules.selectBestPools(consumer, new String[] { productId }, pools, compliance, null, new HashSet<>(), false);
    // Should always pick the 3 socket subscription, becuase 3*3 gives 1 socket over-coverage,
    // and 2*5 provides 2 extra sockets.  using 1 quantity is worth .5 sockets
    assertEquals(1, bestPools.size());
    PoolQuantity q = bestPools.get(0);
    assertEquals(new Integer(3), q.getQuantity());
}
Also used : PoolQuantity(org.candlepin.model.PoolQuantity) Pool(org.candlepin.model.Pool) Test(org.junit.Test)

Example 65 with PoolQuantity

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

the class AutobindRulesTest method testPoolQuantityCompareDiffPool.

@Test
public void testPoolQuantityCompareDiffPool() {
    Product prod = mockProduct(productId, "some prod", "2");
    Pool pool1 = TestUtil.createPool(owner, prod, 10);
    pool1.setId("1234");
    Pool pool2 = TestUtil.createPool(owner, prod, 10);
    pool2.setId("4321");
    PoolQuantity pq1 = new PoolQuantity(pool1, 5);
    PoolQuantity pq2 = new PoolQuantity(pool2, 5);
    assertTrue(pq1.compareTo(pq2) != 0);
    assertEquals(pq1.compareTo(pq2), -pq2.compareTo(pq1));
}
Also used : PoolQuantity(org.candlepin.model.PoolQuantity) Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) Test(org.junit.Test)

Aggregations

PoolQuantity (org.candlepin.model.PoolQuantity)75 Pool (org.candlepin.model.Pool)65 Test (org.junit.Test)52 Entitlement (org.candlepin.model.Entitlement)34 LinkedList (java.util.LinkedList)30 Product (org.candlepin.model.Product)28 HashMap (java.util.HashMap)27 ArrayList (java.util.ArrayList)21 Consumer (org.candlepin.model.Consumer)12 List (java.util.List)11 ConsumerType (org.candlepin.model.ConsumerType)11 Matchers.anyString (org.mockito.Matchers.anyString)11 Date (java.util.Date)8 Set (java.util.Set)8 HashSet (java.util.HashSet)7 EntitlementRefusedException (org.candlepin.policy.EntitlementRefusedException)7 ValidationResult (org.candlepin.policy.ValidationResult)7 Subscription (org.candlepin.model.dto.Subscription)6 Matchers.anyLong (org.mockito.Matchers.anyLong)6 PoolFilterBuilder (org.candlepin.model.PoolFilterBuilder)5