Skip to content

Commit

Permalink
[DE-578] Subscription components 1 review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej-nedza committed Dec 14, 2023
1 parent 1168d2b commit bbc043f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static void setup() throws IOException, ApiException {
prepaidComponent = TEST_SETUP.createPrepaidComponent(productFamily, 1.0);

customer = TEST_SETUP.createCustomer();
subscription = TEST_SETUP.createSubscription(product.getId(), customer.getId());
subscription = TEST_SETUP.createSubscription(customer, product);
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static void setup() throws IOException, ApiException {
component3 = TEST_SETUP.createMeteredComponent(productFamily, 1.0);

customer = TEST_SETUP.createCustomer();
subscription = TEST_SETUP.createSubscription(product.getId(), customer.getId());
subscription = TEST_SETUP.createSubscription(customer, product);

// looks like list components for site might have some caching which can be invalidated by calling this endpoint first.
SUBSCRIPTION_COMPONENTS_CONTROLLER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static void setup() throws IOException, ApiException {
component3 = TEST_SETUP.createMeteredComponent(productFamily, 1.0);

customer = TEST_SETUP.createCustomer();
subscription = TEST_SETUP.createSubscription(product.getId(), customer.getId());
subscription = TEST_SETUP.createSubscription(customer, product);
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void setup() throws IOException, ApiException {
meteredComponent = TEST_SETUP.createMeteredComponent(productFamily, 1.0);

customer = TEST_SETUP.createCustomer();
subscription = TEST_SETUP.createSubscription(product.getId(), customer.getId());
subscription = TEST_SETUP.createSubscription(customer, product);

usage1 = SUBSCRIPTION_COMPONENTS_CONTROLLER.createUsage(subscription.getId(),
CreateUsageComponentId.fromNumber(meteredComponent.getId()),
Expand Down Expand Up @@ -94,9 +94,9 @@ void shouldListUsages() throws IOException, ApiException {

// then
assertThat(usages.size()).isEqualTo(3);
assertUsage(usage1, meteredComponent, subscription,10, "created usage");
assertUsage(usage2, meteredComponent, subscription,50, "created usage 2");
assertUsage(usage3, meteredComponent, subscription,22, "created usage 3");
assertUsage(usage1, meteredComponent, subscription, 10, "created usage");
assertUsage(usage2, meteredComponent, subscription, 50, "created usage 2");
assertUsage(usage3, meteredComponent, subscription, 22, "created usage 3");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static void setup() throws IOException, ApiException {
Product product = TEST_SETUP.createProduct(productFamily);
component = TEST_SETUP.createQuantityBasedComponent(productFamily.getId());
customer = TEST_SETUP.createCustomer();
subscription = TEST_SETUP.createSubscription(product.getId(), customer.getId());
subscription = TEST_SETUP.createSubscription(customer, product);
}

@AfterAll
Expand Down
18 changes: 0 additions & 18 deletions tests/src/test/java/com/maxio/advancedbilling/utils/TestSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,24 +232,6 @@ public Coupon createPercentageCoupon(ProductFamily productFamily, String percent
.getCoupon();
}

public Subscription createSubscription(int productId, int customerId) throws IOException, ApiException {
return advancedBillingClient.getSubscriptionsController()
.createSubscription(
new CreateSubscriptionRequest(
new CreateSubscription.Builder()
.productId(productId)
.customerId(customerId)
.creditCardAttributes(
new PaymentProfileAttributes.Builder()
.expirationMonth(PaymentProfileAttributesExpirationMonth.fromNumber(12))
.expirationYear(PaymentProfileAttributesExpirationYear.fromNumber(2024))
.fullNumber("1")
.build()
)
.build()
)
).getSubscription();
}
public ComponentPricePoint createPricePointForComponent(int componentId, double unitPrice) throws IOException, ApiException {
String name = "Price Point " + randomNumeric(5);
String handle = name.toLowerCase().replace(" ", "-");
Expand Down

0 comments on commit bbc043f

Please sign in to comment.