@Test(groups = "integration") public void testUnauthorizedException() throws Exception { final String subdomain = System.getProperty(KILLBILL_PAYMENT_RECURLY_SUBDOMAIN); RecurlyClient unauthorizedRecurlyClient = new RecurlyClient("invalid-api-key", subdomain); unauthorizedRecurlyClient.open(); try { unauthorizedRecurlyClient.getAccounts(); Assert.fail("getAccounts call should not succeed with invalid credentials."); } catch (RecurlyAPIException expected) { Assert.assertEquals(expected.getRecurlyError().getSymbol(), "unauthorized"); } }
@Test(groups = "integration") public void testUnauthorizedException() throws Exception { final String subdomain = System.getProperty(KILLBILL_PAYMENT_RECURLY_SUBDOMAIN); RecurlyClient unauthorizedRecurlyClient = new RecurlyClient("invalid-api-key", subdomain); unauthorizedRecurlyClient.open(); try { unauthorizedRecurlyClient.getAccounts(); Assert.fail("getAccounts call should not succeed with invalid credentials."); } catch (RecurlyAPIException expected) { Assert.assertEquals(expected.getRecurlyError().getSymbol(), "unauthorized"); } }
@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"); }
final Accounts retrievedAccounts = recurlyClient.getAccounts(); Assert.assertTrue(retrievedAccounts.size() > 0);
final Accounts retrievedAccounts = recurlyClient.getAccounts(); Assert.assertTrue(retrievedAccounts.size() > 0);