Search in sources :

Example 6 with Subscription

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

the class SubscriptionReconcilerTest method oneExistsUnchanged.

@Test
public void oneExistsUnchanged() {
    Subscription testSub1 = createSubscription(owner, "test-prod-1", "up1", "ue1", "uc1", 25);
    createPoolsFor(testSub1);
    reconciler.reconcile(owner, Arrays.asList(testSub1));
    assertUpstream(testSub1, testSub1.getId());
}
Also used : Subscription(org.candlepin.model.dto.Subscription) Test(org.junit.Test)

Example 7 with Subscription

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

the class SubscriptionReconcilerTest method testThreeExistThreeNewSameQuantitiesNewConsumer.

@Test
public void testThreeExistThreeNewSameQuantitiesNewConsumer() {
    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 testSub6 = createSubscription(owner, "test-prod-1", "up1", "ue6", "uc2", 15);
    Subscription testSub7 = createSubscription(owner, "test-prod-1", "up1", "ue7", "uc2", 10);
    Subscription testSub8 = createSubscription(owner, "test-prod-1", "up1", "ue8", "uc2", 5);
    createPoolsFor(testSub3, testSub4, testSub5);
    reconciler.reconcile(owner, Arrays.asList(testSub6, testSub7, testSub8));
    assertUpstream(testSub6, testSub3.getId());
    assertUpstream(testSub7, testSub4.getId());
    assertUpstream(testSub8, testSub5.getId());
}
Also used : Subscription(org.candlepin.model.dto.Subscription) Test(org.junit.Test)

Example 8 with Subscription

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

the class SubscriptionReconcilerTest method testThreeExistTwoNewQuantityMatchNewConsumer.

@Test
public void testThreeExistTwoNewQuantityMatchNewConsumer() {
    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 testSub6 = createSubscription(owner, "test-prod-1", "up1", "ue6", "uc2", 15);
    Subscription testSub8 = createSubscription(owner, "test-prod-1", "up1", "ue8", "uc2", 5);
    createPoolsFor(testSub3, testSub4, testSub5);
    reconciler.reconcile(owner, Arrays.asList(testSub6, testSub8));
    assertUpstream(testSub6, testSub3.getId());
    assertUpstream(testSub8, testSub5.getId());
}
Also used : Subscription(org.candlepin.model.dto.Subscription) Test(org.junit.Test)

Example 9 with Subscription

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

the class SubscriptionReconcilerTest method testQuantMatchMix.

@Test
public void testQuantMatchMix() {
    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 testSub12 = createSubscription(owner, "test-prod-1", "up1", "ue12", "uc3", 23);
    Subscription testSub14 = createSubscription(owner, "test-prod-1", "up1", "ue14", "uc3", 10);
    createPoolsFor(testSub2, testSub3, testSub4, testSub5);
    reconciler.reconcile(owner, Arrays.asList(testSub12, testSub14));
    assertUpstream(testSub12, testSub2.getId());
    assertUpstream(testSub14, testSub4.getId());
}
Also used : Subscription(org.candlepin.model.dto.Subscription) Test(org.junit.Test)

Example 10 with Subscription

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

the class OwnerResourceTest method testRefreshPoolsWithRemovedSubscriptions.

@Test
public void testRefreshPoolsWithRemovedSubscriptions() {
    Product prod = this.createProduct(owner);
    List<Subscription> subscriptions = new LinkedList<>();
    ImportSubscriptionServiceAdapter subAdapter = new ImportSubscriptionServiceAdapter(subscriptions);
    OwnerServiceAdapter ownerAdapter = new DefaultOwnerServiceAdapter(this.ownerCurator, this.i18n);
    Subscription sub = TestUtil.createSubscription(owner, prod, new HashSet<>());
    sub.setId(Util.generateDbUUID());
    sub.setQuantity(2000L);
    sub.setStartDate(TestUtil.createDate(2010, 2, 9));
    sub.setEndDate(TestUtil.createDate(3000, 2, 9));
    sub.setModified(TestUtil.createDate(2010, 2, 12));
    // This line is only present as a result of a (temporary?) fix for BZ 1452694. Once a
    // better fix has been implemented, the upstream pool ID can be removed.
    sub.setUpstreamPoolId("upstream_pool_id");
    subscriptions.add(sub);
    // Trigger the refresh:
    poolManager.getRefresher(subAdapter, ownerAdapter).add(owner).run();
    List<Pool> pools = poolCurator.listByOwnerAndProduct(owner, prod.getId());
    assertEquals(1, pools.size());
    Pool newPool = pools.get(0);
    String poolId = newPool.getId();
    // Now delete the subscription:
    subscriptions.remove(sub);
    // Trigger the refresh:
    poolManager.getRefresher(subAdapter, ownerAdapter).add(owner).run();
    assertNull("Pool not having subscription should have been deleted", poolCurator.find(poolId));
}
Also used : ImportSubscriptionServiceAdapter(org.candlepin.service.impl.ImportSubscriptionServiceAdapter) OwnerServiceAdapter(org.candlepin.service.OwnerServiceAdapter) DefaultOwnerServiceAdapter(org.candlepin.service.impl.DefaultOwnerServiceAdapter) Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) Matchers.anyString(org.mockito.Matchers.anyString) Subscription(org.candlepin.model.dto.Subscription) LinkedList(java.util.LinkedList) DefaultOwnerServiceAdapter(org.candlepin.service.impl.DefaultOwnerServiceAdapter) 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