@Override public String toString() { final StringBuilder sb = new StringBuilder("AccountNote{"); sb.append("account=").append(account.getAccountCode()); sb.append(", message=").append(message); sb.append(", createdAt=").append(createdAt); sb.append('}'); return sb.toString(); }
private void verifyPaginationData(final Subscription subscription) { // Verify nested attributes Assert.assertEquals(subscription.getAccount().getHref(), "https://api.recurly.com/v2/accounts/1"); Assert.assertEquals(subscription.getAccount().getAccountCode(), "1"); }
private void verifyPaginationData(final Subscription subscription) { // Verify nested attributes Assert.assertEquals(subscription.getAccount().getHref(), "https://api.recurly.com/v2/accounts/1"); Assert.assertEquals(subscription.getAccount().getAccountCode(), "1"); }
private void testAccountNotification(final AccountNotification accountNotification) { final Account account = accountNotification.getAccount(); Assert.assertNotNull(account); Assert.assertEquals(account.getAccountCode(), "1"); Assert.assertNull(account.getUsername()); Assert.assertEquals(account.getEmail(), "verena@example.com"); Assert.assertEquals(account.getFirstName(), "Verena"); Assert.assertEquals(account.getLastName(), "Example"); Assert.assertNull(account.getCompanyName()); }
private void testAccountNotification(final AccountNotification accountNotification) { final Account account = accountNotification.getAccount(); Assert.assertNotNull(account); Assert.assertEquals(account.getAccountCode(), "1"); Assert.assertNull(account.getUsername()); Assert.assertEquals(account.getEmail(), "verena@example.com"); Assert.assertEquals(account.getFirstName(), "Verena"); Assert.assertEquals(account.getLastName(), "Example"); Assert.assertNull(account.getCompanyName()); }
@Test(groups = "integration") public void testPagination() throws Exception { System.setProperty(RECURLY_PAGE_SIZE, "1"); final int minNumberOfAccounts = 5; for (int i = 0; i < minNumberOfAccounts; i++) { final Account accountData = TestUtils.createRandomAccount(); recurlyClient.createAccount(accountData); } final Set<String> accountCodes = new HashSet<String>(); Accounts accounts = recurlyClient.getAccounts(); for (int i = 0; i < minNumberOfAccounts; i++) { // If the environment is used, we will have more than the ones we created Assert.assertEquals(accounts.size(), 1); accountCodes.add(accounts.get(0).getAccountCode()); if (i < minNumberOfAccounts - 1) { accounts = accounts.getNext(); } } Assert.assertEquals(accountCodes.size(), minNumberOfAccounts); System.setProperty(RECURLY_PAGE_SIZE, "50"); }
@Test(groups = "integration") public void testPagination() throws Exception { System.setProperty(RECURLY_PAGE_SIZE, "1"); final int minNumberOfAccounts = 5; for (int i = 0; i < minNumberOfAccounts; i++) { final Account accountData = TestUtils.createRandomAccount(); recurlyClient.createAccount(accountData); } final Set<String> accountCodes = new HashSet<String>(); Accounts accounts = recurlyClient.getAccounts(); for (int i = 0; i < minNumberOfAccounts; i++) { // If the environment is used, we will have more than the ones we created Assert.assertEquals(accounts.size(), 1); accountCodes.add(accounts.get(0).getAccountCode()); if (i < minNumberOfAccounts - 1) { accounts = accounts.getNext(); } } Assert.assertEquals(accountCodes.size(), minNumberOfAccounts); System.setProperty(RECURLY_PAGE_SIZE, "50"); }
@Test(groups = "integration", description = "See https://github.com/killbilling/recurly-java-library/issues/21") public void testGetEmptySubscriptions() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); try { // Create a user final Account account = recurlyClient.createAccount(accountData); // Create BillingInfo billingInfoData.setAccount(account); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); Assert.assertNotNull(billingInfo); final BillingInfo retrievedBillingInfo = recurlyClient.getBillingInfo(account.getAccountCode()); Assert.assertNotNull(retrievedBillingInfo); final Subscriptions subs = recurlyClient.getAccountSubscriptions(accountData.getAccountCode(), "active"); Assert.assertEquals(subs.size(), 0); } finally { // Close the account recurlyClient.closeAccount(accountData.getAccountCode()); } }
@Test(groups = "integration", description = "See https://github.com/killbilling/recurly-java-library/issues/21") public void testGetEmptySubscriptions() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); try { // Create a user final Account account = recurlyClient.createAccount(accountData); // Create BillingInfo billingInfoData.setAccount(account); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); Assert.assertNotNull(billingInfo); final BillingInfo retrievedBillingInfo = recurlyClient.getBillingInfo(account.getAccountCode()); Assert.assertNotNull(retrievedBillingInfo); final Subscriptions subs = recurlyClient.getAccountSubscriptions(accountData.getAccountCode(), "active"); Assert.assertEquals(subs.size(), 0); } finally { // Close the account recurlyClient.closeAccount(accountData.getAccountCode()); } }
@Test(groups = "integration") public void testGetBillingInfo() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); billingInfoData.setAccount(null); // need to null out test account accountData.setBillingInfo(billingInfoData); try { // Create account and fetch billing info final Account account = recurlyClient.createAccount(accountData); final BillingInfo retrievedBillingInfo = recurlyClient.getBillingInfo(account.getAccountCode()); Assert.assertNotNull(retrievedBillingInfo); Assert.assertEquals(retrievedBillingInfo.getType(), "credit_card"); } finally { // Close the account recurlyClient.closeAccount(accountData.getAccountCode()); } }
@Test(groups = "integration") public void testGetBillingInfo() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); billingInfoData.setAccount(null); // need to null out test account accountData.setBillingInfo(billingInfoData); try { // Create account and fetch billing info final Account account = recurlyClient.createAccount(accountData); final BillingInfo retrievedBillingInfo = recurlyClient.getBillingInfo(account.getAccountCode()); Assert.assertNotNull(retrievedBillingInfo); Assert.assertEquals(retrievedBillingInfo.getType(), "credit_card"); } finally { // Close the account recurlyClient.closeAccount(accountData.getAccountCode()); } }
@Test(groups = "integration") public void testGetAccountBalance() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); try { final Account account = recurlyClient.createAccount(accountData); // Create BillingInfo billingInfoData.setAccount(account); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); Assert.assertNotNull(billingInfo); final BillingInfo retrievedBillingInfo = recurlyClient.getBillingInfo(account.getAccountCode()); Assert.assertNotNull(retrievedBillingInfo); final Adjustment adjustment = new Adjustment(); adjustment.setUnitAmountInCents(150); adjustment.setCurrency(CURRENCY); recurlyClient.createAccountAdjustment(account.getAccountCode(), adjustment); final AccountBalance balance = recurlyClient.getAccountBalance(account.getAccountCode()); Assert.assertEquals(balance.getBalanceInCents().getUnitAmountUSD(), new Integer(150)); Assert.assertEquals(balance.getPastDue(), Boolean.FALSE); } finally { // Clean up recurlyClient.clearBillingInfo(accountData.getAccountCode()); recurlyClient.closeAccount(accountData.getAccountCode()); } }
@Test(groups = "integration") public void testRedeemGiftCardOnAccount() throws Exception { final GiftCard giftCardData = TestUtils.createRandomGiftCard(); // Purchase a gift card final GiftCard giftCard = recurlyClient.purchaseGiftCard(giftCardData); Assert.assertEquals(giftCard.getProductCode(), giftCardData.getProductCode()); Assert.assertNull(giftCard.getRedeemedAt()); // Let's redeem on an account final Account gifterAccount = giftCard.getGifterAccount(); Assert.assertNotNull(gifterAccount); final String redemptionCode = giftCard.getRedemptionCode(); final String gifterAccountCode = gifterAccount.getAccountCode(); final GiftCard redeemedCard = recurlyClient.redeemGiftCard(redemptionCode, gifterAccountCode); Assert.assertNotNull(redeemedCard.getRedeemedAt()); }
@Test(groups = "integration") public void testRedeemGiftCardOnAccount() throws Exception { final GiftCard giftCardData = TestUtils.createRandomGiftCard(); // Purchase a gift card final GiftCard giftCard = recurlyClient.purchaseGiftCard(giftCardData); Assert.assertEquals(giftCard.getProductCode(), giftCardData.getProductCode()); Assert.assertNull(giftCard.getRedeemedAt()); // Let's redeem on an account final Account gifterAccount = giftCard.getGifterAccount(); Assert.assertNotNull(gifterAccount); final String redemptionCode = giftCard.getRedemptionCode(); final String gifterAccountCode = gifterAccount.getAccountCode(); final GiftCard redeemedCard = recurlyClient.redeemGiftCard(redemptionCode, gifterAccountCode); Assert.assertNotNull(redeemedCard.getRedeemedAt()); }
private void verifyAccount(final Account account) { Assert.assertEquals(account.getAccountCode(), "1"); Assert.assertEquals(account.getState(), "active"); Assert.assertNull(account.getUsername()); Assert.assertEquals(account.getEmail(), "verena@example.com"); Assert.assertEquals(account.getFirstName(), "Verena"); Assert.assertEquals(account.getLastName(), "Example"); Assert.assertNull(account.getAcceptLanguage()); Assert.assertEquals(account.getHostedLoginToken(), "a92468579e9c4231a6c0031c4716c01d"); Assert.assertEquals(account.getCreatedAt(), new DateTime("2011-10-25T12:00:00")); Assert.assertEquals(account.getUpdatedAt(), new DateTime("2011-10-25T12:00:00")); Assert.assertEquals(account.getAddress().getAddress1(), "123 Main St."); Assert.assertNull(account.getAddress().getAddress2()); Assert.assertEquals(account.getAddress().getCity(), "San Francisco"); Assert.assertEquals(account.getAddress().getState(), "CA"); Assert.assertEquals(account.getAddress().getZip(), "94105-1804"); Assert.assertEquals(account.getAddress().getCountry(), "US"); Assert.assertFalse(account.getTaxExempt()); Assert.assertEquals(account.getExemptionCertificate(), "Some Certificate"); Assert.assertNull(account.getAddress().getPhone()); Assert.assertEquals(account.getCustomFields(), getTestFields()); Assert.assertTrue(account.getHasLiveSubscription()); Assert.assertTrue(account.getHasActiveSubscription()); Assert.assertFalse(account.getHasFutureSubscription()); Assert.assertFalse(account.getHasCanceledSubscription()); Assert.assertFalse(account.getHasPastDueInvoice()); Assert.assertEquals(account.getVatNumber(), "U12345678"); }
@Test(groups = "integration") public void testShippingAddressesOnAccount() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final ShippingAddress shippingAddress1 = TestUtils.createRandomShippingAddress(); final ShippingAddress shippingAddress2 = TestUtils.createRandomShippingAddress(); final ShippingAddresses shippingAddressesData = new ShippingAddresses(); try { shippingAddressesData.add(shippingAddress1); shippingAddressesData.add(shippingAddress2); accountData.setShippingAddresses(shippingAddressesData); final Account account = recurlyClient.createAccount(accountData); ShippingAddresses shippingAddresses = recurlyClient.getAccountShippingAddresses(account.getAccountCode()); Assert.assertEquals(shippingAddresses.size(), 2); } finally { recurlyClient.closeAccount(accountData.getAccountCode()); } }
@Test(groups = "integration") public void testShippingAddressesOnAccount() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final ShippingAddress shippingAddress1 = TestUtils.createRandomShippingAddress(); final ShippingAddress shippingAddress2 = TestUtils.createRandomShippingAddress(); final ShippingAddresses shippingAddressesData = new ShippingAddresses(); try { shippingAddressesData.add(shippingAddress1); shippingAddressesData.add(shippingAddress2); accountData.setShippingAddresses(shippingAddressesData); final Account account = recurlyClient.createAccount(accountData); ShippingAddresses shippingAddresses = recurlyClient.getAccountShippingAddresses(account.getAccountCode()); Assert.assertEquals(shippingAddresses.size(), 2); } finally { recurlyClient.closeAccount(accountData.getAccountCode()); } }
@Test(groups = "integration") public void testGetSiteSubscriptions() throws Exception { final Account accountData = TestUtils.createRandomAccount(); final BillingInfo billingInfoData = TestUtils.createRandomBillingInfo(); final Plan planData = TestUtils.createRandomPlan(); try { final Account account = recurlyClient.createAccount(accountData); billingInfoData.setAccount(account); final BillingInfo billingInfo = recurlyClient.createOrUpdateBillingInfo(billingInfoData); final Plan plan = recurlyClient.createPlan(planData); final Subscription subscriptionData = new Subscription(); subscriptionData.setPlanCode(plan.getPlanCode()); subscriptionData.setAccount(accountData); subscriptionData.setCurrency(CURRENCY); subscriptionData.setUnitAmountInCents(1242); subscriptionData.setRemainingBillingCycles(1); // makes sure we have at least one subscription recurlyClient.createSubscription(subscriptionData); // make sure we return more than one subscription Assert.assertTrue(recurlyClient.getSubscriptions().size() > 0); } finally { // Close the account recurlyClient.closeAccount(accountData.getAccountCode()); } }
/** * Creates a random {@link Redemption} object for use in Tests given a seed * * @param seed The RNG seed * @return The random {@link Redemption} object */ public static Redemption createRandomRedemption(final int seed) { final Redemption redemption = new Redemption(); final Account account = createRandomAccount(seed); redemption.setAccount(account); redemption.setAccountCode(account.getAccountCode()); redemption.setSubscriptionUuid(randomAlphaNumericString(10, seed)); redemption.setCoupon(createRandomCoupon(seed)); redemption.setSingleUse(true); redemption.setState("redeemed"); redemption.setCurrency(randomCurrency(seed)); redemption.setTotalDiscountedInCents(randomInteger(1000, seed)); return redemption; }
/** * Creates a random {@link Redemption} object for use in Tests given a seed * * @param seed The RNG seed * @return The random {@link Redemption} object */ public static Redemption createRandomRedemption(final int seed) { final Redemption redemption = new Redemption(); final Account account = createRandomAccount(seed); redemption.setAccount(account); redemption.setAccountCode(account.getAccountCode()); redemption.setSubscriptionUuid(randomAlphaNumericString(10, seed)); redemption.setCoupon(createRandomCoupon(seed)); redemption.setSingleUse(true); redemption.setState("redeemed"); redemption.setCurrency(randomCurrency(seed)); redemption.setTotalDiscountedInCents(randomInteger(1000, seed)); return redemption; }