From 90d068c9d2ae5ad7f89e94279ccf134d1772124f Mon Sep 17 00:00:00 2001 From: Vignesh Kennadi Date: Tue, 24 Sep 2024 11:45:24 +0530 Subject: [PATCH] adds config file and reference from config file --- .../api/client/AccountingApiAccountsTest.java | 15 ++++++++++++--- .../client/AccountingApiBankTransactionTest.java | 14 +++++++++++--- .../client/AccountingApiBankTransferTest.java | 14 +++++++++++--- .../client/AccountingApiBatchPaymentTest.java | 15 ++++++++++++--- .../client/AccountingApiBrandingThemeTest.java | 15 ++++++++++++--- .../client/AccountingApiContactGroupTest.java | 14 +++++++++++--- .../api/client/AccountingApiContactsTest.java | 14 +++++++++++--- .../api/client/AccountingApiCreditNotesTest.java | 13 +++++++++++-- .../api/client/AccountingApiEmployeesTest.java | 13 +++++++++++-- .../client/AccountingApiExpenseClaimsTest.java | 13 +++++++++++-- .../api/client/AccountingApiInvoicesTest.java | 13 +++++++++++-- .../xero/api/client/AccountingApiItemsTest.java | 13 +++++++++++-- .../api/client/AccountingApiJournalsTest.java | 13 +++++++++++-- .../AccountingApiLinkedTransactionsTest.java | 13 +++++++++++-- .../client/AccountingApiManualJournalsTest.java | 13 +++++++++++-- .../client/AccountingApiOrganisationsTest.java | 13 +++++++++++-- .../client/AccountingApiOverpaymentsTest.java | 13 +++++++++++-- .../client/AccountingApiPaymentServicesTest.java | 13 +++++++++++-- .../api/client/AccountingApiPaymentsTest.java | 13 +++++++++++-- .../api/client/AccountingApiPrepaymentsTest.java | 13 +++++++++++-- .../client/AccountingApiPurchaseOrdersTest.java | 13 +++++++++++-- .../xero/api/client/AccountingApiQuotesTest.java | 15 ++++++++++++--- .../api/client/AccountingApiReceiptsTest.java | 13 +++++++++++-- .../AccountingApiRepeatingInvoicesTest.java | 13 +++++++++++-- .../api/client/AccountingApiReportsTest.java | 13 +++++++++++-- .../api/client/AccountingApiTaxRatesTest.java | 13 +++++++++++-- .../AccountingApiTrackingCategoriesTest.java | 13 +++++++++++-- .../xero/api/client/AccountingApiUsersTest.java | 13 +++++++++++-- .../com/xero/api/client/AppStoreApiTest.java | 14 ++++++++++++-- .../java/com/xero/api/client/AssetsApiTest.java | 14 ++++++++++++-- .../client/BankfeedApiFeedConnectionTest.java | 14 ++++++++++++-- .../api/client/BankfeedApiStatementTest.java | 14 ++++++++++++-- .../java/com/xero/api/client/FinanceApiTest.java | 16 +++++++++++----- src/test/resources/config.properties | 9 +++++++++ 34 files changed, 380 insertions(+), 77 deletions(-) create mode 100644 src/test/resources/config.properties diff --git a/src/test/java/com/xero/api/client/AccountingApiAccountsTest.java b/src/test/java/com/xero/api/client/AccountingApiAccountsTest.java index 01f7b24a..407a6b92 100644 --- a/src/test/java/com/xero/api/client/AccountingApiAccountsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiAccountsTest.java @@ -10,6 +10,9 @@ import java.io.File; import org.threeten.bp.*; import java.util.UUID; +import java.util.Properties; +import java.io.IOException; +import java.io.InputStream; public class AccountingApiAccountsTest { @@ -29,9 +32,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiAccountsTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiBankTransactionTest.java b/src/test/java/com/xero/api/client/AccountingApiBankTransactionTest.java index 3d60e0b4..7136dc7e 100644 --- a/src/test/java/com/xero/api/client/AccountingApiBankTransactionTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiBankTransactionTest.java @@ -11,6 +11,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiBankTransactionTest { @@ -29,9 +31,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiBankTransactionTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiBankTransferTest.java b/src/test/java/com/xero/api/client/AccountingApiBankTransferTest.java index 44e7f882..05ad1645 100644 --- a/src/test/java/com/xero/api/client/AccountingApiBankTransferTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiBankTransferTest.java @@ -11,6 +11,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiBankTransferTest { @@ -30,9 +32,15 @@ public void setUp() { xeroTenantId = "xyz"; // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiBankTransferTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } ClassLoader classLoader = getClass().getClassLoader(); bytes = new File(classLoader.getResource("helo-heros.jpg").getFile()); diff --git a/src/test/java/com/xero/api/client/AccountingApiBatchPaymentTest.java b/src/test/java/com/xero/api/client/AccountingApiBatchPaymentTest.java index 84a88b29..fd2bf2fb 100644 --- a/src/test/java/com/xero/api/client/AccountingApiBatchPaymentTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiBatchPaymentTest.java @@ -10,6 +10,9 @@ import java.io.File; import org.threeten.bp.*; import java.util.UUID; +import java.util.Properties; +import java.io.IOException; +import java.io.InputStream; public class AccountingApiBatchPaymentTest { ApiClient defaultClient; @@ -29,9 +32,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiBatchPaymentTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } ClassLoader classLoader = getClass().getClassLoader(); bytes = new File(classLoader.getResource("helo-heros.jpg").getFile()); diff --git a/src/test/java/com/xero/api/client/AccountingApiBrandingThemeTest.java b/src/test/java/com/xero/api/client/AccountingApiBrandingThemeTest.java index a2f6e7ce..9df60906 100644 --- a/src/test/java/com/xero/api/client/AccountingApiBrandingThemeTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiBrandingThemeTest.java @@ -8,6 +8,9 @@ import com.xero.models.accounting.*; import java.util.UUID; +import java.util.Properties; +import java.io.IOException; +import java.io.InputStream; public class AccountingApiBrandingThemeTest { @@ -27,9 +30,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiBrandingThemeTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiContactGroupTest.java b/src/test/java/com/xero/api/client/AccountingApiContactGroupTest.java index a65df9f8..ab8f4ed4 100644 --- a/src/test/java/com/xero/api/client/AccountingApiContactGroupTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiContactGroupTest.java @@ -9,6 +9,8 @@ import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiContactGroupTest { @@ -28,9 +30,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiContactGroupTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiContactsTest.java b/src/test/java/com/xero/api/client/AccountingApiContactsTest.java index 6b37b35e..170f96b9 100644 --- a/src/test/java/com/xero/api/client/AccountingApiContactsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiContactsTest.java @@ -13,6 +13,8 @@ import java.util.UUID; import java.util.List; import java.util.ArrayList; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiContactsTest { @@ -33,9 +35,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiContactsTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } ClassLoader classLoader = getClass().getClassLoader(); body = new File(classLoader.getResource("helo-heros.jpg").getFile()); diff --git a/src/test/java/com/xero/api/client/AccountingApiCreditNotesTest.java b/src/test/java/com/xero/api/client/AccountingApiCreditNotesTest.java index adec2334..409fbbe3 100644 --- a/src/test/java/com/xero/api/client/AccountingApiCreditNotesTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiCreditNotesTest.java @@ -11,6 +11,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiCreditNotesTest { @@ -30,8 +32,15 @@ public void setUp() { xeroTenantId = "xyz"; // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiCreditNotesTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } ClassLoader classLoader = getClass().getClassLoader(); body = new File(classLoader.getResource("helo-heros.jpg").getFile()); diff --git a/src/test/java/com/xero/api/client/AccountingApiEmployeesTest.java b/src/test/java/com/xero/api/client/AccountingApiEmployeesTest.java index 55cd2fd2..b759f39a 100644 --- a/src/test/java/com/xero/api/client/AccountingApiEmployeesTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiEmployeesTest.java @@ -10,6 +10,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiEmployeesTest { @@ -29,8 +31,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiEmployeesTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiExpenseClaimsTest.java b/src/test/java/com/xero/api/client/AccountingApiExpenseClaimsTest.java index 6dc2802a..b952527e 100644 --- a/src/test/java/com/xero/api/client/AccountingApiExpenseClaimsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiExpenseClaimsTest.java @@ -11,6 +11,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiExpenseClaimsTest { @@ -31,8 +33,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiExpenseClaimsTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } ClassLoader classLoader = getClass().getClassLoader(); body = new File(classLoader.getResource("helo-heros.jpg").getFile()); diff --git a/src/test/java/com/xero/api/client/AccountingApiInvoicesTest.java b/src/test/java/com/xero/api/client/AccountingApiInvoicesTest.java index 27163433..146947d9 100644 --- a/src/test/java/com/xero/api/client/AccountingApiInvoicesTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiInvoicesTest.java @@ -13,6 +13,8 @@ import java.util.UUID; import java.util.List; import java.util.ArrayList; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiInvoicesTest { @@ -32,8 +34,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiInvoicesTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } ClassLoader classLoader = getClass().getClassLoader(); body = new File(classLoader.getResource("helo-heros.jpg").getFile()); diff --git a/src/test/java/com/xero/api/client/AccountingApiItemsTest.java b/src/test/java/com/xero/api/client/AccountingApiItemsTest.java index 1afeb63c..978c5dff 100644 --- a/src/test/java/com/xero/api/client/AccountingApiItemsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiItemsTest.java @@ -10,6 +10,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiItemsTest { @@ -29,8 +31,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiItemsTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiJournalsTest.java b/src/test/java/com/xero/api/client/AccountingApiJournalsTest.java index 06e2eacf..f80e0eed 100644 --- a/src/test/java/com/xero/api/client/AccountingApiJournalsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiJournalsTest.java @@ -10,6 +10,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiJournalsTest { @@ -28,8 +30,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiJournalsTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiLinkedTransactionsTest.java b/src/test/java/com/xero/api/client/AccountingApiLinkedTransactionsTest.java index c1991d77..d57cff1d 100644 --- a/src/test/java/com/xero/api/client/AccountingApiLinkedTransactionsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiLinkedTransactionsTest.java @@ -10,6 +10,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiLinkedTransactionsTest { @@ -29,8 +31,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiLinkedTransactionsTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiManualJournalsTest.java b/src/test/java/com/xero/api/client/AccountingApiManualJournalsTest.java index 396dceda..5d3b9846 100644 --- a/src/test/java/com/xero/api/client/AccountingApiManualJournalsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiManualJournalsTest.java @@ -11,6 +11,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiManualJournalsTest { @@ -31,8 +33,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiManualJournalsTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } ClassLoader classLoader = getClass().getClassLoader(); body = new File(classLoader.getResource("helo-heros.jpg").getFile()); diff --git a/src/test/java/com/xero/api/client/AccountingApiOrganisationsTest.java b/src/test/java/com/xero/api/client/AccountingApiOrganisationsTest.java index 009b2b4e..aadb13ac 100644 --- a/src/test/java/com/xero/api/client/AccountingApiOrganisationsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiOrganisationsTest.java @@ -10,6 +10,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiOrganisationsTest { @@ -29,8 +31,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiOrganisationsTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiOverpaymentsTest.java b/src/test/java/com/xero/api/client/AccountingApiOverpaymentsTest.java index 1c8ab923..5ee94739 100644 --- a/src/test/java/com/xero/api/client/AccountingApiOverpaymentsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiOverpaymentsTest.java @@ -11,6 +11,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiOverpaymentsTest { @@ -31,8 +33,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiOverpaymentsTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } ClassLoader classLoader = getClass().getClassLoader(); body = new File(classLoader.getResource("helo-heros.jpg").getFile()); diff --git a/src/test/java/com/xero/api/client/AccountingApiPaymentServicesTest.java b/src/test/java/com/xero/api/client/AccountingApiPaymentServicesTest.java index 54effc58..8152b764 100644 --- a/src/test/java/com/xero/api/client/AccountingApiPaymentServicesTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiPaymentServicesTest.java @@ -9,6 +9,8 @@ import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiPaymentServicesTest { @@ -28,8 +30,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiPaymentServicesTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiPaymentsTest.java b/src/test/java/com/xero/api/client/AccountingApiPaymentsTest.java index 25a3d8ec..b3b8e481 100644 --- a/src/test/java/com/xero/api/client/AccountingApiPaymentsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiPaymentsTest.java @@ -10,6 +10,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiPaymentsTest { @@ -26,8 +28,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiPaymentsTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } } public void tearDown() { diff --git a/src/test/java/com/xero/api/client/AccountingApiPrepaymentsTest.java b/src/test/java/com/xero/api/client/AccountingApiPrepaymentsTest.java index 3e487098..c612f06f 100644 --- a/src/test/java/com/xero/api/client/AccountingApiPrepaymentsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiPrepaymentsTest.java @@ -10,6 +10,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiPrepaymentsTest { @@ -29,8 +31,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiPrepaymentsTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiPurchaseOrdersTest.java b/src/test/java/com/xero/api/client/AccountingApiPurchaseOrdersTest.java index a3f6f26a..955348d8 100644 --- a/src/test/java/com/xero/api/client/AccountingApiPurchaseOrdersTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiPurchaseOrdersTest.java @@ -10,6 +10,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiPurchaseOrdersTest { @@ -28,8 +30,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiPurchaseOrdersTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiQuotesTest.java b/src/test/java/com/xero/api/client/AccountingApiQuotesTest.java index 49e9da45..1d0e5eb8 100644 --- a/src/test/java/com/xero/api/client/AccountingApiQuotesTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiQuotesTest.java @@ -9,6 +9,9 @@ import org.threeten.bp.*; import java.util.UUID; +import java.util.Properties; +import java.io.IOException; +import java.io.InputStream; public class AccountingApiQuotesTest { @@ -28,9 +31,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiQuotesTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiReceiptsTest.java b/src/test/java/com/xero/api/client/AccountingApiReceiptsTest.java index 3a2d07ce..ac6cf8e2 100644 --- a/src/test/java/com/xero/api/client/AccountingApiReceiptsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiReceiptsTest.java @@ -11,6 +11,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiReceiptsTest { @@ -30,8 +32,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiReceiptsTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } ClassLoader classLoader = getClass().getClassLoader(); body = new File(classLoader.getResource("helo-heros.jpg").getFile()); diff --git a/src/test/java/com/xero/api/client/AccountingApiRepeatingInvoicesTest.java b/src/test/java/com/xero/api/client/AccountingApiRepeatingInvoicesTest.java index 34504b38..7e57306c 100644 --- a/src/test/java/com/xero/api/client/AccountingApiRepeatingInvoicesTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiRepeatingInvoicesTest.java @@ -11,6 +11,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiRepeatingInvoicesTest { @@ -30,8 +32,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiRepeatingInvoicesTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } ClassLoader classLoader = getClass().getClassLoader(); body = new File(classLoader.getResource("helo-heros.jpg").getFile()); diff --git a/src/test/java/com/xero/api/client/AccountingApiReportsTest.java b/src/test/java/com/xero/api/client/AccountingApiReportsTest.java index 1295f9b9..1525a012 100644 --- a/src/test/java/com/xero/api/client/AccountingApiReportsTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiReportsTest.java @@ -10,6 +10,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiReportsTest { @@ -27,8 +29,15 @@ public void setUp() { xeroTenantId = "xyz"; // Init AccountingApi client - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiReportsTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiTaxRatesTest.java b/src/test/java/com/xero/api/client/AccountingApiTaxRatesTest.java index af2ce4ce..a1ce75b7 100644 --- a/src/test/java/com/xero/api/client/AccountingApiTaxRatesTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiTaxRatesTest.java @@ -8,6 +8,8 @@ import com.xero.models.accounting.*; import java.io.IOException; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiTaxRatesTest { @@ -26,8 +28,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiTaxRatesTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiTrackingCategoriesTest.java b/src/test/java/com/xero/api/client/AccountingApiTrackingCategoriesTest.java index 8c99de17..3f09a83d 100644 --- a/src/test/java/com/xero/api/client/AccountingApiTrackingCategoriesTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiTrackingCategoriesTest.java @@ -9,6 +9,8 @@ import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiTrackingCategoriesTest { @@ -27,8 +29,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiTrackingCategoriesTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AccountingApiUsersTest.java b/src/test/java/com/xero/api/client/AccountingApiUsersTest.java index e3def3ce..4c9bed34 100644 --- a/src/test/java/com/xero/api/client/AccountingApiUsersTest.java +++ b/src/test/java/com/xero/api/client/AccountingApiUsersTest.java @@ -10,6 +10,8 @@ import org.threeten.bp.*; import java.io.IOException; import java.util.UUID; +import java.util.Properties; +import java.io.InputStream; public class AccountingApiUsersTest { @@ -28,8 +30,15 @@ public void setUp() { // Init AccountingApi client // NEW Sandbox for API Mocking - defaultClient = new ApiClient("http://127.0.0.1:4010",null,null,null,null); - accountingApi = AccountingApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AccountingApiUsersTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("accounting.api.url"),null,null,null,null); + accountingApi = AccountingApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AppStoreApiTest.java b/src/test/java/com/xero/api/client/AppStoreApiTest.java index f5ff53d4..d034b72e 100644 --- a/src/test/java/com/xero/api/client/AppStoreApiTest.java +++ b/src/test/java/com/xero/api/client/AppStoreApiTest.java @@ -9,6 +9,9 @@ import com.xero.models.appstore.*; import java.util.UUID; +import java.util.Properties; +import java.io.IOException; +import java.io.InputStream; public class AppStoreApiTest { @@ -25,8 +28,15 @@ public void setUp() { accessToken = "123"; xeroTenantId = "xyz"; - defaultClient = new ApiClient("http://127.0.0.1:4011",null,null,null,null); - appStoreApi = AppStoreApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AppStoreApiTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("appstore.api.url"),null,null,null,null); + appStoreApi = AppStoreApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/AssetsApiTest.java b/src/test/java/com/xero/api/client/AssetsApiTest.java index b566e32f..03b54a95 100644 --- a/src/test/java/com/xero/api/client/AssetsApiTest.java +++ b/src/test/java/com/xero/api/client/AssetsApiTest.java @@ -11,6 +11,9 @@ import org.threeten.bp.*; import java.util.UUID; +import java.util.Properties; +import java.io.IOException; +import java.io.InputStream; import java.util.List; @@ -30,8 +33,15 @@ public void setUp() { accessToken = "123"; xeroTenantId = "xyz"; - defaultClient = new ApiClient("http://127.0.0.1:4012",null,null,null,null); - assetApi = AssetApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = AssetsApiTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("assets.api.url"),null,null,null,null); + assetApi = AssetApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/BankfeedApiFeedConnectionTest.java b/src/test/java/com/xero/api/client/BankfeedApiFeedConnectionTest.java index 7fe49b2d..162887ef 100644 --- a/src/test/java/com/xero/api/client/BankfeedApiFeedConnectionTest.java +++ b/src/test/java/com/xero/api/client/BankfeedApiFeedConnectionTest.java @@ -12,6 +12,9 @@ import org.junit.Before; import org.junit.Test; +import java.util.Properties; +import java.io.InputStream; +import java.io.IOException; public class BankfeedApiFeedConnectionTest { @@ -31,8 +34,15 @@ public void setUp() { // Init AccountingApi client //defaultClient = new ApiClient("https://virtserver.swaggerhub.com/Xero/bankfeeds/1.0.0",null,null,null,null); - defaultClient = new ApiClient("http://127.0.0.1:4013",null,null,null,null); - bankfeedsApi = BankFeedsApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = BankfeedApiFeedConnectionTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("bankfeeds.api.url"),null,null,null,null); + bankfeedsApi = BankFeedsApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/BankfeedApiStatementTest.java b/src/test/java/com/xero/api/client/BankfeedApiStatementTest.java index 27d008aa..aac44c88 100644 --- a/src/test/java/com/xero/api/client/BankfeedApiStatementTest.java +++ b/src/test/java/com/xero/api/client/BankfeedApiStatementTest.java @@ -8,6 +8,9 @@ import com.xero.models.bankfeeds.*; import org.threeten.bp.*; +import java.util.Properties; +import java.io.IOException; +import java.io.InputStream; public class BankfeedApiStatementTest { @@ -27,8 +30,15 @@ public void setUp() { // Init AccountingApi client //defaultClient = new ApiClient("https://virtserver.swaggerhub.com/Xero/bankfeeds/1.0.0",null,null,null,null); - defaultClient = new ApiClient("http://127.0.0.1:4013",null,null,null,null); - bankfeedsApi = BankFeedsApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = BankfeedApiStatementTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("bankfeeds.api.url"),null,null,null,null); + bankfeedsApi = BankFeedsApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/java/com/xero/api/client/FinanceApiTest.java b/src/test/java/com/xero/api/client/FinanceApiTest.java index 8be82ad6..94323a94 100644 --- a/src/test/java/com/xero/api/client/FinanceApiTest.java +++ b/src/test/java/com/xero/api/client/FinanceApiTest.java @@ -8,9 +8,9 @@ import com.xero.api.XeroApiException; import com.xero.models.finance.*; -import java.util.UUID; - import java.util.*; +import java.io.IOException; +import java.io.InputStream; public class FinanceApiTest { @@ -26,9 +26,15 @@ public void setUp() { // Set Access Token and Tenant Id accessToken = "123"; xeroTenantId = "xyz"; - - defaultClient = new ApiClient("http://127.0.0.1:4014",null,null,null,null); - financeApi = FinanceApi.getInstance(defaultClient); + Properties properties = new Properties(); + try (InputStream input = FinanceApiTest.class.getClassLoader().getResourceAsStream("config.properties")){ + properties.load(input); + defaultClient = new ApiClient(properties.getProperty("finance.api.url"),null,null,null,null); + financeApi = FinanceApi.getInstance(defaultClient); + + } catch (IOException ex) { + ex.printStackTrace(); + } // ADDED TO MANAGE RATE LIMITS while using SwaggerHub to mock APIs if (setUpIsDone) { diff --git a/src/test/resources/config.properties b/src/test/resources/config.properties new file mode 100644 index 00000000..092114ad --- /dev/null +++ b/src/test/resources/config.properties @@ -0,0 +1,9 @@ +accounting.api.url=http://127.0.0.1:4010 +appstore.api.url=http://127.0.0.1:4011 +assets.api.url=http://127.0.0.1:4012 +bankfeeds.api.url=http://127.0.0.1:4013 +finance.api.url=http://127.0.0.1:4014 +payrolluk.api.url=http://127.0.0.1:4015 +payrollnz.api.url=http://127.0.0.1:4016 +payrollau.api.url=http://127.0.0.1:4017 +projects.api.url=http://127.0.0.1:4018