/** One subscription only, created in last billing period. */ @Test public void getSubscriptionsForCustomeroneSubscriptionlastPeriod() throws Exception { // given createSubscriptionHistory( 10L, "2012-09-01 15:10:42", 0, ModificationType.ADD, SubscriptionStatus.ACTIVE); // when CustomerData billingInput = runTX( new Callable<CustomerData>() { @Override public CustomerData call() throws Exception { return new CustomerData( bdr.loadSubscriptionsForCustomer( CUSTOMER_ORGANIZTION_KEY, new SimpleDateFormat(DATE_PATTERN).parse("2012-10-01 00:00:00").getTime(), new SimpleDateFormat(DATE_PATTERN).parse("2012-11-01 00:00:00").getTime(), -1)); } }); // then assertEquals(1, billingInput.getSubscriptionKeys().size()); long subscriptionKey = billingInput.getSubscriptionKeys().get(0).longValue(); assertEquals(1, billingInput.getSubscriptionHistoryEntries(subscriptionKey).size()); assertEquals( SUBPRX + "10", billingInput .getSubscriptionHistoryEntries(subscriptionKey) .get(0) .getDataContainer() .getSubscriptionId()); }
/** * * * <ul> * <li>one subscription deactivated in last period * <li>one created and modified in last period * <li>one created in last period and modified in current period * <li>one created and modified in current period * </ul> */ @Test public void getSubscriptionsForCustomercomplex() throws Exception { // given givenDeactivatedSubsriptionInLastPeriod(); givenSubscriptionModifiedInLastPeriod(); givenModifiedSubscriptionFromLastPeriod(); givenModifiedSubscriptionFromCurrentPeriod(); // when CustomerData billingInput = runTX( new Callable<CustomerData>() { @Override public CustomerData call() throws Exception { return new CustomerData( bdr.loadSubscriptionsForCustomer( CUSTOMER_ORGANIZTION_KEY, new SimpleDateFormat(DATE_PATTERN).parse("2012-10-01 00:00:00").getTime(), new SimpleDateFormat(DATE_PATTERN).parse("2012-11-01 00:00:00").getTime(), -1)); } }); // then assertEquals(4, billingInput.getSubscriptionKeys().size()); long subscriptionKey0 = billingInput.getSubscriptionKeys().get(0).longValue(); assertEquals( SUBPRX + "11", billingInput .getSubscriptionHistoryEntries(subscriptionKey0) .get(0) .getDataContainer() .getSubscriptionId()); assertEquals( 1, billingInput.getSubscriptionHistoryEntries(subscriptionKey0).get(0).getObjVersion()); // givenSubscriptionModifiedInLastPeriod long subscriptionKey1 = billingInput.getSubscriptionKeys().get(1).longValue(); assertEquals(3, billingInput.getSubscriptionHistoryEntries(subscriptionKey1).size()); assertEquals( SUBPRX + "12", billingInput .getSubscriptionHistoryEntries(subscriptionKey1) .get(0) .getDataContainer() .getSubscriptionId()); assertEquals( 2, billingInput.getSubscriptionHistoryEntries(subscriptionKey1).get(0).getObjVersion()); // givenModifiedSubscriptionFromLastPeriod long subscriptionKey2 = billingInput.getSubscriptionKeys().get(2).longValue(); assertEquals(3, billingInput.getSubscriptionHistoryEntries(subscriptionKey2).size()); assertEquals( SUBPRX + "13", billingInput .getSubscriptionHistoryEntries(subscriptionKey2) .get(0) .getDataContainer() .getSubscriptionId()); assertEquals( 2, billingInput.getSubscriptionHistoryEntries(subscriptionKey2).get(0).getObjVersion()); assertEquals( 1, billingInput.getSubscriptionHistoryEntries(subscriptionKey2).get(1).getObjVersion()); // givenModifiedSubscriptionFromCurrentPeriod long subscriptionKey3 = billingInput.getSubscriptionKeys().get(3).longValue(); assertEquals(2, billingInput.getSubscriptionHistoryEntries(subscriptionKey3).size()); assertEquals( SUBPRX + "14", billingInput .getSubscriptionHistoryEntries(subscriptionKey3) .get(0) .getDataContainer() .getSubscriptionId()); assertEquals( 1, billingInput.getSubscriptionHistoryEntries(subscriptionKey3).get(0).getObjVersion()); assertEquals( 0, billingInput.getSubscriptionHistoryEntries(subscriptionKey3).get(1).getObjVersion()); }