Search in sources :

Example 66 with Subscription

use of org.candlepin.model.dto.Subscription in project candlepin by candlepin.

the class SubscriptionReconcilerTest method testMultiPools.

@Test
public void testMultiPools() {
    Subscription testSub1 = createSubscription(owner, "test-prod-1", "up1", "ue1", "uc1", 25);
    Subscription testSub2 = createSubscription(owner, "test-prod-1", "up1", "ue2", "uc1", 20);
    Subscription testSub3 = createSubscription(owner, "test-prod-1", "up1", "ue3", "uc1", 15);
    Subscription testSub4 = createSubscription(owner, "test-prod-1", "up1", "ue4", "uc1", 10);
    Subscription testSub5 = createSubscription(owner, "test-prod-1", "up1", "ue5", "uc1", 5);
    Subscription testSub20 = createSubscription(owner, "test-prod-1", "up2", "ue20", "uc1", 25);
    Subscription testSub21 = createSubscription(owner, "test-prod-1", "up2", "ue21", "uc1", 20);
    Subscription testSub22 = createSubscription(owner, "test-prod-1", "up2", "ue22", "uc1", 15);
    Subscription testSub24 = createSubscription(owner, "test-prod-1", "up2", "ue24", "uc1", 5);
    Subscription testSub30 = createSubscription(owner, "test-prod-1", "up3", "ue30", "uc1", 25);
    Subscription testSub31 = createSubscription(owner, "test-prod-1", "up3", "ue31", "uc1", 20);
    Subscription testSub32 = createSubscription(owner, "test-prod-1", "up3", "ue32", "uc1", 15);
    Subscription testSub33 = createSubscription(owner, "test-prod-1", "up3", "ue33", "uc1", 10);
    Subscription testSub34 = createSubscription(owner, "test-prod-1", "up3", "ue34", "uc1", 5);
    createPoolsFor(testSub1, testSub2, testSub3, testSub4, testSub5, testSub20, testSub21, testSub22, testSub24);
    reconciler.reconcile(owner, Arrays.asList(testSub1, testSub2, testSub3, testSub4, testSub5, testSub30, testSub31, testSub32, testSub33, testSub34));
    // 20-24 have no matchup with 30-34 due to different upstream pool ID:
    assertUpstream(testSub1, testSub1.getId());
    assertUpstream(testSub2, testSub2.getId());
    assertUpstream(testSub3, testSub3.getId());
    assertUpstream(testSub4, testSub4.getId());
    assertUpstream(testSub5, testSub5.getId());
    assertUpstream(testSub30, testSub30.getId());
    assertUpstream(testSub31, testSub31.getId());
    assertUpstream(testSub32, testSub32.getId());
    assertUpstream(testSub33, testSub33.getId());
    assertUpstream(testSub34, testSub34.getId());
}
Also used : Subscription(org.candlepin.model.dto.Subscription) Test(org.junit.Test)

Example 67 with Subscription

use of org.candlepin.model.dto.Subscription in project candlepin by candlepin.

the class SubscriptionReconcilerTest method testTwoExistOneRemoved.

@Test
public void testTwoExistOneRemoved() {
    Subscription testSub2 = createSubscription(owner, "test-prod-1", "up1", "ue2", "uc1", 20);
    Subscription testSub3 = createSubscription(owner, "test-prod-1", "up1", "ue3", "uc1", 15);
    createPoolsFor(testSub2, testSub3);
    reconciler.reconcile(owner, Arrays.asList(testSub3));
    assertUpstream(testSub3, testSub3.getId());
}
Also used : Subscription(org.candlepin.model.dto.Subscription) Test(org.junit.Test)

Example 68 with Subscription

use of org.candlepin.model.dto.Subscription in project candlepin by candlepin.

the class SubscriptionReconcilerTest method createPoolsFor.

/*
     * Creates a pool with the properties of each incoming subscription. This is partially
     * being used due to the original test suite comparing existing local subscriptions
     * to incoming subscriptions. Today we don't have local subscriptions, only the
     * master pools they created.
     *
     * TODO: Might be worth switching from copying data of a subscription to just creating
     * the local pool with params.
     */
private List<Pool> createPoolsFor(Subscription... subs) {
    List<Pool> pools = new LinkedList<>();
    for (Subscription sub : subs) {
        pools.add(TestUtil.copyFromSub(sub));
    }
    // Mock these pools as the return value for the owner:
    CandlepinQuery<Pool> cqmock = mock(CandlepinQuery.class);
    when(cqmock.list()).thenReturn(pools);
    when(cqmock.iterator()).thenReturn(pools.iterator());
    when(poolCurator.listByOwnerAndType(owner, PoolType.NORMAL)).thenReturn(cqmock);
    return pools;
}
Also used : Pool(org.candlepin.model.Pool) Subscription(org.candlepin.model.dto.Subscription) LinkedList(java.util.LinkedList)

Example 69 with Subscription

use of org.candlepin.model.dto.Subscription in project candlepin by candlepin.

the class SubscriptionReconcilerTest method testThreeExistOldThreeNew.

@Test
public void testThreeExistOldThreeNew() {
    Subscription testSub3 = createSubscription(owner, "test-prod-1", "up1", "ue3", "uc1", 15);
    Subscription testSub4 = createSubscription(owner, "test-prod-1", "up1", "ue4", "uc1", 10);
    Subscription testSub5 = createSubscription(owner, "test-prod-1", "up1", "ue5", "uc1", 5);
    Subscription testSub9 = createSubscription(owner, "test-prod-1", "up1", "", "", 15);
    Subscription testSub10 = createSubscription(owner, "test-prod-1", "up1", "", "", 10);
    Subscription testSub11 = createSubscription(owner, "test-prod-1", "up1", "", "", 5);
    createPoolsFor(testSub9, testSub10, testSub11);
    reconciler.reconcile(owner, Arrays.asList(testSub3, testSub4, testSub5));
    assertUpstream(testSub3, testSub9.getId());
    assertUpstream(testSub4, testSub10.getId());
    assertUpstream(testSub5, testSub11.getId());
}
Also used : Subscription(org.candlepin.model.dto.Subscription) Test(org.junit.Test)

Example 70 with Subscription

use of org.candlepin.model.dto.Subscription in project candlepin by candlepin.

the class SubscriptionReconcilerTest method testQuantMatchAllSame.

@Test
public void testQuantMatchAllSame() {
    Subscription testSub3 = createSubscription(owner, "test-prod-1", "up1", "ue3", "uc1", 15);
    Subscription testSub15 = createSubscription(owner, "test-prod-1", "up1", "ue15", "uc1", 15);
    Subscription testSub16 = createSubscription(owner, "test-prod-1", "up1", "ue16", "uc1", 15);
    createPoolsFor(testSub3, testSub15);
    reconciler.reconcile(owner, Arrays.asList(testSub3, testSub16));
    // Quantities 25, 20, 15 should be replaced by new pools with 23, 17, 10:
    assertUpstream(testSub3, testSub3.getId());
    assertUpstream(testSub16, testSub15.getId());
}
Also used : Subscription(org.candlepin.model.dto.Subscription) Test(org.junit.Test)

Aggregations

Subscription (org.candlepin.model.dto.Subscription)101 Test (org.junit.Test)77 Pool (org.candlepin.model.Pool)60 Product (org.candlepin.model.Product)48 SourceSubscription (org.candlepin.model.SourceSubscription)36 LinkedList (java.util.LinkedList)35 ArrayList (java.util.ArrayList)34 Owner (org.candlepin.model.Owner)33 ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)27 HashMap (java.util.HashMap)20 HashSet (java.util.HashSet)18 Matchers.anyString (org.mockito.Matchers.anyString)18 Entitlement (org.candlepin.model.Entitlement)16 Date (java.util.Date)15 PoolType (org.candlepin.model.Pool.PoolType)13 ImportSubscriptionServiceAdapter (org.candlepin.service.impl.ImportSubscriptionServiceAdapter)13 List (java.util.List)11 OwnerServiceAdapter (org.candlepin.service.OwnerServiceAdapter)11 ConsumerType (org.candlepin.model.ConsumerType)10 ProductData (org.candlepin.model.dto.ProductData)9