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());
}
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());
}
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());
}
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());
}
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));
}
Aggregations