wallets = null;
+
+ String jsonResponse = this.bitPayClient.get("supportedwallets");
try {
- HttpResponse response = this.bitPayClient.get("supportedwallets");
wallets = Arrays.asList(
- JsonMapperFactory.create().readValue(this.bitPayClient.responseToJsonString(response), Wallet[].class)
+ JsonMapperFactory.create().readValue(jsonResponse, Wallet[].class)
);
} catch (JsonProcessingException e) {
- throw new WalletQueryException(null,
- "failed to deserialize BitPay server response (Wallet) : " + e.getMessage());
- } catch (Exception e) {
- throw new WalletQueryException(null,
- "failed to deserialize BitPay server response (Wallet) : " + e.getMessage());
+ BitPayExceptionProvider.throwDeserializeResourceException("Wallet", e.getMessage());
}
return wallets;
diff --git a/src/main/java/com/bitpay/sdk/exceptions/BillCreationException.java b/src/main/java/com/bitpay/sdk/exceptions/BillCreationException.java
deleted file mode 100644
index ee0feef2..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/BillCreationException.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a POST when the Bill cannot be created.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 01
- * Resource digits for the Bill: 00
- * Error digits for the Bill:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 010001
- *
- *
- * @see Rest API Error Codes
- */
-public class BillCreationException extends BillException {
- /**
- * Construct the BillCreationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public BillCreationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to create bill";
- String bitPayCode = "BITPAY-BILL-CREATE";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/BillDeliveryException.java b/src/main/java/com/bitpay/sdk/exceptions/BillDeliveryException.java
deleted file mode 100644
index 6fa2a352..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/BillDeliveryException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a POST when the Bill cannot be delivered.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 01
- * Resource digits for the Bill: 00
- * Error digits for the Bill:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 010002
- *
- *
- * @see Rest API Error Codes
- */
-public class BillDeliveryException extends BillException {
- /**
- * Construct the BillDeliveryException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public BillDeliveryException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to deliver bill";
- String bitPayCode = "BITPAY-BILL-DELIVERY";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/BillException.java b/src/main/java/com/bitpay/sdk/exceptions/BillException.java
deleted file mode 100644
index 732cb30c..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/BillException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- * Exception which is extended by other exceptions related with Bill.
- *
- * @see com.bitpay.sdk.exceptions.BillCreationException
- * @see com.bitpay.sdk.exceptions.BillQueryException
- * @see com.bitpay.sdk.exceptions.BillDeliveryException
- * @see com.bitpay.sdk.exceptions.BillUpdateException
- *
- * @see Rest API Error Codes
- */
-public class BillException extends BitPayException {
- /**
- * Construct the BillException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public BillException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "An unexpected error occurred while trying to manage the bill";
- String bitPayCode = "BITPAY-BILL-GENERIC";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/BillQueryException.java b/src/main/java/com/bitpay/sdk/exceptions/BillQueryException.java
deleted file mode 100644
index 29c23b31..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/BillQueryException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a GET when the Bill cannot be retrieved.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 02
- * Resource digits for the Bill: 00
- * Error digits for the Bill:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 020002
- *
- *
- * @see Rest API Error Codes
- */
-public class BillQueryException extends BillException {
- /**
- * Construct the BillQueryException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public BillQueryException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to retrieve bill";
- String bitPayCode = "BITPAY-BILL-GET";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/BillUpdateException.java b/src/main/java/com/bitpay/sdk/exceptions/BillUpdateException.java
deleted file mode 100644
index 0188358a..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/BillUpdateException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a PUT when the Bill cannot be updated.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 03
- * Resource digits for the Bill: 00
- * Error digits for the Bill:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 030002
- *
- *
- * @see Rest API Error Codes
- */
-public class BillUpdateException extends BillException {
- /**
- * Construct the BillUpdateException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public BillUpdateException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to update bill";
- String bitPayCode = "BITPAY-BILL-UPDATE";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/BitPayApiException.java b/src/main/java/com/bitpay/sdk/exceptions/BitPayApiException.java
new file mode 100644
index 00000000..e5f14552
--- /dev/null
+++ b/src/main/java/com/bitpay/sdk/exceptions/BitPayApiException.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2019 BitPay.
+ * All rights reserved.
+ */
+
+package com.bitpay.sdk.exceptions;
+
+public class BitPayApiException extends BitPayException {
+
+ private static final long serialVersionUID = 8211452784073681895L;
+
+ private final String code;
+
+ public BitPayApiException(String message, String code) {
+ super(message);
+ this.code = code;
+ }
+
+ /**
+ * An error code consists of 6 digits.
+ * The first two digits of an error code represent the HTTP method that was used to call it.
+ * The next two digits refer to the resource that was impacted.
+ * The last two digits refer to the specific error.
+ * eg. 010103 - Missing parameters for Invoice POST request.
+ *
+ * @return String
+ */
+ public String getCode() {
+ return this.code;
+ }
+}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/BitPayException.java b/src/main/java/com/bitpay/sdk/exceptions/BitPayException.java
index 38fb25bf..eae1473e 100644
--- a/src/main/java/com/bitpay/sdk/exceptions/BitPayException.java
+++ b/src/main/java/com/bitpay/sdk/exceptions/BitPayException.java
@@ -5,82 +5,21 @@
package com.bitpay.sdk.exceptions;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.util.TextUtils;
-
/**
* General BitPay Exception which is inherited by all other exceptions.
*
* @see Rest API Error Codes
*/
-public class BitPayException extends ClientProtocolException {
- private static final long serialVersionUID = -7186627969477257933L;
-
- /**
- * String [optional] The Exception code to throw.
- */
- private final String statusCode;
+public class BitPayException extends Exception {
- /**
- * String [optional] The Exception message to throw.
- */
- private final String reasonPhrase;
+ private static final long serialVersionUID = -5407556346434827903L;
/**
* Construct the BitPayException.
*
- * @param statusCode String [optional] The Exception code to throw.
- * @param reasonPhrase String [optional] The Exception message to throw.
- */
- public BitPayException(
- String statusCode,
- String reasonPhrase
- ) {
- super(String.format("Status: %s" + (TextUtils.isBlank(reasonPhrase) ? "" : " -> Reason: %s"),
- buildStatus(statusCode), buildMessage(reasonPhrase)));
- this.statusCode = statusCode;
- this.reasonPhrase = reasonPhrase;
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Unexpected Bitpay exeption.";
- String bitPayCode = "BITPAY-GENERIC";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-
- private static String buildStatus(String status) {
- if (status == null) {
- status = "000000";
- }
-
- return status;
- }
-
- /**
- * An error code consists of 6 digits.
- * The first two digits of an error code represent the HTTP method that was used to call it.
- * The next two digits refer to the resource that was impacted.
- * The last two digits refer to the specific error.
- * eg. 010103 - Missing parameters for Invoice POST request.
- *
- * @return String
- */
- public String getStatusCode() {
- return this.statusCode;
- }
-
- /**
- * Reason phrase including BitPay Code and BitPay Message.
- * eg. BITPAY-BILL-UPDATE: Failed to update bill -> failed to deserialize BitPay server response (Bill)
- *
- * @return String
+ * @param message String [optional] The Exception message.
*/
- public String getReasonPhrase() {
- return this.reasonPhrase;
+ public BitPayException(String message) {
+ super(message);
}
}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/BitPayExceptionProvider.java b/src/main/java/com/bitpay/sdk/exceptions/BitPayExceptionProvider.java
new file mode 100644
index 00000000..b8565e22
--- /dev/null
+++ b/src/main/java/com/bitpay/sdk/exceptions/BitPayExceptionProvider.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2019 BitPay.
+ * All rights reserved.
+ */
+
+package com.bitpay.sdk.exceptions;
+
+import com.bitpay.sdk.logger.LoggerProvider;
+import java.util.Objects;
+
+public class BitPayExceptionProvider {
+
+ public static final String GENERIC_API_UNMAPPED_ERROR_CODE = "000000";
+
+ /**
+ * Throw Generic (Non-Api) Exception.
+ *
+ * @param message error message
+ * @throws BitPayGenericException BitPayGenericException class
+ */
+ public static void throwGenericExceptionWithMessage(String message) throws BitPayGenericException {
+ logErrorMessage(message);
+
+ throw new BitPayGenericException(message);
+ }
+
+ /**
+ * Throw API Exception.
+ *
+ * @param message error message
+ * @throws BitPayApiException BitPayApiException class
+ */
+ public static void throwApiExceptionWithMessage(String message) throws BitPayApiException {
+ logErrorMessage(message);
+
+ throw new BitPayApiException(message, GENERIC_API_UNMAPPED_ERROR_CODE);
+ }
+
+ /**
+ * Throw API Exception with specific message and code.
+ *
+ * @param message error message
+ * @param code BitPay error code
+ * @throws BitPayApiException BitPayApiException
+ */
+ public static void throwApiExceptionWithMessage(String message, String code) throws BitPayApiException {
+ logErrorMessage(message);
+
+ throw new BitPayApiException(message, code);
+ }
+
+ public static void throwValidationException(String message) throws BitPayValidationException {
+ logErrorMessage(message);
+
+ throw new BitPayValidationException(message);
+ }
+
+ public static void throwMissingParameterException() throws BitPayValidationException {
+ final String message = "Missing required parameter";
+
+ logErrorMessage(message);
+
+ throw new BitPayValidationException(message);
+ }
+
+ public static void throwDeserializeResourceException(String resource, String exceptionMessage)
+ throws BitPayGenericException {
+ String message = String.format(
+ "Failed to deserialize BitPay server response ( %s ) : " + exceptionMessage, resource);
+ BitPayExceptionProvider.throwGenericExceptionWithMessage(message);
+ }
+
+ public static void throwDeserializeException(String exceptionMessage)
+ throws BitPayGenericException {
+ String message = "Failed to deserialize BitPay server response : " + exceptionMessage;
+ BitPayExceptionProvider.throwGenericExceptionWithMessage(message);
+ }
+
+ public static void throwEncodeException(String exceptionMessage)
+ throws BitPayGenericException {
+ String message = "Failed to encode params : " + exceptionMessage;
+ BitPayExceptionProvider.throwGenericExceptionWithMessage(message);
+ }
+
+ public static void throwSerializeResourceException(String resource, String exceptionMessage)
+ throws BitPayGenericException {
+ String message = String.format("Failed to serialize ( %s ) : " + exceptionMessage, resource);
+ BitPayExceptionProvider.throwGenericExceptionWithMessage(message);
+ }
+
+ public static void throwSerializeParamsException(String exceptionMessage) throws BitPayGenericException {
+ String message = "Failed to serialize params : " + exceptionMessage;
+ BitPayExceptionProvider.throwGenericExceptionWithMessage(message);
+ }
+
+ public static void throwInvalidCurrencyException(String currencyCode) throws BitPayValidationException {
+ String message = String.format("Currency code %s must be a type of Model.Currency", currencyCode);
+ BitPayExceptionProvider.throwValidationException(message);
+ }
+
+ private static void logErrorMessage(String message) {
+ if (Objects.nonNull(message)) {
+ LoggerProvider.getLogger().logError(message);
+ }
+ }
+}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/BitPayGenericException.java b/src/main/java/com/bitpay/sdk/exceptions/BitPayGenericException.java
new file mode 100644
index 00000000..a714d52e
--- /dev/null
+++ b/src/main/java/com/bitpay/sdk/exceptions/BitPayGenericException.java
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2019 BitPay.
+ * All rights reserved.
+ */
+
+package com.bitpay.sdk.exceptions;
+
+public class BitPayGenericException extends BitPayException {
+
+ private static final long serialVersionUID = -4496707441469582396L;
+
+ public BitPayGenericException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/BitPayValidationException.java b/src/main/java/com/bitpay/sdk/exceptions/BitPayValidationException.java
new file mode 100644
index 00000000..d16946d3
--- /dev/null
+++ b/src/main/java/com/bitpay/sdk/exceptions/BitPayValidationException.java
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2019 BitPay.
+ * All rights reserved.
+ */
+
+package com.bitpay.sdk.exceptions;
+
+public class BitPayValidationException extends BitPayGenericException {
+
+ private static final long serialVersionUID = -6721535639566485766L;
+
+ public BitPayValidationException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/CurrencyException.java b/src/main/java/com/bitpay/sdk/exceptions/CurrencyException.java
deleted file mode 100644
index 33008f80..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/CurrencyException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- * Exception which is extended by other exceptions related with Currency.
- *
- * @see com.bitpay.sdk.exceptions.CurrencyQueryException
- * @see Rest API Error Codes
- */
-public class CurrencyException extends BitPayException {
- /**
- * Construct the CurrencyException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public CurrencyException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "An unexpected error occurred while trying to manage the currencies";
- String bitPayCode = "BITPAY-CURRENCY-GENERIC";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/CurrencyQueryException.java b/src/main/java/com/bitpay/sdk/exceptions/CurrencyQueryException.java
deleted file mode 100644
index 5b2a667a..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/CurrencyQueryException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a GET when the Currency cannot be retrieved.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 02
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 020001
- *
- *
- * @see Rest API Error Codes
- */
-public class CurrencyQueryException extends CurrencyException {
- /**
- * Construct the CurrencyQueryException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public CurrencyQueryException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to retrieve currencies";
- String bitPayCode = "BITPAY-CURRENCY-GET";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/InvoiceCancellationException.java b/src/main/java/com/bitpay/sdk/exceptions/InvoiceCancellationException.java
deleted file mode 100644
index 07c103fb..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/InvoiceCancellationException.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a DELETE when the Invoice cannot be cancelled.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 04
- * Resource digits for the Invoice: 01
- * Error digits for the Invoice:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- * - 08 - Invoice is missing email or SMS
- * - 09 - SMS not verified
- * - 10 - Invoice price is below minimum threshold
- * - 11 - Invoice price is above maximum threshold
- * - 12 - Invalid SMS number
- * - 13 - Error verifying SMS
- * - 14 - Unable to update contact information on high value transaction
- * - 15 - Email already set on invoice
- * - 16 - Unable to perform action outside of demo environment
- * - 17 - Invalid invoice state
- * - 18 - Misconfigured account
- *
- *
- * eg 040101
- *
- *
- * @see Rest API Error Codes
- */
-public class InvoiceCancellationException extends InvoiceException {
- /**
- * Construct the InvoiceCancellationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public InvoiceCancellationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to cancel invoice";
- String bitPayCode = "BITPAY-INVOICE-CANCEL";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/InvoiceCreationException.java b/src/main/java/com/bitpay/sdk/exceptions/InvoiceCreationException.java
deleted file mode 100644
index e9110d97..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/InvoiceCreationException.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a POST when the Invoice cannot be created.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 01
- * Resource digits for the Invoice: 01
- * Error digits for the Invoice:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- * - 08 - Invoice is missing email or SMS
- * - 09 - SMS not verified
- * - 10 - Invoice price is below minimum threshold
- * - 11 - Invoice price is above maximum threshold
- * - 12 - Invalid SMS number
- * - 13 - Error verifying SMS
- * - 14 - Unable to update contact information on high value transaction
- * - 15 - Email already set on invoice
- * - 16 - Unable to perform action outside of demo environment
- * - 17 - Invalid invoice state
- * - 18 - Misconfigured account
- *
- *
- * eg 010101
- *
- *
- * @see Rest API Error Codes
- */
-public class InvoiceCreationException extends InvoiceException {
- /**
- * Construct the InvoiceCreationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public InvoiceCreationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to create invoice";
- String bitPayCode = "BITPAY-INVOICE-CREATE";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/InvoiceException.java b/src/main/java/com/bitpay/sdk/exceptions/InvoiceException.java
deleted file mode 100644
index 7b89baa3..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/InvoiceException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- * Exception which is extended by other exceptions related with Invoice.
- *
- * @see com.bitpay.sdk.exceptions.InvoiceCancellationException
- * @see com.bitpay.sdk.exceptions.InvoiceCreationException
- * @see com.bitpay.sdk.exceptions.InvoiceQueryException
- * @see com.bitpay.sdk.exceptions.InvoiceUpdateException
- *
- * @see Rest API Error Codes
- */
-public class InvoiceException extends BitPayException {
- /**
- * Construct the InvoiceException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public InvoiceException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "An unexpected error occurred while trying to manage the invoice";
- String bitPayCode = "BITPAY-INVOICE-GENERIC";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/InvoiceQueryException.java b/src/main/java/com/bitpay/sdk/exceptions/InvoiceQueryException.java
deleted file mode 100644
index f4d252b0..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/InvoiceQueryException.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a GET when the Invoice cannot be retrieved.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 02
- * Resource digits for the Invoice: 01
- * Error digits for the Invoice:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- * - 08 - Invoice is missing email or SMS
- * - 09 - SMS not verified
- * - 10 - Invoice price is below minimum threshold
- * - 11 - Invoice price is above maximum threshold
- * - 12 - Invalid SMS number
- * - 13 - Error verifying SMS
- * - 14 - Unable to update contact information on high value transaction
- * - 15 - Email already set on invoice
- * - 16 - Unable to perform action outside of demo environment
- * - 17 - Invalid invoice state
- * - 18 - Misconfigured account
- *
- *
- * eg 040101
- *
- *
- * @see Rest API Error Codes
- */
-public class InvoiceQueryException extends InvoiceException {
- /**
- * Construct the InvoiceQueryException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public InvoiceQueryException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to retrieve invoice";
- String bitPayCode = "BITPAY-INVOICE-GET";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/InvoiceUpdateException.java b/src/main/java/com/bitpay/sdk/exceptions/InvoiceUpdateException.java
deleted file mode 100644
index d53f48a8..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/InvoiceUpdateException.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a PUT when the Invoice cannot be updated.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 03
- * Resource digits for the Invoice: 01
- * Error digits for the Invoice:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- * - 08 - Invoice is missing email or SMS
- * - 09 - SMS not verified
- * - 10 - Invoice price is below minimum threshold
- * - 11 - Invoice price is above maximum threshold
- * - 12 - Invalid SMS number
- * - 13 - Error verifying SMS
- * - 14 - Unable to update contact information on high value transaction
- * - 15 - Email already set on invoice
- * - 16 - Unable to perform action outside of demo environment
- * - 17 - Invalid invoice state
- * - 18 - Misconfigured account
- *
- *
- * eg 030101
- *
- *
- * @see Rest API Error Codes
- */
-public class InvoiceUpdateException extends InvoiceException {
- /**
- * Construct the InvoiceUpdateException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public InvoiceUpdateException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to update invoice";
- String bitPayCode = "BITPAY-INVOICE-UPDATE";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/LedgerException.java b/src/main/java/com/bitpay/sdk/exceptions/LedgerException.java
deleted file mode 100644
index a39bbccf..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/LedgerException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- * Exception which is extended by other exceptions related with Ledger.
- *
- * @see com.bitpay.sdk.exceptions.LedgerQueryException
- *
- * @see Rest API Error Codes
- */
-public class LedgerException extends BitPayException {
- /**
- * Construct the LedgerException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public LedgerException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "An unexpected error occurred while trying to manage the ledger";
- String bitPayCode = "BITPAY-LEDGER-GENERIC";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/LedgerQueryException.java b/src/main/java/com/bitpay/sdk/exceptions/LedgerQueryException.java
deleted file mode 100644
index 7c5bfa42..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/LedgerQueryException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a GET when the Ledger cannot be retrieved.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 02
- * Resource digits for the Ledger: 00
- * Error digits for the Ledger:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 020001
- *
- *
- * @see Rest API Error Codes
- */
-public class LedgerQueryException extends LedgerException {
- /**
- * Construct the LedgerQueryException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public LedgerQueryException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to retrieve ledger";
- String bitPayCode = "BITPAY-LEDGER-GET";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchCancellationException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchCancellationException.java
deleted file mode 100644
index affb03a9..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchCancellationException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a DELETE when the Payout Batch cannot be cancelled.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 04
- * Resource digits for the Payout Batch: 00
- * Error digits for the Payout Batch:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 040001
- *
- *
- * @see Rest API Error Codes
- */
-public class PayoutBatchCancellationException extends PayoutBatchException {
- /**
- * Construct the PayoutBatchCancellationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutBatchCancellationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to cancel payout batch.";
- String bitPayCode = "BITPAY-PAYOUT-BATCH-CANCELLATION";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchCreationException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchCreationException.java
deleted file mode 100644
index 8e5a37bb..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchCreationException.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a POST when the Payout Batch cannot be created.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 01
- * Resource digits for the Payout Batch: 00
- * Error digits for the Payout Batch:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 010001
- *
- *
- * @see Rest API Error Codes
- */
-public class PayoutBatchCreationException extends PayoutBatchException {
- /**
- * Construct the PayoutBatchCreationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutBatchCreationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to create payout batch.";
- String bitPayCode = "BITPAY-PAYOUT-BATCH-CREATE";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchException.java
deleted file mode 100644
index c70f5ee3..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- * Exception which is extended by other exceptions related with Payout Batch.
- *
- * @see com.bitpay.sdk.exceptions.PayoutBatchCancellationException
- * @see com.bitpay.sdk.exceptions.PayoutBatchCreationException
- * @see com.bitpay.sdk.exceptions.PayoutBatchNotificationException
- * @see com.bitpay.sdk.exceptions.PayoutBatchQueryException
- *
- * @see Rest API Error Codes
- */
-public class PayoutBatchException extends BitPayException {
- /**
- * Construct the PayoutBatchException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutBatchException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "An unexpected error occured while trying to manage the payout batch.";
- String bitPayCode = "BITPAY-PAYOUT-BATCH-GENERIC";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchNotificationException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchNotificationException.java
deleted file mode 100644
index 033ef163..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchNotificationException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a POST when the Payout Batch Notification cannot be created.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 01
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 010001
- *
- *
- * @see Rest API Error Codes
- */
-public class PayoutBatchNotificationException extends PayoutBatchException {
- /**
- * Construct the PayoutBatchNotificationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutBatchNotificationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to send payout batch notification.";
- String bitPayCode = "BITPAY-PAYOUT-BATCH-NOTIFICATION";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchQueryException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchQueryException.java
deleted file mode 100644
index 7b18a2b3..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutBatchQueryException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a POST when the Payout Batch cannot be retrieved.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 02
- * Resource digits for the Payout Batch: 00
- * Error digits for the Payout Batch:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 020001
- *
- *
- * @see Rest API Error Codes
- */
-public class PayoutBatchQueryException extends PayoutBatchException {
- /**
- * Construct the PayoutBatchQueryException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutBatchQueryException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to retrieve payout batch.";
- String bitPayCode = "BITPAY-PAYOUT-BATCH-GET";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutCancellationException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutCancellationException.java
deleted file mode 100644
index 8ecf82ba..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutCancellationException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a DELETE when the Payout cannot be cancelled.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 04
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 040001
- *
- *
- * @see Rest API Error Codes
- */
-public class PayoutCancellationException extends PayoutException {
- /**
- * Construct the PayoutCancellationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutCancellationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to cancel payout.";
- String bitPayCode = "BITPAY-PAYOUT-CANCEL";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutCreationException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutCreationException.java
deleted file mode 100644
index e3add26f..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutCreationException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a POST when the Payout cannot be created.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 01
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 010001
- *
- *
- * @see Rest API Error Codes
- */
-public class PayoutCreationException extends PayoutException {
- /**
- * Construct the PayoutCreationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutCreationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to create payout.";
- String bitPayCode = "BITPAY-PAYOUT-SUBMIT";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutException.java
deleted file mode 100644
index 3008819c..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- * Exception which is extended by other exceptions related with Payout Batch.
- *
- * @see com.bitpay.sdk.exceptions.PayoutCancellationException
- * @see com.bitpay.sdk.exceptions.PayoutCreationException
- * @see com.bitpay.sdk.exceptions.PayoutNotificationException
- * @see com.bitpay.sdk.exceptions.PayoutQueryException
- *
- * @see Rest API Error Codes
- */
-public class PayoutException extends BitPayException {
- /**
- * Construct the PayoutException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "An unexpected error occurred while trying to manage the payout.";
- String bitPayCode = "BITPAY-PAYOUT-GENERIC";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutNotificationException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutNotificationException.java
deleted file mode 100644
index 91bc18d3..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutNotificationException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a POST when the Payout Notification cannot be created.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 01
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 010001
- *
- *
- * @see Rest API Error Codes
- */
-public class PayoutNotificationException extends PayoutException {
- /**
- * Construct the PayoutNotificationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutNotificationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to send payout notification.";
- String bitPayCode = "BITPAY-PAYOUT-NOTIFICATION";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutQueryException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutQueryException.java
deleted file mode 100644
index f9127b87..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutQueryException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a GET when the Payout cannot be retrieved.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 02
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 020001
- *
- *
- * @see Rest API Error Codes
- */
-public class PayoutQueryException extends PayoutException {
- /**
- * Construct the PayoutQueryException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutQueryException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to retrieve payout.";
- String bitPayCode = "BITPAY-PAYOUT-GET";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientCancellationException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientCancellationException.java
deleted file mode 100644
index c5c6cd7d..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientCancellationException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a GET when the Payout Recipient cannot be cancelled.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 04
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 040001
- *
- *
- * @see Rest API Error Codes
- */
-public class PayoutRecipientCancellationException extends PayoutRecipientException {
- /**
- * Construct the PayoutRecipientCancellationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutRecipientCancellationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to cancel payout recipient";
- String bitPayCode = "BITPAY-PAYOUT-RECIPIENT-CANCELLATION";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientCreationException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientCreationException.java
deleted file mode 100644
index c60815bd..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientCreationException.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a POST when the Payout Recipient cannot be created.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 01
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 010001
- *
- *
- * @see Rest API Error Codes
- */
-public class PayoutRecipientCreationException extends PayoutRecipientException {
- /**
- * Construct the PayoutRecipientCreationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutRecipientCreationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to submit payout recipient.";
- String bitPayCode = "BITPAY-PAYOUT-RECIPIENT-CREATE";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
-
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientException.java
deleted file mode 100644
index 27f9df58..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- * Exception which is extended by other exceptions related with Payout Recipient.
- *
- * @see com.bitpay.sdk.exceptions.PayoutRecipientCancellationException
- * @see com.bitpay.sdk.exceptions.PayoutRecipientCreationException
- * @see com.bitpay.sdk.exceptions.PayoutRecipientUpdateException
- * @see com.bitpay.sdk.exceptions.PayoutRecipientNotificationException
- * @see com.bitpay.sdk.exceptions.PayoutRecipientQueryException
- *
- * @see Rest API Error Codes
- */
-public class PayoutRecipientException extends BitPayException {
- /**
- * Construct the PayoutRecipientException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutRecipientException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "An unexpected error occurred while trying to manage the payout recipient";
- String bitPayCode = "BITPAY-PAYOUT-RECIPIENT-GENERIC";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientNotificationException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientNotificationException.java
deleted file mode 100644
index f0e2e59c..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientNotificationException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a GET when the Payout Recipient Notification cannot be created.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 01
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 010001
- *
- *
- * @see Rest API Error Codes
- */
-public class PayoutRecipientNotificationException extends PayoutRecipientException {
- /**
- * Construct the PayoutRecipientNotificationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutRecipientNotificationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to send payout recipient notification.";
- String bitPayCode = "BITPAY-PAYOUT-RECIPIENT-NOTIFICATION";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientQueryException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientQueryException.java
deleted file mode 100644
index 7a54f2d3..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientQueryException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a GET when the Payout Recipient cannot be retrieved.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 02
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 020001
- *
- *
- * @see Rest API Error Codes
- */
-public class PayoutRecipientQueryException extends PayoutRecipientException {
- /**
- * Construct the PayoutRecipientQueryException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutRecipientQueryException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to retrieve payout recipient.";
- String bitPayCode = "BITPAY-PAYOUT-RECIPIENT-GET";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientUpdateException.java b/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientUpdateException.java
deleted file mode 100644
index 720a6c4a..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/PayoutRecipientUpdateException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a PUT when the Payout Recipient cannot be updated.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 03
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 030001
- *
- *
- * @see Rest API Error Codes
- */
-public class PayoutRecipientUpdateException extends PayoutRecipientException {
- /**
- * Construct the PayoutRecipientUpdateException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public PayoutRecipientUpdateException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to update payout recipient.";
- String bitPayCode = "BITPAY-PAYOUT-RECIPIENT-UPDATE";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/RateException.java b/src/main/java/com/bitpay/sdk/exceptions/RateException.java
deleted file mode 100644
index 43807cc8..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/RateException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- * Exception which is extended by other exceptions related with Rate.
- *
- * @see com.bitpay.sdk.exceptions.RateQueryException
- *
- * @see Rest API Error Codes
- */
-public class RateException extends BitPayException {
- /**
- * Construct the RateException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public RateException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "An unexpected error occurred while trying to manage the rates";
- String bitPayCode = "BITPAY-RATES-GENERIC";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/RateQueryException.java b/src/main/java/com/bitpay/sdk/exceptions/RateQueryException.java
deleted file mode 100644
index 1ba88525..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/RateQueryException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a GET when the Rate cannot be retrieved.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 02
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 020001
- *
- *
- * @see Rest API Error Codes
- */
-public class RateQueryException extends RateException {
- /**
- * Construct the RateQueryException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public RateQueryException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to retrieve rates";
- String bitPayCode = "BITPAY-RATES-GET";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/RefundCancellationException.java b/src/main/java/com/bitpay/sdk/exceptions/RefundCancellationException.java
deleted file mode 100644
index e8308751..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/RefundCancellationException.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a DELETE when the Refund cannot be cancelled.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 04
- * Resource digits for the this class: 02
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Refund not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- * - 04 - Active refund request already exists
- * - 07 - Invalid invoice state for refund
- * - 08 - Fees are greater than refund amount
- *
- *
- * eg 040201
- *
- *
- * @see Rest API Error Codes
- */
-public class RefundCancellationException extends RefundException {
- /**
- * Construct the RefundCancellationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public RefundCancellationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to cancel refund";
- String bitPayCode = "BITPAY-REFUND-CANCEL";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/RefundCreationException.java b/src/main/java/com/bitpay/sdk/exceptions/RefundCreationException.java
deleted file mode 100644
index 235c9c8a..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/RefundCreationException.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a POST when the Refund cannot be created.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 01
- * Resource digits for the this class: 02
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Refund not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- * - 04 - Active refund request already exists
- * - 07 - Invalid invoice state for refund
- * - 08 - Fees are greater than refund amount
- *
- *
- * eg 010201
- *
- *
- * @see Rest API Error Codes
- */
-public class RefundCreationException extends RefundException {
- /**
- * Construct the RefundCreationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public RefundCreationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to create refund";
- String bitPayCode = "BITPAY-REFUND-CREATE";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/RefundException.java b/src/main/java/com/bitpay/sdk/exceptions/RefundException.java
deleted file mode 100644
index 724104cf..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/RefundException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- * Exception which is extended by other exceptions related with Refund.
- *
- * @see com.bitpay.sdk.exceptions.RefundCancellationException
- * @see com.bitpay.sdk.exceptions.RefundCreationException
- * @see com.bitpay.sdk.exceptions.RefundUpdateException
- * @see com.bitpay.sdk.exceptions.RefundQueryException
- *
- * @see Rest API Error Codes
- */
-public class RefundException extends BitPayException {
- /**
- * Construct the RefundException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public RefundException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "An unexpected error occurred while trying to manage the refund";
- String bitPayCode = "BITPAY-REFUND-GENERIC";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/RefundQueryException.java b/src/main/java/com/bitpay/sdk/exceptions/RefundQueryException.java
deleted file mode 100644
index 5be81f5d..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/RefundQueryException.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a GET when the Refund cannot be retrieved.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 02
- * Resource digits for the this class: 02
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Refund not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- * - 04 - Active refund request already exists
- * - 07 - Invalid invoice state for refund
- * - 08 - Fees are greater than refund amount
- *
- *
- * eg 020201
- *
- *
- * @see Rest API Error Codes
- */
-public class RefundQueryException extends RefundException {
- /**
- * Construct the RefundQueryException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public RefundQueryException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to retrieve refund";
- String bitPayCode = "BITPAY-REFUND-GET";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/RefundUpdateException.java b/src/main/java/com/bitpay/sdk/exceptions/RefundUpdateException.java
deleted file mode 100644
index b625f142..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/RefundUpdateException.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a PUT when the Refund cannot be updated.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 02
- * Resource digits for the this class: 03
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Refund not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- * - 04 - Active refund request already exists
- * - 07 - Invalid invoice state for refund
- * - 08 - Fees are greater than refund amount
- *
- *
- * eg 020301
- *
- *
- * @see Rest API Error Codes
- */
-public class RefundUpdateException extends RefundException {
- /**
- * Construct the RefundUpdateException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public RefundUpdateException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to update refund";
- String bitPayCode = "BITPAY-REFUND-UPDATE";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/SettlementException.java b/src/main/java/com/bitpay/sdk/exceptions/SettlementException.java
deleted file mode 100644
index 8932be89..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/SettlementException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- * Exception which is extended by other exceptions related with Settlement.
- *
- * @see com.bitpay.sdk.exceptions.SettlementQueryException
- * @see Rest API Error Codes
- */
-public class SettlementException extends BitPayException {
- /**
- * Construct the SettlementException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public SettlementException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "An unexpected error occurred while trying to manage the settlements";
- String bitPayCode = "BITPAY-SETTLEMENTS-GENERIC";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/SettlementQueryException.java b/src/main/java/com/bitpay/sdk/exceptions/SettlementQueryException.java
deleted file mode 100644
index 2b671bf2..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/SettlementQueryException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a GET when the Settlement cannot be retrieved.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 02
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 020002
- *
- *
- * @see Rest API Error Codes
- */
-public class SettlementQueryException extends SettlementException {
- /**
- * Construct the SettlementQueryException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public SettlementQueryException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to retrieve settlements";
- String bitPayCode = "BITPAY-SETTLEMENTS-GET";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/SubscriptionCreationException.java b/src/main/java/com/bitpay/sdk/exceptions/SubscriptionCreationException.java
deleted file mode 100644
index 263587b7..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/SubscriptionCreationException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a POST when the Subscription cannot be created.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 01
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 010002
- *
- *
- * @see Rest API Error Codes
- */
-public class SubscriptionCreationException extends SubscriptionException {
- /**
- * Construct the SubscriptionCreationException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public SubscriptionCreationException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to create subscription";
- String bitPayCode = "BITPAY-SUBSCRIPTION-CREATE";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/SubscriptionException.java b/src/main/java/com/bitpay/sdk/exceptions/SubscriptionException.java
deleted file mode 100644
index 00b42e9f..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/SubscriptionException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- * Exception which is extended by other exceptions related with Refund.
- *
- * @see com.bitpay.sdk.exceptions.SubscriptionCreationException
- * @see com.bitpay.sdk.exceptions.SubscriptionUpdateException
- * @see com.bitpay.sdk.exceptions.SubscriptionQueryException
- *
- * @see Rest API Error Codes
- */
-public class SubscriptionException extends BitPayException {
- /**
- * Construct the SubscriptionException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public SubscriptionException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "An unexpected error occurred while trying to manage the subscription";
- String bitPayCode = "BITPAY-SUBSCRIPTION-GENERIC";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/SubscriptionQueryException.java b/src/main/java/com/bitpay/sdk/exceptions/SubscriptionQueryException.java
deleted file mode 100644
index 5aa653b4..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/SubscriptionQueryException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a GET when the Subscription cannot be retrieved.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 02
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 020002
- *
- *
- * @see Rest API Error Codes
- */
-public class SubscriptionQueryException extends SubscriptionException {
- /**
- * Construct the SubscriptionQueryException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public SubscriptionQueryException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to retrieve subscription";
- String bitPayCode = "BITPAY-SUBSCRIPTION-GET";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/SubscriptionUpdateException.java b/src/main/java/com/bitpay/sdk/exceptions/SubscriptionUpdateException.java
deleted file mode 100644
index 0254572b..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/SubscriptionUpdateException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a PUT when the Subscription cannot be updated.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 03
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 030002
- *
- *
- * @see Rest API Error Codes
- */
-public class SubscriptionUpdateException extends SubscriptionException {
- /**
- * Construct the SubscriptionUpdateException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public SubscriptionUpdateException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to update subscription";
- String bitPayCode = "BITPAY-SUBSCRIPTION-UPDATE";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/WalletException.java b/src/main/java/com/bitpay/sdk/exceptions/WalletException.java
deleted file mode 100644
index 5efeed06..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/WalletException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- * Exception which is extended by other exceptions related with Wallet.
- *
- * @see com.bitpay.sdk.exceptions.WalletQueryException
- *
- * @see Rest API Error Codes
- */
-public class WalletException extends BitPayException {
- /**
- * Construct the WalletException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public WalletException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "An unexpected error occurred while trying to manage wallets";
- String bitPayCode = "BITPAY-WALLET-GENERIC";
-
- if (message.isEmpty() || !message.contains("BITPAY-")) {
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
- }
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/exceptions/WalletQueryException.java b/src/main/java/com/bitpay/sdk/exceptions/WalletQueryException.java
deleted file mode 100644
index b324516b..00000000
--- a/src/main/java/com/bitpay/sdk/exceptions/WalletQueryException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay.
- * All rights reserved.
- */
-
-package com.bitpay.sdk.exceptions;
-
-/**
- *
- * Exception thrown for a GET when the Wallet cannot be retrieved.
- *
- *
- * - First two digits: HTTP method
- * - Second two digits: Resource
- * - Final two digits: Error
- *
- * HTTP method digits for this class: 02
- * Resource digits for the this class: 00
- * Error digits for this class:
- *
- * - 00 - Generic server error
- * - 01 - Resource not found
- * - 02 - Invalid parameters
- * - 03 - Missing parameters
- *
- *
- * eg 020002
- *
- *
- * @see Rest API Error Codes
- */
-public class WalletQueryException extends WalletException {
- /**
- * Construct the WalletQueryException.
- *
- * @param status String [optional] The Exception code to throw.
- * @param message String [optional] The Exception message to throw.
- */
- public WalletQueryException(
- String status,
- String message
- ) {
- super(status, buildMessage(message));
- }
-
- private static String buildMessage(String message) {
- String bitPayMessage = "Failed to retrieve supported wallets";
- String bitPayCode = "BITPAY-WALLET-GET";
-
- message = bitPayCode + ": " + bitPayMessage + " -> " + message;
-
- return message;
- }
-}
diff --git a/src/main/java/com/bitpay/sdk/logger/BitPayLogger.java b/src/main/java/com/bitpay/sdk/logger/BitPayLogger.java
new file mode 100644
index 00000000..058536d3
--- /dev/null
+++ b/src/main/java/com/bitpay/sdk/logger/BitPayLogger.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2019 BitPay.
+ * All rights reserved.
+ */
+
+package com.bitpay.sdk.logger;
+
+public interface BitPayLogger {
+
+ void logRequest(
+ String method,
+ String endpoint,
+ String json
+ );
+
+ void logResponse(
+ String method,
+ String endpoint,
+ String json
+ );
+
+ void logError(String message);
+}
diff --git a/src/main/java/com/bitpay/sdk/logger/EmptyLogger.java b/src/main/java/com/bitpay/sdk/logger/EmptyLogger.java
new file mode 100644
index 00000000..27ea535d
--- /dev/null
+++ b/src/main/java/com/bitpay/sdk/logger/EmptyLogger.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2019 BitPay.
+ * All rights reserved.
+ */
+
+package com.bitpay.sdk.logger;
+
+public class EmptyLogger implements BitPayLogger {
+
+ @Override
+ public void logRequest(String method, String endpoint, String json) {
+ }
+
+ @Override
+ public void logResponse(String method, String endpoint, String json) {
+ }
+
+ @Override
+ public void logError(String message) {
+ }
+}
diff --git a/src/main/java/com/bitpay/sdk/logger/LoggerProvider.java b/src/main/java/com/bitpay/sdk/logger/LoggerProvider.java
new file mode 100644
index 00000000..a5ef1967
--- /dev/null
+++ b/src/main/java/com/bitpay/sdk/logger/LoggerProvider.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2019 BitPay.
+ * All rights reserved.
+ */
+
+package com.bitpay.sdk.logger;
+
+import java.util.Objects;
+
+public class LoggerProvider {
+
+ private static BitPayLogger logger = null;
+
+ private LoggerProvider() {
+ }
+
+ public static BitPayLogger getLogger() {
+ if (Objects.isNull(logger)) {
+ logger = new EmptyLogger();
+ }
+
+ return logger;
+ }
+
+ /**
+ * Set BitPayLogger.
+ *
+ * @param bitPayLogger BitPayLogger
+ */
+ public static void setLogger(BitPayLogger bitPayLogger) {
+ logger = bitPayLogger;
+ }
+}
diff --git a/src/main/java/com/bitpay/sdk/logger/Slf4jLogger.java b/src/main/java/com/bitpay/sdk/logger/Slf4jLogger.java
new file mode 100644
index 00000000..8f8060f8
--- /dev/null
+++ b/src/main/java/com/bitpay/sdk/logger/Slf4jLogger.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2019 BitPay.
+ * All rights reserved.
+ */
+
+//package com.bitpay.sdk.logger;
+//
+//import org.slf4j.LoggerFactory;
+//
+//public class Slf4jLogger implements BitPayLogger {
+//
+// private static final org.slf4j.Logger logger = LoggerFactory.getLogger(Slf4jLogger.class);
+//
+// @Override
+// public void logRequest(String method, String endpoint, String json) {
+// logger.info("Request method: " + method + " Endpoint: " + endpoint + " Json: " + json);
+// }
+//
+// @Override
+// public void logResponse(String method, String endpoint, String json) {
+// logger.info("Response method: " + method + " Endpoint: " + endpoint + " Json: " + json);
+// }
+//
+// @Override
+// public void logError(String message) {
+// logger.error(message);
+// }
+//}
diff --git a/src/main/java/com/bitpay/sdk/model/bill/Bill.java b/src/main/java/com/bitpay/sdk/model/bill/Bill.java
index 03189dfd..94e0994b 100644
--- a/src/main/java/com/bitpay/sdk/model/bill/Bill.java
+++ b/src/main/java/com/bitpay/sdk/model/bill/Bill.java
@@ -5,7 +5,8 @@
package com.bitpay.sdk.model.bill;
-import com.bitpay.sdk.exceptions.BitPayException;
+import com.bitpay.sdk.exceptions.BitPayExceptionProvider;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
import com.bitpay.sdk.model.Currency;
import com.bitpay.sdk.model.ModelConfiguration;
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -120,12 +121,12 @@ public String getCurrency() {
* Sets ISO 4217 3-character currency code. This is the currency associated with the price field.
*
* @param currency the currency
- * @throws BitPayException the bit pay exception
+ * @throws BitPayGenericException the bit pay exception
*/
@JsonProperty("currency")
- public void setCurrency(final String currency) throws BitPayException {
+ public void setCurrency(final String currency) throws BitPayGenericException {
if (!Currency.isValid(currency)) {
- throw new BitPayException(null, "Error: currency code must be a type of Model.Currency");
+ BitPayExceptionProvider.throwInvalidCurrencyException(currency);
}
this.currency = currency;
diff --git a/src/main/java/com/bitpay/sdk/model/invoice/Invoice.java b/src/main/java/com/bitpay/sdk/model/invoice/Invoice.java
index 7aa558f6..e43f622c 100644
--- a/src/main/java/com/bitpay/sdk/model/invoice/Invoice.java
+++ b/src/main/java/com/bitpay/sdk/model/invoice/Invoice.java
@@ -5,7 +5,8 @@
package com.bitpay.sdk.model.invoice;
-import com.bitpay.sdk.exceptions.BitPayException;
+import com.bitpay.sdk.exceptions.BitPayExceptionProvider;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
import com.bitpay.sdk.model.Currency;
import com.bitpay.sdk.model.ModelConfiguration;
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -198,13 +199,13 @@ public String getCurrency() {
* This is the currency associated with the price field.
*
* @param currency the currency
- * @throws BitPayException the bit pay exception
+ * @throws BitPayGenericException BitPayGenericException class
* @see Supported currencies
*/
@JsonProperty("currency")
- public void setCurrency(final String currency) throws BitPayException {
+ public void setCurrency(final String currency) throws BitPayGenericException {
if (!Currency.isValid(currency)) {
- throw new BitPayException(null, "Error: currency code must be a type of Model.Currency");
+ BitPayExceptionProvider.throwInvalidCurrencyException(currency);
}
this.currency = currency;
@@ -649,12 +650,12 @@ public String getSelectedTransactionCurrency() {
* "DOGE", "DAI" and "WBTC". If not yet selected, this field will not be returned.
*
* @param selectedTransactionCurrency the selected transaction currency
- * @throws BitPayException the bit pay exception
+ * @throws BitPayGenericException BitPayGenericException class
*/
@JsonProperty("selectedTransactionCurrency")
- public void setSelectedTransactionCurrency(final String selectedTransactionCurrency) throws BitPayException {
+ public void setSelectedTransactionCurrency(final String selectedTransactionCurrency) throws BitPayGenericException {
if (!Currency.isValid(selectedTransactionCurrency)) {
- throw new BitPayException(null, "Error: selectedTransactionCurrency code must be a type of Model.Currency");
+ BitPayExceptionProvider.throwInvalidCurrencyException(selectedTransactionCurrency);
}
this.selectedTransactionCurrency = this.currency;
diff --git a/src/main/java/com/bitpay/sdk/model/invoice/RefundInfo.java b/src/main/java/com/bitpay/sdk/model/invoice/RefundInfo.java
index 888fbc3b..2041260a 100644
--- a/src/main/java/com/bitpay/sdk/model/invoice/RefundInfo.java
+++ b/src/main/java/com/bitpay/sdk/model/invoice/RefundInfo.java
@@ -5,7 +5,8 @@
package com.bitpay.sdk.model.invoice;
-import com.bitpay.sdk.exceptions.BitPayException;
+import com.bitpay.sdk.exceptions.BitPayExceptionProvider;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
import com.bitpay.sdk.model.Currency;
import com.bitpay.sdk.model.ModelConfiguration;
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -68,12 +69,12 @@ public String getCurrency() {
* Sets reference currency used for the refund, usually the same as the currency used to create the invoice.
*
* @param currency the currency
- * @throws BitPayException the bit pay exception
+ * @throws BitPayGenericException BitPayGenericException class
*/
@JsonProperty("currency")
- public void setCurrency(String currency) throws BitPayException {
+ public void setCurrency(String currency) throws BitPayGenericException {
if (!Currency.isValid(currency)) {
- throw new BitPayException(null, "Error: currency code must be a type of Model.Currency");
+ BitPayExceptionProvider.throwInvalidCurrencyException(currency);
}
this.currency = currency;
diff --git a/src/main/java/com/bitpay/sdk/model/payout/Payout.java b/src/main/java/com/bitpay/sdk/model/payout/Payout.java
index a5acfcb1..b8e8b25d 100644
--- a/src/main/java/com/bitpay/sdk/model/payout/Payout.java
+++ b/src/main/java/com/bitpay/sdk/model/payout/Payout.java
@@ -5,7 +5,8 @@
package com.bitpay.sdk.model.payout;
-import com.bitpay.sdk.exceptions.BitPayException;
+import com.bitpay.sdk.exceptions.BitPayExceptionProvider;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
import com.bitpay.sdk.model.Currency;
import com.bitpay.sdk.model.ModelConfiguration;
import com.bitpay.sdk.util.DateDeserializer;
@@ -162,12 +163,12 @@ public String getCurrency() {
* Sets currency code set for the batch amount (ISO 4217 3-character currency code).
*
* @param currency the currency
- * @throws BitPayException the bit pay exception
+ * @throws BitPayGenericException the bit pay exception
*/
@JsonProperty("currency")
- public void setCurrency(final String currency) throws BitPayException {
+ public void setCurrency(final String currency) throws BitPayGenericException {
if (!Currency.isValid(currency)) {
- throw new BitPayException(null, "Error: currency code must be a type of Model.Currency");
+ BitPayExceptionProvider.throwInvalidCurrencyException(currency);
}
this.currency = currency;
}
@@ -194,12 +195,12 @@ public String getLedgerCurrency() {
* e.g. your settlement currency.
*
* @param ledgerCurrency the ledger currency
- * @throws BitPayException the bit pay exception
+ * @throws BitPayGenericException the bit pay exception
*/
@JsonProperty("ledgerCurrency")
- public void setLedgerCurrency(final String ledgerCurrency) throws BitPayException {
+ public void setLedgerCurrency(final String ledgerCurrency) throws BitPayGenericException {
if (!Currency.isValid(ledgerCurrency)) {
- throw new BitPayException(null, "Error: currency code must be a type of Model.Currency");
+ BitPayExceptionProvider.throwInvalidCurrencyException(ledgerCurrency);
}
this.ledgerCurrency = ledgerCurrency;
}
diff --git a/src/main/java/com/bitpay/sdk/model/rate/Rates.java b/src/main/java/com/bitpay/sdk/model/rate/Rates.java
index d4c86296..1c53333e 100644
--- a/src/main/java/com/bitpay/sdk/model/rate/Rates.java
+++ b/src/main/java/com/bitpay/sdk/model/rate/Rates.java
@@ -6,7 +6,8 @@
package com.bitpay.sdk.model.rate;
import com.bitpay.sdk.client.RateClient;
-import com.bitpay.sdk.exceptions.RateQueryException;
+import com.bitpay.sdk.exceptions.BitPayApiException;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.List;
@@ -42,14 +43,11 @@ public List getRates() {
* Update rates.
*
* @param rateClient the rate client
- * @throws RateQueryException the rate query exception
+ * @throws BitPayGenericException BitPayGenericException class
+ * @throws BitPayApiException BitPayApiException class
*/
- public void update(RateClient rateClient) throws RateQueryException {
- try {
- this.rates = rateClient.getRates().getRates();
- } catch (Exception e) {
- throw new RateQueryException(null, e.getMessage());
- }
+ public void update(RateClient rateClient) throws BitPayGenericException, BitPayApiException {
+ this.rates = rateClient.getRates().getRates();
}
/**
diff --git a/src/main/java/com/bitpay/sdk/util/KeyUtils.java b/src/main/java/com/bitpay/sdk/util/KeyUtils.java
index 424f01ce..75bc1405 100644
--- a/src/main/java/com/bitpay/sdk/util/KeyUtils.java
+++ b/src/main/java/com/bitpay/sdk/util/KeyUtils.java
@@ -5,6 +5,8 @@
package com.bitpay.sdk.util;
+import com.bitpay.sdk.exceptions.BitPayExceptionProvider;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -12,7 +14,6 @@
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.net.URI;
import java.net.URISyntaxException;
@@ -21,6 +22,7 @@
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.ECKey.ECDSASignature;
import org.bitcoinj.core.Sha256Hash;
+import org.bitcoinj.crypto.KeyCrypterException;
/**
* The type Key utils.
@@ -65,11 +67,10 @@ public static ECKey createEcKey() {
* @param privateKey the private key
* @return the ec key
*/
- public static ECKey createEcKeyFromHexString(String privateKey) {
+ public static ECKey createEcKeyFromHexString(String privateKey) throws BitPayGenericException {
byte[] bytes = hexToBytes(privateKey);
- ECKey ecKey = ECKey.fromASN1(bytes);
- return ecKey;
+ return ECKey.fromASN1(bytes);
}
/**
@@ -79,7 +80,7 @@ public static ECKey createEcKeyFromHexString(String privateKey) {
* @return the ec key
* @throws IOException the io exception
*/
- public static ECKey createEcKeyFromHexStringFile(String privKeyFile) throws IOException {
+ public static ECKey createEcKeyFromHexStringFile(String privKeyFile) throws IOException, BitPayGenericException {
return createEcKeyFromHexString(getKeyStringFromFile(privKeyFile));
}
@@ -224,9 +225,7 @@ public static void saveEcKeyAsHex(ECKey ecKey) throws IOException {
*/
public static String loadEcKeyAsHex(ECKey ecKey) throws IOException {
byte[] bytes = ecKey.toASN1();
- String keyHex = bytesToHex(bytes);
-
- return keyHex;
+ return bytesToHex(bytes);
}
/**
@@ -234,9 +233,9 @@ public static String loadEcKeyAsHex(ECKey ecKey) throws IOException {
*
* @param ecKey the ec key
* @return the string
- * @throws IllegalArgumentException the illegal argument exception
+ * @throws BitPayGenericException the illegal argument exception
*/
- public static String deriveSin(ECKey ecKey) throws IllegalArgumentException {
+ public static String deriveSin(ECKey ecKey) throws BitPayGenericException {
// Get sha256 hash and then the RIPEMD-160 hash of the public key (this call gets the result in one step).
byte[] pubKeyHash = ecKey.getPubKeyHash();
@@ -268,20 +267,28 @@ public static String deriveSin(ECKey ecKey) throws IllegalArgumentException {
* @param key the key
* @param input the input
* @return the string
- * @throws UnsupportedEncodingException the unsupported encoding exception
+ * @throws BitPayGenericException BitPayGenericException class
*/
public static String sign(
ECKey key,
String input
- ) throws UnsupportedEncodingException {
- byte[] data = input.getBytes(StandardCharsets.UTF_8);
+ ) throws BitPayGenericException {
+ String result = null;
- Sha256Hash hash = Sha256Hash.of(data);
- ECDSASignature sig = key.sign(hash, null);
+ try {
+ byte[] data = input.getBytes(StandardCharsets.UTF_8);
- byte[] bytes = sig.encodeToDER();
+ Sha256Hash hash = Sha256Hash.of(data);
+ ECDSASignature sig = key.sign(hash, null);
- return bytesToHex(bytes);
+ byte[] bytes = sig.encodeToDER();
+
+ result = bytesToHex(bytes);
+ } catch (KeyCrypterException e) {
+ BitPayExceptionProvider.throwGenericExceptionWithMessage("Wrong ecKey. " + e.getMessage());
+ }
+
+ return result;
}
private static int getHexVal(char hex) {
@@ -294,13 +301,14 @@ private static int getHexVal(char hex) {
*
* @param hex the hex
* @return the byte []
- * @throws IllegalArgumentException the illegal argument exception
+ * @throws BitPayGenericException BitPayGenericException class
*/
- public static byte[] hexToBytes(String hex) throws IllegalArgumentException {
+ public static byte[] hexToBytes(String hex) throws BitPayGenericException {
char[] hexArray = hex.toCharArray();
if (hex.length() % 2 == 1) {
- throw new IllegalArgumentException("Error: The binary key cannot have an odd number of digits");
+ BitPayExceptionProvider.throwGenericExceptionWithMessage(
+ "Error: The binary key cannot have an odd number of digits");
}
byte[] arr = new byte[hex.length() >> 1];
diff --git a/src/main/java/com/bitpay/sdk/util/TokenContainer.java b/src/main/java/com/bitpay/sdk/util/TokenContainer.java
index 33502a8b..57f5b193 100644
--- a/src/main/java/com/bitpay/sdk/util/TokenContainer.java
+++ b/src/main/java/com/bitpay/sdk/util/TokenContainer.java
@@ -6,7 +6,8 @@
package com.bitpay.sdk.util;
import com.bitpay.sdk.Config;
-import com.bitpay.sdk.exceptions.BitPayException;
+import com.bitpay.sdk.exceptions.BitPayExceptionProvider;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
import com.bitpay.sdk.model.Facade;
import com.fasterxml.jackson.databind.JsonNode;
import java.util.Hashtable;
@@ -49,9 +50,9 @@ public TokenContainer(Config configuration) {
*
* @param facade The identifier for the desired resource.
* @return The token associated with resource.
- * @throws BitPayException BitPayException class
+ * @throws BitPayGenericException BitPayGenericException class
*/
- public String getAccessToken(Facade facade) throws BitPayException {
+ public String getAccessToken(Facade facade) throws BitPayGenericException {
return this.getAccessToken(facade.toString());
}
@@ -60,11 +61,12 @@ public String getAccessToken(Facade facade) throws BitPayException {
*
* @param key The identifier for the desired resource.
* @return The token associated with resource.
- * @throws BitPayException BitPayException class
+ * @throws BitPayGenericException BitPayGenericException class
*/
- public String getAccessToken(String key) throws BitPayException {
+ public String getAccessToken(String key) throws BitPayGenericException {
if (!this.data.containsKey(key)) {
- throw new BitPayException(null, "There is no token for the specified key : " + key);
+ BitPayExceptionProvider.throwGenericExceptionWithMessage(
+ "There is no token for the specified key : " + key);
}
return this.data.get(key);
diff --git a/src/test/java/com/bitpay/sdk/ClientTest.java b/src/test/java/com/bitpay/sdk/ClientTest.java
index bfe878f2..64354d0d 100644
--- a/src/test/java/com/bitpay/sdk/ClientTest.java
+++ b/src/test/java/com/bitpay/sdk/ClientTest.java
@@ -5,16 +5,12 @@
package com.bitpay.sdk;
import com.bitpay.sdk.client.BitPayClient;
-import com.bitpay.sdk.exceptions.BitPayException;
-import com.bitpay.sdk.exceptions.InvoiceCancellationException;
-import com.bitpay.sdk.exceptions.RefundCreationException;
-import com.bitpay.sdk.exceptions.RefundQueryException;
-import com.bitpay.sdk.exceptions.RefundUpdateException;
+import com.bitpay.sdk.exceptions.BitPayApiException;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
+import com.bitpay.sdk.exceptions.BitPayValidationException;
+import com.bitpay.sdk.model.Facade;
import com.bitpay.sdk.model.bill.Bill;
import com.bitpay.sdk.model.bill.Item;
-import com.bitpay.sdk.model.Facade;
-import com.bitpay.sdk.model.payout.PayoutGroup;
-import com.bitpay.sdk.model.payout.PayoutGroupFailed;
import com.bitpay.sdk.model.invoice.Buyer;
import com.bitpay.sdk.model.invoice.Invoice;
import com.bitpay.sdk.model.invoice.InvoiceEventToken;
@@ -22,6 +18,8 @@
import com.bitpay.sdk.model.ledger.Ledger;
import com.bitpay.sdk.model.ledger.LedgerEntry;
import com.bitpay.sdk.model.payout.Payout;
+import com.bitpay.sdk.model.payout.PayoutGroup;
+import com.bitpay.sdk.model.payout.PayoutGroupFailed;
import com.bitpay.sdk.model.payout.PayoutRecipient;
import com.bitpay.sdk.model.payout.PayoutRecipients;
import com.bitpay.sdk.model.rate.Rate;
@@ -42,9 +40,7 @@
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FileUtils;
-import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.message.BasicNameValuePair;
import org.junit.jupiter.api.Assertions;
@@ -77,10 +73,6 @@ public class ClientTest {
private TokenContainer accessTokens;
@Mock
private GuidGenerator guidGenerator;
- @Mock
- private HttpResponse httpResponse;
- @Mock
- private HttpEntity httpEntity;
@BeforeEach
public void clearResourceClients() {
@@ -88,7 +80,7 @@ public void clearResourceClients() {
}
@Test
- public void it_should_provide_pos_client() throws BitPayException {
+ public void it_should_provide_pos_client() throws BitPayGenericException {
// given
String posToken = "posToken";
@@ -100,7 +92,7 @@ public void it_should_provide_pos_client() throws BitPayException {
}
@Test
- public void it_should_provide_client_by_key() throws BitPayException {
+ public void it_should_provide_client_by_key() throws BitPayGenericException {
// given
String privateKey =
"3082013102010104208ae30afbc7e93cb10cb983f70863e546b53f0b2c6158b1a71b576fd09790cff3a081e33081e0020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f3044042000000000000000000000000000000000000000000000000000000000000000000420000000000000000000000000000000000000000000000000000000000000000704410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a124032200035d6a7e38d7c08b8a626e2390d0360a72a58bd1c5e1348e0eb810d4bbab3d3adf";
@@ -116,7 +108,7 @@ public void it_should_provide_client_by_key() throws BitPayException {
}
@Test
- public void it_should_provide_client_by_config() throws BitPayException {
+ public void it_should_provide_client_by_config() throws BitPayGenericException {
// given
String path = System.getProperty("user.dir") + "/src/test/java/com/bitpay/sdk/BitPay.config.json";
@@ -129,8 +121,8 @@ public void it_should_provide_client_by_config() throws BitPayException {
}
@Test
- public void it_should_throws_bitpayexception_for_invalid_privateKey() throws BitPayException {
- BitPayException exception = Assertions.assertThrows(BitPayException.class, () -> {
+ public void it_should_throws_BitPayApiException_for_invalid_privateKey() {
+ BitPayGenericException exception = Assertions.assertThrows(BitPayGenericException.class, () -> {
new Client(
Environment.TEST,
new PrivateKey("invalid"),
@@ -140,23 +132,19 @@ public void it_should_throws_bitpayexception_for_invalid_privateKey() throws Bit
);
});
- Assertions.assertEquals(
- "Status: 000000 -> Reason: failed to deserialize BitPay server response (Config) : Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Private Key file not found",
- exception.getMessage()
- );
+ Assertions.assertEquals("Private Key file not found", exception.getMessage());
}
@Test
- public void it_should_authorize_client_by_pairing_code() throws BitPayException {
+ public void it_should_authorize_client_by_pairing_code() throws BitPayApiException, BitPayGenericException {
// given
String pairingCode = "123123123";
Mockito.when(this.guidGenerator.execute()).thenReturn(EXAMPLE_UUID);
- Mockito.when(this.bitPayClient.post("tokens",
- "{\"guid\":\"37bd36bd-6fcb-409c-a907-47f9244302aa\",\"id\":\"Tf2yXsY49iFyDfxt3b2kf9VPRMwPxxAyCRW\",\"pairingCode\":\"123123123\"}"))
- .thenReturn(this.httpResponse);
final String responseString =
"[{\"policies\":[{\"policy\":\"id\",\"method\":\"active\",\"params\":[\"Tf2yXsY49iFyDfxt3b2kf9VPRMwPxxAyCRW\"]}],\"token\":\"t0k3n\",\"facade\":\"merchant\",\"dateCreated\":1668425446554,\"pairingExpiration\":1668511846554,\"pairingCode\":\"123123123\"}]";
- Mockito.when(this.bitPayClient.responseToJsonString(httpResponse)).thenReturn(responseString);
+ Mockito.when(this.bitPayClient.post("tokens",
+ "{\"guid\":\"37bd36bd-6fcb-409c-a907-47f9244302aa\",\"id\":\"Tf2yXsY49iFyDfxt3b2kf9VPRMwPxxAyCRW\",\"pairingCode\":\"123123123\"}"))
+ .thenReturn(responseString);
Client testedClass = this.getTestedClass();
@@ -164,20 +152,19 @@ public void it_should_authorize_client_by_pairing_code() throws BitPayException
testedClass.authorizeClient(pairingCode);
// then
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Mockito.verify(this.accessTokens, Mockito.times(1)).put("merchant", "t0k3n");
}
@Test
- public void it_should_authorize_client_by_facade() throws BitPayException {
+ public void it_should_authorize_client_by_facade() throws BitPayApiException, BitPayGenericException {
// given
Mockito.when(this.guidGenerator.execute()).thenReturn(EXAMPLE_UUID);
- Mockito.when(this.bitPayClient.post("tokens",
- "{\"count\":1,\"facade\":\"merchant\",\"guid\":\"37bd36bd-6fcb-409c-a907-47f9244302aa\",\"id\":\"Tf2yXsY49iFyDfxt3b2kf9VPRMwPxxAyCRW\"}"))
- .thenReturn(this.httpResponse);
+
final String responseString =
"[{\"policies\":[{\"policy\":\"id\",\"method\":\"inactive\",\"params\":[\"Tf2yXsY49iFyDfxt3b2kf9VPRMwPxxAyCRW\"]}],\"token\":\"G7XM9fcM1gtCN7DUr8ZWtPGVFLTKiYWanHR4kvqsnjP3\",\"facade\":\"merchant\",\"label\":\"merchantwebsite.com\",\"dateCreated\":1621340364865,\"pairingExpiration\":1621426764865,\"pairingCode\":\"C4Lg7oW\"}]";
- Mockito.when(this.bitPayClient.responseToJsonString(httpResponse)).thenReturn(responseString);
+ Mockito.when(this.bitPayClient.post("tokens",
+ "{\"count\":1,\"facade\":\"merchant\",\"guid\":\"37bd36bd-6fcb-409c-a907-47f9244302aa\",\"id\":\"Tf2yXsY49iFyDfxt3b2kf9VPRMwPxxAyCRW\"}"))
+ .thenReturn(responseString);
Client testedClass = this.getTestedClass();
@@ -185,22 +172,20 @@ public void it_should_authorize_client_by_facade() throws BitPayException {
testedClass.authorizeClient(Facade.MERCHANT);
// then
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Mockito.verify(this.accessTokens, Mockito.times(1))
.put("merchant", "G7XM9fcM1gtCN7DUr8ZWtPGVFLTKiYWanHR4kvqsnjP3");
}
@Test
- public void it_should_test_requestClientAuthorization() throws BitPayException {
+ public void it_should_test_requestClientAuthorization() throws BitPayApiException, BitPayGenericException {
// given
String pairingCode = "123123123";
Mockito.when(this.guidGenerator.execute()).thenReturn(EXAMPLE_UUID);
- Mockito.when(this.bitPayClient.post("tokens",
- "{\"guid\":\"37bd36bd-6fcb-409c-a907-47f9244302aa\",\"id\":\"Tf2yXsY49iFyDfxt3b2kf9VPRMwPxxAyCRW\",\"pairingCode\":\"123123123\"}"))
- .thenReturn(this.httpResponse);
final String responseString =
"[{\"policies\":[{\"policy\":\"id\",\"method\":\"active\",\"params\":[\"Tf2yXsY49iFyDfxt3b2kf9VPRMwPxxAyCRW\"]}],\"token\":\"t0k3n\",\"facade\":\"merchant\",\"dateCreated\":1668425446554,\"pairingExpiration\":1668511846554,\"pairingCode\":\"\"}]";
- Mockito.when(this.bitPayClient.responseToJsonString(httpResponse)).thenReturn(responseString);
+ Mockito.when(this.bitPayClient.post("tokens",
+ "{\"guid\":\"37bd36bd-6fcb-409c-a907-47f9244302aa\",\"id\":\"Tf2yXsY49iFyDfxt3b2kf9VPRMwPxxAyCRW\",\"pairingCode\":\"123123123\"}"))
+ .thenReturn(responseString);
Client testedClass = this.getTestedClass();
@@ -208,12 +193,11 @@ public void it_should_test_requestClientAuthorization() throws BitPayException {
testedClass.authorizeClient(pairingCode);
// then
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Mockito.verify(this.accessTokens, Mockito.times(1)).put("merchant", "t0k3n");
}
@Test
- public void it_should_test_getAccessToken() throws BitPayException {
+ public void it_should_test_getAccessToken() throws BitPayGenericException {
// given
Client testedClass = this.getTestedClass();
String tokenKey = "tokenKey";
@@ -226,18 +210,16 @@ public void it_should_test_getAccessToken() throws BitPayException {
}
@Test
- public void it_should_test_getCurrencyInfo() throws IOException {
+ public void it_should_test_getCurrencyInfo() throws BitPayGenericException, BitPayApiException {
// given
String response = getPreparedJsonDataFromFile("currencies.json");
InputStream inputStream = new ByteArrayInputStream(response.getBytes());
- Mockito.when(this.bitPayClient.get("currencies")).thenReturn(this.httpResponse);
- Mockito.when(this.httpResponse.getEntity()).thenReturn(this.httpEntity);
- Mockito.when(this.httpEntity.getContent()).thenReturn(inputStream);
+ Mockito.when(this.bitPayClient.get("currencies")).thenReturn(response);
Client testedClass = this.getTestedClass();
// when
- Map result = testedClass.getCurrencyInfo("USD");
+ Map result = testedClass.getCurrencyInfo("USD");
// then
Assertions.assertEquals("USD", result.get("code"));
@@ -246,13 +228,12 @@ public void it_should_test_getCurrencyInfo() throws IOException {
}
@Test
- public void it_should_test_create_invoice_by_merchant() throws IOException {
+ public void it_should_test_create_invoice_by_merchant()
+ throws BitPayGenericException, BitPayApiException {
// given
Invoice invoice = getInvoiceExample();
Mockito.when(this.bitPayClient.post("invoices", getPreparedJsonDataFromFile("createInvoiceRequest.json"), true))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("createInvoiceResponse.json"));
Mockito.when(this.accessTokens.tokenExists(Facade.MERCHANT)).thenReturn(true);
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT))
@@ -275,14 +256,12 @@ public void it_should_test_create_invoice_by_merchant() throws IOException {
}
@Test
- public void it_should_test_createInvoice_by_pos() throws IOException {
+ public void it_should_test_createInvoice_by_pos() throws BitPayGenericException, BitPayApiException {
// given
Invoice invoice = getInvoiceExample();
Mockito
.when(this.bitPayClient.post("invoices", getPreparedJsonDataFromFile("createInvoiceRequest.json"), false))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("createInvoiceResponse.json"));
Mockito.when(this.accessTokens.tokenExists(Facade.MERCHANT)).thenReturn(false);
Mockito.when(this.accessTokens.getAccessToken(Facade.POS)).thenReturn("someToken");
@@ -304,7 +283,7 @@ public void it_should_test_createInvoice_by_pos() throws IOException {
}
@Test
- public void it_should_test_getInvoice_by_merchant() throws BitPayException {
+ public void it_should_test_getInvoice_by_merchant() throws BitPayApiException, BitPayGenericException {
// given
String id = "UZjwcYkWAKfTMn9J1yyfs4";
final String facadeToken = "someToken";
@@ -313,8 +292,6 @@ public void it_should_test_getInvoice_by_merchant() throws BitPayException {
Mockito.when(this.bitPayClient
.get(ArgumentMatchers.eq("invoices/" + id), ArgumentMatchers.eq(params), ArgumentMatchers.eq(true)))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getInvoice.json"));
Mockito.when(this.accessTokens.tokenExists(Facade.MERCHANT)).thenReturn(true);
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT))
@@ -325,14 +302,13 @@ public void it_should_test_getInvoice_by_merchant() throws BitPayException {
Invoice result = testedClass.getInvoice(id);
// then
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Mockito.verify(this.bitPayClient, Mockito.times(1))
.get(ArgumentMatchers.eq("invoices/" + id), ArgumentMatchers.eq(params), ArgumentMatchers.eq(true));
Assertions.assertEquals("chc9kj52-04g0-4b6f-941d-3a844e352758", result.getGuid());
}
@Test
- public void it_should_test_getInvoice_by_pos() throws BitPayException {
+ public void it_should_test_getInvoice_by_pos() throws BitPayApiException, BitPayGenericException {
// given
String id = "UZjwcYkWAKfTMn9J1yyfs4";
final String facadeToken = "someToken";
@@ -341,8 +317,6 @@ public void it_should_test_getInvoice_by_pos() throws BitPayException {
Mockito.when(this.bitPayClient
.get(ArgumentMatchers.eq("invoices/" + id), ArgumentMatchers.eq(params), ArgumentMatchers.eq(false)))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getInvoice.json"));
Mockito.when(this.accessTokens.tokenExists(Facade.MERCHANT)).thenReturn(false);
Mockito.when(this.accessTokens.getAccessToken(Facade.POS)).thenReturn(facadeToken);
@@ -352,14 +326,13 @@ public void it_should_test_getInvoice_by_pos() throws BitPayException {
Invoice result = testedClass.getInvoice(id);
// then
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Mockito.verify(this.bitPayClient, Mockito.times(1))
.get(ArgumentMatchers.eq("invoices/" + id), ArgumentMatchers.eq(params), ArgumentMatchers.eq(false));
Assertions.assertEquals("chc9kj52-04g0-4b6f-941d-3a844e352758", result.getGuid());
}
@Test
- public void it_should_test_getInvoiceByGuid() throws BitPayException {
+ public void it_should_test_getInvoiceByGuid() throws BitPayApiException, BitPayGenericException {
// given
String guid = "chc9kj52-04g0-4b6f-941d-3a844e352758";
String merchantToken = "merchantToken";
@@ -368,8 +341,6 @@ public void it_should_test_getInvoiceByGuid() throws BitPayException {
Mockito.when(this.bitPayClient
.get(ArgumentMatchers.eq("invoices/guid/" + guid), ArgumentMatchers.eq(expectedParams),
ArgumentMatchers.eq(true)))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getInvoice.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -379,12 +350,11 @@ public void it_should_test_getInvoiceByGuid() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals("chc9kj52-04g0-4b6f-941d-3a844e352758", result.getGuid());
}
@Test
- public void it_should_test_getInvoices() throws BitPayException {
+ public void it_should_test_getInvoices() throws BitPayApiException, BitPayGenericException {
// given
String merchantToken = "merchantToken";
List expectedParams = new ArrayList();
@@ -394,8 +364,6 @@ public void it_should_test_getInvoices() throws BitPayException {
expectedParams.add(new BasicNameValuePair("status", "complete"));
expectedParams.add(new BasicNameValuePair("limit", "1"));
Mockito.when(this.bitPayClient.get(ArgumentMatchers.eq("invoices"), ArgumentMatchers.eq(expectedParams)))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getInvoices.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -412,19 +380,16 @@ public void it_should_test_getInvoices() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertFalse(result.isEmpty());
}
@Test
- public void it_should_get_invoice_event_token() throws BitPayException {
+ public void it_should_get_invoice_event_token() throws BitPayApiException, BitPayGenericException {
// given
String merchantToken = "merchantToken";
List expectedParams = new ArrayList();
expectedParams.add(new BasicNameValuePair("token", merchantToken));
Mockito.when(this.bitPayClient.get(ArgumentMatchers.eq("invoices/GZRP3zgNHTDf8F5BmdChKz/events"), ArgumentMatchers.eq(expectedParams)))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getInvoiceEventToken.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -434,15 +399,14 @@ public void it_should_get_invoice_event_token() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals("4MuqDPt93i9Xbf8SnAPniwbGeNLW8A3ScgAmukFMgFUFRqTLuuhVdAFfePPysVqL2P", result.getToken());
Assertions.assertEquals(Arrays.asList("payment", "confirmation"), result.getEvents());
Assertions.assertEquals(Arrays.asList("subscribe", "unsubscribe"), result.getActions());
}
@Test
- public void it_should_test_throws_exception_for_missing_arguments_in_updateInvoice() throws BitPayException {
- Assertions.assertThrows(BitPayException.class, () -> {
+ public void it_should_test_throws_validation_exception_for_missing_arguments_in_updateInvoice() throws BitPayValidationException {
+ Assertions.assertThrows(BitPayValidationException.class, () -> {
// given
final String merchantToken = "merchantToken";
final String invoiceId = "UZjwcYkWAKfTMn9J1yyfs4";
@@ -463,15 +427,13 @@ public void it_should_test_throws_exception_for_missing_arguments_in_updateInvoi
}
@Test
- public void it_should_test_updateInvoice() throws BitPayException {
+ public void it_should_test_updateInvoice() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String invoiceId = "UZjwcYkWAKfTMn9J1yyfs4";
Mockito.when(this.bitPayClient.update(ArgumentMatchers.eq("invoices/" + invoiceId),
ArgumentMatchers.eq("{\"buyerSms\":\"+12223334444\",\"token\":\"merchantToken\"}")))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getInvoice.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
@@ -488,12 +450,11 @@ public void it_should_test_updateInvoice() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals("chc9kj52-04g0-4b6f-941d-3a844e352758", result.getGuid());
}
@Test
- public void it_should_test_payInvoice() throws BitPayException {
+ public void it_should_test_payInvoice() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String invoiceId = "UZjwcYkWAKfTMn9J1yyfs4";
@@ -501,8 +462,6 @@ public void it_should_test_payInvoice() throws BitPayException {
Mockito.when(this.bitPayClient.update(ArgumentMatchers.eq("invoices/pay/" + invoiceId),
ArgumentMatchers.eq("{\"token\":\"merchantToken\",\"status\":\"complete\"}")))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getInvoice.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -515,12 +474,11 @@ public void it_should_test_payInvoice() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals("chc9kj52-04g0-4b6f-941d-3a844e352758", result.getGuid());
}
@Test
- public void it_should_force_cancel_invoice() throws BitPayException {
+ public void it_should_force_cancel_invoice() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String invoiceId = "UZjwcYkWAKfTMn9J1yyfs4";
@@ -530,9 +488,7 @@ public void it_should_force_cancel_invoice() throws BitPayException {
Mockito.when(this.bitPayClient.delete(
ArgumentMatchers.eq("invoices/" + invoiceId), ArgumentMatchers.eq(expectedParams))
- ).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getPreparedJsonDataFromFile("getCancelledInvoice.json"));
+ ).thenReturn(getPreparedJsonDataFromFile("getCancelledInvoice.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -542,12 +498,11 @@ public void it_should_force_cancel_invoice() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).delete("invoices/" + invoiceId, expectedParams);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals("payment#1234", result.getGuid());
}
@Test
- public void it_should_cancel_invoice() throws BitPayException {
+ public void it_should_cancel_invoice() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String invoiceId = "UZjwcYkWAKfTMn9J1yyfs4";
@@ -556,9 +511,7 @@ public void it_should_cancel_invoice() throws BitPayException {
Mockito.when(this.bitPayClient.delete(
ArgumentMatchers.eq("invoices/" + invoiceId), ArgumentMatchers.eq(expectedParams))
- ).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getPreparedJsonDataFromFile("getCancelledInvoice.json"));
+ ).thenReturn(getPreparedJsonDataFromFile("getCancelledInvoice.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -568,12 +521,11 @@ public void it_should_cancel_invoice() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).delete("invoices/" + invoiceId, expectedParams);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals("payment#1234", result.getGuid());
}
@Test
- public void it_should_cancel_invoice_by_guid() throws BitPayException {
+ public void it_should_cancel_invoice_by_guid() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String guidId = "payment#1234";
@@ -582,9 +534,7 @@ public void it_should_cancel_invoice_by_guid() throws BitPayException {
Mockito.when(this.bitPayClient.delete(
ArgumentMatchers.eq("invoices/guid/" + guidId), ArgumentMatchers.eq(expectedParams))
- ).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getPreparedJsonDataFromFile("getCancelledInvoice.json"));
+ ).thenReturn(getPreparedJsonDataFromFile("getCancelledInvoice.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -594,14 +544,13 @@ public void it_should_cancel_invoice_by_guid() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).delete("invoices/guid/" + guidId, expectedParams);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(guidId, result.getGuid());
}
@Test
- public void it_should_throws_exception_for_cancel_invoice_for_invalid_state_of_cancel() throws BitPayException {
- InvoiceCancellationException exception = Assertions.assertThrows(
- InvoiceCancellationException.class,
+ public void it_should_throws_exception_for_cancel_invoice_for_invalid_state_of_cancel() throws BitPayApiException {
+ BitPayApiException exception = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
final String merchantToken = "merchantToken";
final String guidId = "chc9kj52-04g0-4b6f-941d-3a844e352757";
@@ -610,25 +559,28 @@ public void it_should_throws_exception_for_cancel_invoice_for_invalid_state_of_c
Mockito.when(this.bitPayClient.delete(
ArgumentMatchers.eq("invoices/guid/" + guidId), ArgumentMatchers.eq(expectedParams))
- ).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenThrow(new BitPayException(null, "Error: Invalid invoice state for cancel"));
+ ).thenThrow(new BitPayApiException("Error: Invalid invoice state for cancel", "00000"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
// when
- Invoice result = testedClass.cancelInvoiceByGuid(guidId, false);
+ testedClass.cancelInvoiceByGuid(guidId, false);
}
);
Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-INVOICE-CANCEL: Failed to cancel invoice -> Error: Invalid invoice state for cancel",
+ "Error: Invalid invoice state for cancel",
exception.getMessage()
);
+
+ Assertions.assertEquals(
+ "00000",
+ exception.getCode()
+ );
}
@Test
- public void it_should_request_invoice_webhook_to_be_resent() throws BitPayException {
+ public void it_should_request_invoice_webhook_to_be_resent() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String invoiceId = "UZjwcYkWAKfTMn9J1yyfs4";
@@ -636,9 +588,7 @@ public void it_should_request_invoice_webhook_to_be_resent() throws BitPayExcept
Mockito.when(this.bitPayClient.post(
ArgumentMatchers.eq("invoices/" + invoiceId + "/notifications"), ArgumentMatchers.eq(requestJson))
- ).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn("\"Success\"");
+ ).thenReturn("\"Success\"");
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -648,20 +598,17 @@ public void it_should_request_invoice_webhook_to_be_resent() throws BitPayExcept
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).post("invoices/" + invoiceId + "/notifications", requestJson);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertTrue(result);
}
@Test
- public void it_should_create_refund() throws BitPayException {
+ public void it_should_create_refund() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String invoiceId = "UZjwcYkWAKfTMn9J1yyfs4";
final String createRefundJsonRequest = getPreparedJsonDataFromFile("createRefundRequest.json");
Mockito.when(this.bitPayClient.post("refunds/", createRefundJsonRequest, true))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("createRefundResponse.json"));
Mockito.when(this.guidGenerator.execute()).thenReturn(EXAMPLE_UUID);
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
@@ -684,21 +631,18 @@ public void it_should_create_refund() throws BitPayException {
createRefundJsonRequest,
true
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(invoiceId, result.getInvoice());
Assertions.assertEquals(EXAMPLE_UUID, result.getGuid());
}
@Test
- public void it_should_create_refund_with_guid() throws BitPayException {
+ public void it_should_create_refund_with_guid() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String invoiceId = "UZjwcYkWAKfTMn9J1yyfs4";
final String createRefundJsonRequest = getPreparedJsonDataFromFile("createRefundRequest.json");
Mockito.when(this.bitPayClient.post("refunds/", createRefundJsonRequest, true))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("createRefundResponse.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -722,21 +666,18 @@ public void it_should_create_refund_with_guid() throws BitPayException {
createRefundJsonRequest,
true
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(invoiceId, result.getInvoice());
Assertions.assertEquals(EXAMPLE_UUID, result.getGuid());
}
@Test
- public void it_should_create_refund_using_refund_object() throws BitPayException {
+ public void it_should_create_refund_using_refund_object() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String invoiceId = "UZjwcYkWAKfTMn9J1yyfs4";
final String createRefundJsonRequest = getPreparedJsonDataFromFile("createRefundRequest.json");
Mockito.when(this.bitPayClient.post("refunds/", createRefundJsonRequest, true))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("createRefundResponse.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -756,15 +697,14 @@ public void it_should_create_refund_using_refund_object() throws BitPayException
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).post("refunds/", createRefundJsonRequest, true);
Mockito.verify(this.guidGenerator, Mockito.times(0)).execute();
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(invoiceId, result.getInvoice());
Assertions.assertEquals(EXAMPLE_UUID, result.getGuid());
}
@Test
- public void it_should_throws_refundCreationException_for_missing_invoice_id_and_amount_for_createRefund() {
- RefundCreationException exception = Assertions.assertThrows(
- RefundCreationException.class,
+ public void it_should_throws_bitpay_validation_exception_for_missing_invoice_id_and_amount_for_createRefund() {
+ BitPayValidationException exception = Assertions.assertThrows(
+ BitPayValidationException.class,
() -> {
// given
Client testedClass = this.getTestedClass();
@@ -775,15 +715,15 @@ public void it_should_throws_refundCreationException_for_missing_invoice_id_and_
);
Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-REFUND-CREATE: Failed to create refund -> Invoice ID, amount and currency are required to issue a refund.",
+ "Invoice ID, amount and currency are required to issue a refund.",
exception.getMessage()
);
}
@Test
- public void it_should_throws_refundCreationException_for_invalid_sendRefundNotification() {
- RefundCreationException exception = Assertions.assertThrows(
- RefundCreationException.class,
+ public void it_should_throws_bitpay_api_exception_for_invalid_sendRefundNotification() {
+ BitPayApiException exception = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
// given
Client testedClass = this.getTestedClass();
@@ -791,7 +731,7 @@ public void it_should_throws_refundCreationException_for_invalid_sendRefundNotif
ArgumentMatchers.eq("refunds/1/notifications"),
ArgumentMatchers.anyString(),
ArgumentMatchers.eq(true)
- )).thenThrow(new BitPayException("500", "error message"));
+ )).thenThrow(new BitPayApiException("error message", "500"));
// when
testedClass.sendRefundNotification("1");
@@ -799,15 +739,15 @@ public void it_should_throws_refundCreationException_for_invalid_sendRefundNotif
);
Assertions.assertEquals(
- "Status: 500 -> Reason: BITPAY-REFUND-CREATE: Failed to create refund -> error message",
+ "error message",
exception.getMessage()
);
}
@Test
- public void it_should_throws_refundCreationException_for_api_issue_for_create_refund() {
- RefundCreationException exception = Assertions.assertThrows(
- RefundCreationException.class,
+ public void it_should_throws_bitpay_api_exception_for_api_issue_for_create_refund() {
+ BitPayApiException exception = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
// given
Client testedClass = this.getTestedClass();
@@ -815,7 +755,7 @@ public void it_should_throws_refundCreationException_for_api_issue_for_create_re
ArgumentMatchers.eq("refunds/"),
ArgumentMatchers.anyString(),
ArgumentMatchers.eq(true)
- )).thenThrow(new BitPayException("500", "error message"));
+ )).thenThrow(new BitPayApiException("error message", "500"));
// when
testedClass.createRefund("123", 2.20, true, true, true, "no");
@@ -823,15 +763,15 @@ public void it_should_throws_refundCreationException_for_api_issue_for_create_re
);
Assertions.assertEquals(
- "Status: 500 -> Reason: BITPAY-REFUND-CREATE: Failed to create refund -> error message",
+ "error message",
exception.getMessage()
);
}
@Test
- public void it_should_throws_refundQueryException_for_api_issue_for_get_refund() {
- RefundQueryException exception = Assertions.assertThrows(
- RefundQueryException.class,
+ public void it_should_throws_bitpay_api_exception_for_api_issue_for_get_refund() {
+ BitPayApiException exception = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
// given
Client testedClass = this.getTestedClass();
@@ -840,7 +780,7 @@ public void it_should_throws_refundQueryException_for_api_issue_for_get_refund()
ArgumentMatchers.eq("refunds/" + id),
ArgumentMatchers.any(),
ArgumentMatchers.eq(true)
- )).thenThrow(new BitPayException("500", "error message"));
+ )).thenThrow(new BitPayApiException("error message", "500"));
// when
testedClass.getRefund(id);
@@ -848,15 +788,15 @@ public void it_should_throws_refundQueryException_for_api_issue_for_get_refund()
);
Assertions.assertEquals(
- "Status: 500 -> Reason: BITPAY-REFUND-GET: Failed to retrieve refund -> error message",
+ "error message",
exception.getMessage()
);
}
@Test
- public void it_should_throws_refundQueryException_for_api_issue_for_get_refunds() {
- RefundQueryException exception = Assertions.assertThrows(
- RefundQueryException.class,
+ public void it_should_throws_bitpay_api_exception_for_api_issue_for_get_refunds() {
+ BitPayApiException exception = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
// given
Client testedClass = this.getTestedClass();
@@ -865,7 +805,7 @@ public void it_should_throws_refundQueryException_for_api_issue_for_get_refunds(
ArgumentMatchers.eq("refunds/"),
ArgumentMatchers.any(),
ArgumentMatchers.eq(true)
- )).thenThrow(new BitPayException("500", "error message"));
+ )).thenThrow(new BitPayApiException("error message", "500"));
// when
testedClass.getRefunds(id);
@@ -873,40 +813,15 @@ public void it_should_throws_refundQueryException_for_api_issue_for_get_refunds(
);
Assertions.assertEquals(
- "Status: 500 -> Reason: BITPAY-REFUND-GET: Failed to retrieve refund -> error message",
+ "error message",
exception.getMessage()
);
}
@Test
- public void it_should_throws_refundUpdateException_for_api_issue_for_get_refunds() {
- RefundQueryException exception = Assertions.assertThrows(
- RefundQueryException.class,
- () -> {
- // given
- Client testedClass = this.getTestedClass();
- String id = "12";
- Mockito.when(this.bitPayClient.get(
- ArgumentMatchers.eq("refunds/"),
- ArgumentMatchers.any(),
- ArgumentMatchers.eq(true)
- )).thenThrow(new BitPayException("500", "error message"));
-
- // when
- testedClass.getRefunds(id);
- }
- );
-
- Assertions.assertEquals(
- "Status: 500 -> Reason: BITPAY-REFUND-GET: Failed to retrieve refund -> error message",
- exception.getMessage()
- );
- }
-
- @Test
- public void it_should_throws_refundUpdateException_for_api_issue_for_update_refund() {
- RefundUpdateException exception = Assertions.assertThrows(
- RefundUpdateException.class,
+ public void it_should_throws_bitpay_api_exception_for_api_issue_for_update_refund() {
+ BitPayApiException exception = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
// given
Client testedClass = this.getTestedClass();
@@ -914,7 +829,7 @@ public void it_should_throws_refundUpdateException_for_api_issue_for_update_refu
Mockito.when(this.bitPayClient.update(
ArgumentMatchers.eq("refunds/12"),
ArgumentMatchers.eq("{\"token\":null,\"status\":\"complete\"}")
- )).thenThrow(new BitPayException("500", "error message"));
+ )).thenThrow(new BitPayApiException("error message", "500"));
// when
testedClass.updateRefund(id, "complete");
@@ -922,13 +837,13 @@ public void it_should_throws_refundUpdateException_for_api_issue_for_update_refu
);
Assertions.assertEquals(
- "Status: 500 -> Reason: BITPAY-REFUND-UPDATE: Failed to update refund -> error message",
+ "error message",
exception.getMessage()
);
}
@Test
- public void it_should_get_refund_by_id() throws BitPayException {
+ public void it_should_get_refund_by_id() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String refundId = "WoE46gSLkJQS48RJEiNw3L";
@@ -937,8 +852,6 @@ public void it_should_get_refund_by_id() throws BitPayException {
params.add(new BasicNameValuePair("token", "merchantToken"));
Mockito.when(this.bitPayClient.get("refunds/" + refundId, params, true))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getRefund.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
@@ -954,12 +867,11 @@ public void it_should_get_refund_by_id() throws BitPayException {
params,
true
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(refundId, result.getId());
}
@Test
- public void it_should_get_refund_by_guid() throws BitPayException {
+ public void it_should_get_refund_by_guid() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
@@ -967,8 +879,6 @@ public void it_should_get_refund_by_guid() throws BitPayException {
params.add(new BasicNameValuePair("token", "merchantToken"));
Mockito.when(this.bitPayClient.get("refunds/guid/" + EXAMPLE_UUID, params, true))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getRefund.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
@@ -984,12 +894,11 @@ public void it_should_get_refund_by_guid() throws BitPayException {
params,
true
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(EXAMPLE_UUID, result.getGuid());
}
@Test
- public void it_should_test_get_refunds() throws BitPayException {
+ public void it_should_test_get_refunds() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String invoiceId = "Hpqc63wvE1ZjzeeH4kEycF";
@@ -1000,8 +909,6 @@ public void it_should_test_get_refunds() throws BitPayException {
params.add(new BasicNameValuePair("invoiceId", invoiceId));
Mockito.when(this.bitPayClient.get("refunds/", params, true))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getRefundsJsonConvertedResponse);
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -1016,12 +923,11 @@ public void it_should_test_get_refunds() throws BitPayException {
params,
true
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(invoiceId, result.get(0).getInvoice());
}
@Test
- public void it_should_update_refund_by_id() throws BitPayException {
+ public void it_should_update_refund_by_id() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String status = "complete";
@@ -1036,9 +942,7 @@ public void it_should_update_refund_by_id() throws BitPayException {
Mockito.when(this.bitPayClient.update(
"refunds/" + refundId,
requestedJson
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getRefundsJsonConvertedResponse);
+ )).thenReturn(getRefundsJsonConvertedResponse);
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -1048,12 +952,11 @@ public void it_should_update_refund_by_id() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).update("refunds/" + refundId, requestedJson);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(refundId, result.getId());
}
@Test
- public void it_should_update_refund_by_guid() throws BitPayException {
+ public void it_should_update_refund_by_guid() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String status = "complete";
@@ -1068,9 +971,7 @@ public void it_should_update_refund_by_guid() throws BitPayException {
Mockito.when(this.bitPayClient.update(
"refunds/guid/" + guid,
requestedJson
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getRefundsJsonConvertedResponse);
+ )).thenReturn(getRefundsJsonConvertedResponse);
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -1080,12 +981,11 @@ public void it_should_update_refund_by_guid() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).update("refunds/guid/" + guid, requestedJson);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(guid, result.getGuid());
}
@Test
- public void it_should_test_sendRefundNotification() throws BitPayException {
+ public void it_should_test_sendRefundNotification() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String refundId = "WoE46gSLkJQS48RJEiNw3L";
@@ -1099,9 +999,7 @@ public void it_should_test_sendRefundNotification() throws BitPayException {
"refunds/" + refundId + "/notifications",
requestedJson,
true
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getRefundsJsonConvertedResponse);
+ )).thenReturn(getRefundsJsonConvertedResponse);
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -1115,12 +1013,11 @@ public void it_should_test_sendRefundNotification() throws BitPayException {
requestedJson,
true
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertTrue(result);
}
@Test
- public void it_should_cancel_refund_by_id() throws BitPayException {
+ public void it_should_cancel_refund_by_id() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String refundId = "WoE46gSLkJQS48RJEiNw3L";
@@ -1132,9 +1029,7 @@ public void it_should_cancel_refund_by_id() throws BitPayException {
Mockito.when(this.bitPayClient.delete(
"refunds/" + refundId,
params
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getRefundsJsonConvertedResponse);
+ )).thenReturn(getRefundsJsonConvertedResponse);
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -1145,12 +1040,11 @@ public void it_should_cancel_refund_by_id() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).delete("refunds/" + refundId, params);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(refundId, result.getId());
}
@Test
- public void it_should_cancel_refund_by_guid() throws BitPayException {
+ public void it_should_cancel_refund_by_guid() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "merchantToken";
final String guid = EXAMPLE_UUID;
@@ -1162,9 +1056,7 @@ public void it_should_cancel_refund_by_guid() throws BitPayException {
Mockito.when(this.bitPayClient.delete(
"refunds/guid/" + guid,
params
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getRefundsJsonConvertedResponse);
+ )).thenReturn(getRefundsJsonConvertedResponse);
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Client testedClass = this.getTestedClass();
@@ -1175,12 +1067,11 @@ public void it_should_cancel_refund_by_guid() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).delete("refunds/guid/" + guid, params);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(guid, result.getGuid());
}
@Test
- public void it_should_test_createBill_by_merchant_facade() throws BitPayException {
+ public void it_should_test_createBill_by_merchant_facade() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "AKnJyeLF1BjAfgfDbVUzHXk64N1WuDq3R9xtZouQFhSv";
final String createBillApiRequest = getPreparedJsonDataFromFile("createBillRequest.json");
@@ -1190,9 +1081,7 @@ public void it_should_test_createBill_by_merchant_facade() throws BitPayExceptio
"bills",
createBillApiRequest,
true
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getPreparedJsonDataFromFile("createBillResponse.json"));
+ )).thenReturn(getPreparedJsonDataFromFile("createBillResponse.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(merchantToken);
Mockito.when(this.accessTokens.tokenExists(Facade.MERCHANT)).thenReturn(true);
@@ -1204,12 +1093,11 @@ public void it_should_test_createBill_by_merchant_facade() throws BitPayExceptio
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).post("bills", createBillApiRequest, true);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(BILL_ID, result.getId());
}
@Test
- public void it_should_test_createBill_by_pos_facade() throws BitPayException {
+ public void it_should_test_createBill_by_pos_facade() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "AKnJyeLF1BjAfgfDbVUzHXk64N1WuDq3R9xtZouQFhSv";
final String createBillApiRequest = getPreparedJsonDataFromFile("createBillRequest.json");
@@ -1219,9 +1107,7 @@ public void it_should_test_createBill_by_pos_facade() throws BitPayException {
"bills",
createBillApiRequest,
false
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getPreparedJsonDataFromFile("createBillPosResponse.json"));
+ )).thenReturn(getPreparedJsonDataFromFile("createBillPosResponse.json"));
Mockito.when(this.accessTokens.tokenExists(Facade.MERCHANT)).thenReturn(false);
Mockito.when(this.accessTokens.getAccessToken(Facade.POS)).thenReturn(merchantToken);
@@ -1233,12 +1119,11 @@ public void it_should_test_createBill_by_pos_facade() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.POS);
Mockito.verify(this.bitPayClient, Mockito.times(1)).post("bills", createBillApiRequest, false);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(BILL_ID, result.getId());
}
@Test
- public void it_should_test_getBill_by_merchant_facade() throws BitPayException {
+ public void it_should_test_getBill_by_merchant_facade() throws BitPayApiException, BitPayGenericException {
// given
final String facadeToken = "AKnJyeLF1BjAfgfDbVUzHXk64N1WuDq3R9xtZouQFhSv";
@@ -1246,8 +1131,6 @@ public void it_should_test_getBill_by_merchant_facade() throws BitPayException {
params.add(new BasicNameValuePair("token", facadeToken));
Mockito.when(this.bitPayClient.get("bills/" + BILL_ID, params, true))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getBill.json"));
Mockito.when(this.accessTokens.tokenExists(Facade.MERCHANT)).thenReturn(true);
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(facadeToken);
@@ -1260,12 +1143,11 @@ public void it_should_test_getBill_by_merchant_facade() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).get("bills/" + BILL_ID, params, true);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(BILL_ID, result.getId());
}
@Test
- public void it_should_test_getBill_by_pos_facade() throws BitPayException {
+ public void it_should_test_getBill_by_pos_facade() throws BitPayApiException, BitPayGenericException {
// given
final String facadeToken = "AKnJyeLF1BjAfgfDbVUzHXk64N1WuDq3R9xtZouQFhSv";
@@ -1273,8 +1155,6 @@ public void it_should_test_getBill_by_pos_facade() throws BitPayException {
params.add(new BasicNameValuePair("token", facadeToken));
Mockito.when(this.bitPayClient.get("bills/" + BILL_ID, params, false))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getBill.json"));
Mockito.when(this.accessTokens.tokenExists(Facade.MERCHANT)).thenReturn(false);
Mockito.when(this.accessTokens.getAccessToken(Facade.POS)).thenReturn(facadeToken);
@@ -1289,12 +1169,11 @@ public void it_should_test_getBill_by_pos_facade() throws BitPayException {
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.POS);
Mockito.verify(this.bitPayClient, Mockito.times(1)).get("bills/" + BILL_ID, params, false);
Mockito.verify(this.bitPayClient, Mockito.times(0)).get("bills/" + BILL_ID, params, true);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(BILL_ID, result.getId());
}
@Test
- public void it_should_test_getBills() throws BitPayException {
+ public void it_should_test_getBills() throws BitPayApiException, BitPayGenericException {
// given
final List params = new ArrayList();
params.add(new BasicNameValuePair("token", MERCHANT_TOKEN));
@@ -1302,9 +1181,7 @@ public void it_should_test_getBills() throws BitPayException {
Mockito.when(this.bitPayClient.get(
"bills",
params
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getPreparedJsonDataFromFile("getBills.json"));
+ )).thenReturn(getPreparedJsonDataFromFile("getBills.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(MERCHANT_TOKEN);
Client testedClass = this.getTestedClass();
@@ -1315,13 +1192,12 @@ public void it_should_test_getBills() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).get("bills", params);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(BILL_ID, result.get(0).getId());
Assertions.assertEquals(2, result.size());
}
@Test
- public void it_should_test_getBills_by_status() throws BitPayException {
+ public void it_should_test_getBills_by_status() throws BitPayApiException, BitPayGenericException {
// given
final String status = "complete";
@@ -1332,9 +1208,7 @@ public void it_should_test_getBills_by_status() throws BitPayException {
Mockito.when(this.bitPayClient.get(
"bills",
params
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getPreparedJsonDataFromFile("getBills.json"));
+ )).thenReturn(getPreparedJsonDataFromFile("getBills.json"));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(MERCHANT_TOKEN);
Client testedClass = this.getTestedClass();
@@ -1345,13 +1219,12 @@ public void it_should_test_getBills_by_status() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).get("bills", params);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(BILL_ID, result.get(0).getId());
Assertions.assertEquals(2, result.size());
}
@Test
- public void it_should_test_updateBill() throws BitPayException {
+ public void it_should_test_updateBill() throws BitPayApiException, BitPayGenericException {
// given
final String merchantToken = "AKnJyeLF1BjAfgfDbVUzHXk64N1WuDq3R9xtZouQFhSv";
final Bill bill = this.getBillExample(merchantToken);
@@ -1363,9 +1236,7 @@ public void it_should_test_updateBill() throws BitPayException {
Mockito.when(this.bitPayClient.update(
"bills/" + BILL_ID,
updateBillApiRequest
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getPreparedJsonDataFromFile("getBill.json"));
+ )).thenReturn(getPreparedJsonDataFromFile("getBill.json"));
Client testedClass = this.getTestedClass();
@@ -1374,21 +1245,18 @@ public void it_should_test_updateBill() throws BitPayException {
// then
Mockito.verify(this.bitPayClient, Mockito.times(1)).update("bills/" + BILL_ID, updateBillApiRequest);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(BILL_ID, result.getId());
}
@Test
- public void it_should_test_deliverBill_by_merchant_facade() throws BitPayException {
+ public void it_should_test_deliverBill_by_merchant_facade() throws BitPayApiException, BitPayGenericException {
// given
final String billToken = "billToken";
Mockito.when(this.bitPayClient.post(
"bills/" + BILL_ID + "/deliveries",
"{\"token\":\"billToken\"}",
true
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn("Success");
+ )).thenReturn("Success");
Mockito.when(this.accessTokens.tokenExists(Facade.MERCHANT)).thenReturn(true);
Client testedClass = this.getTestedClass();
@@ -1402,21 +1270,18 @@ public void it_should_test_deliverBill_by_merchant_facade() throws BitPayExcepti
"{\"token\":\"billToken\"}",
true
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals("Success", result);
}
@Test
- public void it_should_test_deliverBill_by_pos_facade() throws BitPayException {
+ public void it_should_test_deliverBill_by_pos_facade() throws BitPayApiException, BitPayGenericException {
// given
final String billToken = "billToken";
Mockito.when(this.bitPayClient.post(
"bills/" + BILL_ID + "/deliveries",
"{\"token\":\"billToken\"}",
false
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn("Success");
+ )).thenReturn("Success");
Mockito.when(this.accessTokens.tokenExists(Facade.MERCHANT)).thenReturn(false);
Client testedClass = this.getTestedClass();
@@ -1430,15 +1295,13 @@ public void it_should_test_deliverBill_by_pos_facade() throws BitPayException {
"{\"token\":\"billToken\"}",
false
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals("Success", result);
}
@Test
- public void it_should_return_rate() throws BitPayException {
+ public void it_should_return_rate() throws BitPayApiException, BitPayGenericException {
// given
- Mockito.when(this.bitPayClient.get("rates/BCH/USD")).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
+ Mockito.when(this.bitPayClient.get("rates/BCH/USD"))
.thenReturn("{\"code\": \"USD\", \"name\": \"US Dollar\", \"rate\": 100.99}");
Client testedClass = this.getTestedClass();
@@ -1452,11 +1315,9 @@ public void it_should_return_rate() throws BitPayException {
}
@Test
- public void it_should_test_get_rates() throws BitPayException {
+ public void it_should_test_get_rates() throws BitPayApiException, BitPayGenericException {
// given
- Mockito.when(this.bitPayClient.get("rates")).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getPreparedJsonDataFromFile("getRates.json"));
+ Mockito.when(this.bitPayClient.get("rates")).thenReturn(getPreparedJsonDataFromFile("getRates.json"));
Client testedClass = this.getTestedClass();
@@ -1469,11 +1330,9 @@ public void it_should_test_get_rates() throws BitPayException {
}
@Test
- public void it_should_get_rates_by_base_currency() throws BitPayException {
+ public void it_should_get_rates_by_base_currency() throws BitPayApiException, BitPayGenericException {
// given
- Mockito.when(this.bitPayClient.get("rates/USD")).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getPreparedJsonDataFromFile("getRates.json"));
+ Mockito.when(this.bitPayClient.get("rates/USD")).thenReturn(getPreparedJsonDataFromFile("getRates.json"));
Client testedClass = this.getTestedClass();
@@ -1486,7 +1345,7 @@ public void it_should_get_rates_by_base_currency() throws BitPayException {
}
@Test
- public void it_should_get_ledger_entries() throws BitPayException {
+ public void it_should_get_ledger_entries() throws BitPayApiException, BitPayGenericException {
// given
final String currency = "USD";
final String dateStart = "2021-5-10";
@@ -1498,8 +1357,7 @@ public void it_should_get_ledger_entries() throws BitPayException {
params.add(new BasicNameValuePair("endDate", dateEnd));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(MERCHANT_TOKEN);
- Mockito.when(this.bitPayClient.get("ledgers/" + currency, params)).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
+ Mockito.when(this.bitPayClient.get("ledgers/" + currency, params))
.thenReturn(getPreparedJsonDataFromFile("getLedgers.json"));
Client testedClass = this.getTestedClass();
@@ -1510,20 +1368,18 @@ public void it_should_get_ledger_entries() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).get("ledgers/" + currency, params);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(3, result.size());
Assertions.assertEquals("20210510_fghij", result.get(0).getDescription());
}
@Test
- public void it_should_test_getLedgers() throws BitPayException {
+ public void it_should_test_getLedgers() throws BitPayApiException, BitPayGenericException {
// given
final List params = new ArrayList();
params.add(new BasicNameValuePair("token", MERCHANT_TOKEN));
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(MERCHANT_TOKEN);
- Mockito.when(this.bitPayClient.get("ledgers", params)).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
+ Mockito.when(this.bitPayClient.get("ledgers", params))
.thenReturn(getPreparedJsonDataFromFile("getLedgerBalances.json"));
Client testedClass = this.getTestedClass();
@@ -1534,13 +1390,12 @@ public void it_should_test_getLedgers() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).get("ledgers", params);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(3, result.size());
Assertions.assertEquals(2389.82, result.get(1).getBalance());
}
@Test
- public void it_should_test_submitPayoutRecipients() throws BitPayException {
+ public void it_should_test_submitPayoutRecipients() throws BitPayApiException, BitPayGenericException {
// given
PayoutRecipients recipients = getPayoutRecipientsExample();
Mockito.when(this.accessTokens.getAccessToken(Facade.PAYOUT)).thenReturn(PAYOUT_ACCESS_TOKEN);
@@ -1548,9 +1403,7 @@ public void it_should_test_submitPayoutRecipients() throws BitPayException {
"recipients",
getPreparedJsonDataFromFile("submitPayoutRecipientsRequest.json"),
true
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getPreparedJsonDataFromFile("submitPayoutRecipientsResponse.json"));
+ )).thenReturn(getPreparedJsonDataFromFile("submitPayoutRecipientsResponse.json"));
Client testedClass = this.getTestedClass();
@@ -1564,7 +1417,6 @@ public void it_should_test_submitPayoutRecipients() throws BitPayException {
getPreparedJsonDataFromFile("submitPayoutRecipientsRequest.json"),
true
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(2, result.size());
Assertions.assertEquals(
RECIPIENT_TOKEN,
@@ -1573,7 +1425,7 @@ public void it_should_test_submitPayoutRecipients() throws BitPayException {
}
@Test
- public void it_should_test_getPayoutRecipients() throws BitPayException {
+ public void it_should_test_getPayoutRecipients() throws BitPayApiException, BitPayGenericException {
// given
final String status = "invited";
final Integer limit = 1;
@@ -1587,8 +1439,7 @@ public void it_should_test_getPayoutRecipients() throws BitPayException {
params.add(new BasicNameValuePair("limit", limit.toString()));
params.add(new BasicNameValuePair("offset", offset.toString()));
- Mockito.when(this.bitPayClient.get("recipients", params, true)).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
+ Mockito.when(this.bitPayClient.get("recipients", params, true))
.thenReturn(getPreparedJsonDataFromFile("retrieveRecipientsResponse.json"));
Client testedClass = this.getTestedClass();
@@ -1599,7 +1450,6 @@ public void it_should_test_getPayoutRecipients() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.PAYOUT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).get("recipients", params, true);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(2, result.size());
Assertions.assertEquals(
RECIPIENT_TOKEN,
@@ -1608,14 +1458,13 @@ public void it_should_test_getPayoutRecipients() throws BitPayException {
}
@Test
- public void it_should_test_getPayoutRecipient() throws BitPayException {
+ public void it_should_test_getPayoutRecipient() throws BitPayApiException, BitPayGenericException {
// given
final List params = new ArrayList();
params.add(new BasicNameValuePair("token", PAYOUT_ACCESS_TOKEN));
Mockito.when(this.accessTokens.getAccessToken(Facade.PAYOUT)).thenReturn(PAYOUT_ACCESS_TOKEN);
- Mockito.when(this.bitPayClient.get("recipients/" + RECIPIENT_ID, params, true)).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
+ Mockito.when(this.bitPayClient.get("recipients/" + RECIPIENT_ID, params, true))
.thenReturn(getPreparedJsonDataFromFile("retrieveRecipientResponse.json"));
Client testedClass = this.getTestedClass();
@@ -1627,7 +1476,6 @@ public void it_should_test_getPayoutRecipient() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.PAYOUT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).get("recipients/" + RECIPIENT_ID, params, true);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(
RECIPIENT_TOKEN,
result.getToken()
@@ -1635,7 +1483,7 @@ public void it_should_test_getPayoutRecipient() throws BitPayException {
}
@Test
- public void it_should_test_updatePayoutRecipient() throws BitPayException {
+ public void it_should_test_updatePayoutRecipient() throws BitPayApiException, BitPayGenericException {
// given
final PayoutRecipient payoutRecipient = new PayoutRecipient();
final String label = "Bob123";
@@ -1647,9 +1495,7 @@ public void it_should_test_updatePayoutRecipient() throws BitPayException {
Mockito.when(this.bitPayClient.update(
"recipients/" + RECIPIENT_ID,
getPreparedJsonDataFromFile("updatePayoutRecipientRequest.json")
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getPreparedJsonDataFromFile("retrieveRecipientResponse.json"));
+ )).thenReturn(getPreparedJsonDataFromFile("retrieveRecipientResponse.json"));
Client testedClass = this.getTestedClass();
@@ -1663,20 +1509,18 @@ public void it_should_test_updatePayoutRecipient() throws BitPayException {
"recipients/" + RECIPIENT_ID,
getPreparedJsonDataFromFile("updatePayoutRecipientRequest.json")
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(RECIPIENT_TOKEN, result.getToken());
Assertions.assertEquals(label, result.getLabel());
}
@Test
- public void it_should_test_deletePayoutRecipient() throws BitPayException {
+ public void it_should_test_deletePayoutRecipient() throws BitPayApiException, BitPayGenericException {
// given
final List params = new ArrayList();
params.add(new BasicNameValuePair("token", PAYOUT_ACCESS_TOKEN));
Mockito.when(this.accessTokens.getAccessToken(Facade.PAYOUT)).thenReturn(PAYOUT_ACCESS_TOKEN);
- Mockito.when(this.bitPayClient.delete("recipients/" + RECIPIENT_ID, params)).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
+ Mockito.when(this.bitPayClient.delete("recipients/" + RECIPIENT_ID, params))
.thenReturn(getPreparedJsonDataFromFile("success.json"));
Client testedClass = this.getTestedClass();
@@ -1690,12 +1534,11 @@ public void it_should_test_deletePayoutRecipient() throws BitPayException {
"recipients/" + RECIPIENT_ID,
params
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertTrue(result);
}
@Test
- public void it_should_test_requestPayoutRecipientNotification() throws BitPayException {
+ public void it_should_test_requestPayoutRecipientNotification() throws BitPayApiException, BitPayGenericException {
// given
final String requestJson = "{\"token\":\"3LKKrrNB2BcVAu2Y24QQ78GrKUk2ANLK4eLo85Q1a2HU\"}";
@@ -1704,9 +1547,7 @@ public void it_should_test_requestPayoutRecipientNotification() throws BitPayExc
"recipients/" + RECIPIENT_ID + "/notifications",
requestJson,
true
- )).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
- .thenReturn(getPreparedJsonDataFromFile("success.json"));
+ )).thenReturn(getPreparedJsonDataFromFile("success.json"));
Client testedClass = this.getTestedClass();
@@ -1721,20 +1562,17 @@ public void it_should_test_requestPayoutRecipientNotification() throws BitPayExc
requestJson,
true
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertTrue(result);
}
@Test
- public void it_should_test_submitPayout() throws BitPayException {
+ public void it_should_test_submitPayout() throws BitPayApiException, BitPayGenericException {
// given
final String requestJson = getPreparedJsonDataFromFile("submitPayoutRequest.json");
Payout payout = getPayoutExample();
Mockito.when(this.accessTokens.getAccessToken(Facade.PAYOUT)).thenReturn(PAYOUT_ACCESS_TOKEN);
Mockito.when(this.bitPayClient.post("payouts", requestJson, true))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("submitPayoutResponse.json"));
Client testedClass = this.getTestedClass();
@@ -1746,7 +1584,6 @@ public void it_should_test_submitPayout() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.PAYOUT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).post("payouts", requestJson, true);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(
"6RZSTPtnzEaroAe2X4YijenRiqteRDNvzbT8NjtcHjUVd9FUFwa7dsX8RFgRDDC5SL",
result.getToken()
@@ -1754,15 +1591,13 @@ public void it_should_test_submitPayout() throws BitPayException {
}
@Test
- public void it_should_test_submitPayoutGroup() throws BitPayException, ParseException {
+ public void it_should_test_submitPayoutGroup() throws BitPayApiException, BitPayGenericException, ParseException {
// given
final String requestJson = getPreparedJsonDataFromFile("submitPayoutGroupRequest.json");
Collection payouts = Arrays.asList(getPayoutExample(), getPayoutExample());
Mockito.when(this.accessTokens.getAccessToken(Facade.PAYOUT)).thenReturn(PAYOUT_ACCESS_TOKEN);
Mockito.when(this.bitPayClient.post("payouts/group", requestJson, true))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("submitPayoutGroupResponse.json"));
Client testedClass = this.getTestedClass();
@@ -1774,7 +1609,6 @@ public void it_should_test_submitPayoutGroup() throws BitPayException, ParseExce
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.PAYOUT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).post("payouts/group", requestJson, true);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertFalse(result.getPayouts().isEmpty());
Payout firstPayout = result.getPayouts().get(0);
@@ -1814,15 +1648,13 @@ public void it_should_test_submitPayoutGroup() throws BitPayException, ParseExce
}
@Test
- public void it_should_test_getPayout() throws BitPayException {
+ public void it_should_test_getPayout() throws BitPayApiException, BitPayGenericException {
// given
final List params = new ArrayList();
params.add(new BasicNameValuePair("token", PAYOUT_ACCESS_TOKEN));
Mockito.when(this.accessTokens.getAccessToken(Facade.PAYOUT)).thenReturn(PAYOUT_ACCESS_TOKEN);
Mockito.when(this.bitPayClient.get("payouts/" + PAYOUT_ID, params, true))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("submitPayoutResponse.json"));
Client testedClass = this.getTestedClass();
@@ -1836,20 +1668,17 @@ public void it_should_test_getPayout() throws BitPayException {
Mockito.verify(this.bitPayClient, Mockito.times(1)).get(
"payouts/" + PAYOUT_ID, params, true
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(PAYOUT_ID, result.getId());
}
@Test
- public void it_should_test_cancelPayout() throws BitPayException {
+ public void it_should_test_cancelPayout() throws BitPayApiException, BitPayGenericException {
// given
final List params = new ArrayList();
params.add(new BasicNameValuePair("token", PAYOUT_ACCESS_TOKEN));
Mockito.when(this.accessTokens.getAccessToken(Facade.PAYOUT)).thenReturn(PAYOUT_ACCESS_TOKEN);
Mockito.when(this.bitPayClient.delete("payouts/" + PAYOUT_ID, params))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("success.json"));
Client testedClass = this.getTestedClass();
@@ -1861,22 +1690,18 @@ public void it_should_test_cancelPayout() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.PAYOUT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).delete("payouts/" + PAYOUT_ID, params);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertTrue(result);
}
@Test
- public void it_should_test_cancelPayoutGroup() throws BitPayException {
+ public void it_should_test_cancelPayoutGroup() throws BitPayApiException, BitPayGenericException {
// given
final List params = new ArrayList();
params.add(new BasicNameValuePair("token", PAYOUT_ACCESS_TOKEN));
Mockito.when(this.accessTokens.getAccessToken(Facade.PAYOUT)).thenReturn(PAYOUT_ACCESS_TOKEN);
Mockito.when(this.bitPayClient.delete("payouts/group/" + PAYOUT_ID, params))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("cancelPayoutGroupResponse.json"));
-
Client testedClass = this.getTestedClass();
// when
@@ -1886,7 +1711,6 @@ public void it_should_test_cancelPayoutGroup() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.PAYOUT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).delete("payouts/group/" + PAYOUT_ID, params);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertFalse(result.getPayouts().isEmpty());
Assertions.assertFalse(result.getFailed().isEmpty());
@@ -1897,7 +1721,7 @@ public void it_should_test_cancelPayoutGroup() throws BitPayException {
}
@Test
- public void it_should_test_getPayouts() throws BitPayException {
+ public void it_should_test_getPayouts() throws BitPayApiException, BitPayGenericException {
// given
final String startDate = "2021-05-27";
final String endDate = "2021-05-31";
@@ -1913,8 +1737,6 @@ public void it_should_test_getPayouts() throws BitPayException {
Mockito.when(this.accessTokens.getAccessToken(Facade.PAYOUT)).thenReturn(PAYOUT_ACCESS_TOKEN);
Mockito.when(this.bitPayClient.get("payouts", params, true))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getPayouts.json"));
Client testedClass = this.getTestedClass();
@@ -1933,12 +1755,11 @@ public void it_should_test_getPayouts() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.PAYOUT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).get("payouts", params, true);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(2, result.size());
}
@Test
- public void it_should_test_requestPayoutNotification() throws BitPayException {
+ public void it_should_test_requestPayoutNotification() throws BitPayApiException, BitPayGenericException {
// given
final String requestJson = "{\"token\":\"3LKKrrNB2BcVAu2Y24QQ78GrKUk2ANLK4eLo85Q1a2HU\"}";
@@ -1947,8 +1768,6 @@ public void it_should_test_requestPayoutNotification() throws BitPayException {
Mockito.when(this.accessTokens.getAccessToken(Facade.PAYOUT)).thenReturn(PAYOUT_ACCESS_TOKEN);
Mockito.when(this.bitPayClient.post("payouts/" + PAYOUT_ID + "/notifications", requestJson, true))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("success.json"));
Client testedClass = this.getTestedClass();
@@ -1963,12 +1782,11 @@ public void it_should_test_requestPayoutNotification() throws BitPayException {
requestJson,
true
);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertTrue(result);
}
@Test
- public void it_should_test_getSettlements() throws BitPayException {
+ public void it_should_test_getSettlements() throws BitPayApiException, BitPayGenericException {
// given
final String currency = "USD";
final String dateStart = "2021-5-10";
@@ -1988,8 +1806,6 @@ public void it_should_test_getSettlements() throws BitPayException {
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(MERCHANT_TOKEN);
Mockito.when(this.bitPayClient.get("settlements", params))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getSettlementsResponse.json"));
Client testedClass = this.getTestedClass();
@@ -2007,13 +1823,12 @@ public void it_should_test_getSettlements() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).get("settlements", params);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(2, result.size());
Assertions.assertEquals("KBkdURgmE3Lsy9VTnavZHX", result.get(0).getId());
}
@Test
- public void it_should_test_getSettlement() throws BitPayException {
+ public void it_should_test_getSettlement() throws BitPayApiException, BitPayGenericException {
// given
final String settlementId = "DNFnN3fFjjzLn6if5bdGJC";
@@ -2022,8 +1837,6 @@ public void it_should_test_getSettlement() throws BitPayException {
Mockito.when(this.accessTokens.getAccessToken(Facade.MERCHANT)).thenReturn(MERCHANT_TOKEN);
Mockito.when(this.bitPayClient.get("settlements/" + settlementId, params))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getSettlementResponse.json"));
Client testedClass = this.getTestedClass();
@@ -2034,12 +1847,11 @@ public void it_should_test_getSettlement() throws BitPayException {
// then
Mockito.verify(this.accessTokens, Mockito.times(1)).getAccessToken(Facade.MERCHANT);
Mockito.verify(this.bitPayClient, Mockito.times(1)).get("settlements/" + settlementId, params);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals("RPWTabW8urd3xWv2To989v", result.getId());
}
@Test
- public void it_should_test_getSettlementReconciliationReport() throws BitPayException {
+ public void it_should_test_getSettlementReconciliationReport() throws BitPayApiException, BitPayGenericException {
// given
final String settlementId = "DNFnN3fFjjzLn6if5bdGJC";
final String settlementToken = "5T1T5yGDEtFDYe8jEVBSYLHKewPYXZrDLvZxtXBzn69fBbZYitYQYH4BFYFvvaVU7D";
@@ -2048,8 +1860,6 @@ public void it_should_test_getSettlementReconciliationReport() throws BitPayExce
params.add(new BasicNameValuePair("token", settlementToken));
Mockito.when(this.bitPayClient.get("settlements/" + settlementId + "/reconciliationreport", params))
- .thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
.thenReturn(getPreparedJsonDataFromFile("getSettlementReconciliationReportResponse.json"));
Client testedClass = this.getTestedClass();
@@ -2060,16 +1870,14 @@ public void it_should_test_getSettlementReconciliationReport() throws BitPayExce
// then
Mockito.verify(this.bitPayClient, Mockito.times(1))
.get("settlements/" + settlementId + "/reconciliationreport", params);
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals("RvNuCTMAkURKimwgvSVEMP", result.getId());
Assertions.assertEquals(2389.82F, result.getTotalAmount());
}
@Test
- public void it_should_test_getSupportedWallets() throws BitPayException {
+ public void it_should_test_getSupportedWallets() throws BitPayApiException, BitPayGenericException {
// given
- Mockito.when(this.bitPayClient.get("supportedwallets")).thenReturn(this.httpResponse);
- Mockito.when(this.bitPayClient.responseToJsonString(this.httpResponse))
+ Mockito.when(this.bitPayClient.get("supportedwallets"))
.thenReturn(getPreparedJsonDataFromFile("getSupportedWalletsResponse.json"));
Client testedClass = this.getTestedClass();
@@ -2079,7 +1887,6 @@ public void it_should_test_getSupportedWallets() throws BitPayException {
// then
Mockito.verify(this.bitPayClient, Mockito.times(1)).get("supportedwallets");
- Mockito.verify(this.bitPayClient, Mockito.times(1)).responseToJsonString(this.httpResponse);
Assertions.assertEquals(7, result.size());
Assertions.assertEquals("bitpay-wallet.png", result.get(0).getAvatar());
Assertions.assertEquals("https://bitpay.com/img/wallet-logos/bitpay-wallet.png", result.get(0).getImage());
@@ -2099,18 +1906,6 @@ public void it_should_get_http_client() {
);
}
- @Test
- public void it_should_test_setLoggerLevel() {
- // given
- Client testedClass = this.getTestedClass();
-
- // when
- testedClass.setLoggerLevel(3);
-
- // then
- Mockito.verify(this.bitPayClient, Mockito.times(1)).setLoggerLevel(3);
- }
-
private Invoice getInvoiceExample() {
Invoice invoice = new Invoice(10.0, "USD");
invoice.setOrderId(EXAMPLE_UUID);
@@ -2137,7 +1932,7 @@ private Invoice getInvoiceExample() {
return invoice;
}
- private Bill getBillExample(String merchantToken) throws BitPayException {
+ private Bill getBillExample(String merchantToken) throws BitPayGenericException {
List cc = new ArrayList();
cc.add("jane@doe.com");
@@ -2189,7 +1984,7 @@ private PayoutRecipients getPayoutRecipientsExample() {
return new PayoutRecipients(recipients);
}
- private Payout getPayoutExample() throws BitPayException {
+ private Payout getPayoutExample() throws BitPayGenericException {
final Payout payout = new Payout();
payout.setAmount(10.00);
payout.setCurrency("USD");
@@ -2205,8 +2000,6 @@ private Payout getPayoutExample() throws BitPayException {
}
/**
- * Be aware. I removed "data" index from original request
- *
* @param fileName filename of json
* @return json response
*/
diff --git a/src/test/java/com/bitpay/sdk/ConfigTest.java b/src/test/java/com/bitpay/sdk/ConfigTest.java
index 5a2964df..48ba5d84 100644
--- a/src/test/java/com/bitpay/sdk/ConfigTest.java
+++ b/src/test/java/com/bitpay/sdk/ConfigTest.java
@@ -58,7 +58,7 @@ public void it_should_returns_bitpay_api_version() {
@Test
public void it_should_returns_bitpay_plugin_info() {
- Assertions.assertTrue(Config.BITPAY_PLUGIN_INFO.contains("BitPay_Java_Client_v9"));
+ Assertions.assertTrue(Config.BITPAY_PLUGIN_INFO.contains("BitPay_Java_Client_v10.0.0"));
}
@Test
diff --git a/src/test/java/com/bitpay/sdk/client/AuthorizationClientTest.java b/src/test/java/com/bitpay/sdk/client/AuthorizationClientTest.java
index af347ad0..b1a8447b 100644
--- a/src/test/java/com/bitpay/sdk/client/AuthorizationClientTest.java
+++ b/src/test/java/com/bitpay/sdk/client/AuthorizationClientTest.java
@@ -4,6 +4,8 @@
package com.bitpay.sdk.client;
+import com.bitpay.sdk.exceptions.BitPayApiException;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
import com.bitpay.sdk.model.Facade;
import com.bitpay.sdk.util.TokenContainer;
import java.io.IOException;
@@ -17,7 +19,7 @@ public AuthorizationClientTest() throws IOException {
}
@Test
- public void it_should_authorize_client_by_facade() throws IOException {
+ public void it_should_authorize_client_by_facade() throws BitPayGenericException, BitPayApiException {
// given
Mockito.when(this.uuidGenerator.execute()).thenReturn(AbstractClientTest.EXAMPLE_UUID);
this.addServerJsonResponse(
diff --git a/src/test/java/com/bitpay/sdk/client/BitPayClientTest.java b/src/test/java/com/bitpay/sdk/client/BitPayClientTest.java
index 3022dca7..1499ecd4 100644
--- a/src/test/java/com/bitpay/sdk/client/BitPayClientTest.java
+++ b/src/test/java/com/bitpay/sdk/client/BitPayClientTest.java
@@ -5,14 +5,13 @@
package com.bitpay.sdk.client;
import com.bitpay.sdk.Config;
-import com.bitpay.sdk.exceptions.BitPayException;
+import com.bitpay.sdk.exceptions.BitPayApiException;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpDelete;
@@ -20,7 +19,6 @@
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicNameValuePair;
import org.bitcoinj.core.ECKey;
import org.junit.jupiter.api.Assertions;
@@ -42,7 +40,8 @@ public class BitPayClientTest {
private HttpRequestFactory httpRequestFactory;
@Test
- public void it_should_test_get_request_without_parameters() throws IOException, URISyntaxException {
+ public void it_should_prepare_get_request_without_parameters()
+ throws IOException, URISyntaxException {
// given
final String testUrl = "/test";
final HttpGet httpGet = Mockito.mock(HttpGet.class);
@@ -54,7 +53,11 @@ public void it_should_test_get_request_without_parameters() throws IOException,
BitPayClient testedClass = this.getTestedClass();
// when
- testedClass.get(testUrl, parameters);
+ try {
+ testedClass.get(testUrl, parameters);
+ } catch (Exception e) {
+ // missing response
+ }
// then
Mockito.verify(httpClient, Mockito.times(1)).execute(httpGet);
@@ -71,7 +74,8 @@ public void it_should_test_get_request_without_parameters() throws IOException,
}
@Test
- public void it_should_test_get_request_with_parameters() throws IOException, URISyntaxException {
+ public void it_should_prepare_get_request_with_parameters()
+ throws IOException, URISyntaxException {
// given
final String testUrl = "/test";
final HttpGet httpGet = Mockito.mock(HttpGet.class);
@@ -83,7 +87,11 @@ public void it_should_test_get_request_with_parameters() throws IOException, URI
BitPayClient testedClass = this.getTestedClass();
// when
- testedClass.get(testUrl, parameters, true);
+ try {
+ testedClass.get(testUrl, parameters, true);
+ } catch (Exception e) {
+ // missing response
+ }
// then
Mockito.verify(httpClient, Mockito.times(1)).execute(httpGet);
@@ -100,10 +108,9 @@ public void it_should_test_get_request_with_parameters() throws IOException, URI
}
@Test
- public void it_should_throws_bitpayexception_when_something_is_wrong_for_get_requests()
- throws IOException, URISyntaxException {
- BitPayException exception1 = Assertions.assertThrows(
- BitPayException.class,
+ public void it_should_throws_bitpay_api_exception_when_something_is_wrong_for_get_requests() {
+ BitPayApiException exception1 = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
final HttpGet httpGet = Mockito.mock(HttpGet.class);
Mockito.when(this.httpRequestFactory.createHttpGet(ArgumentMatchers.anyString())).thenReturn(httpGet);
@@ -113,13 +120,12 @@ public void it_should_throws_bitpayexception_when_something_is_wrong_for_get_req
);
Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Error: GET failed\n" +
- "Illegal character in hostname at index 16: http://localhost[/]?",
+ "Illegal character in hostname at index 16: http://localhost[/]?",
exception1.getMessage()
);
- BitPayException exception2 = Assertions.assertThrows(
- BitPayException.class,
+ BitPayApiException exception2 = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
final HttpGet httpGet = Mockito.mock(HttpGet.class);
Mockito.when(this.httpRequestFactory.createHttpGet(ArgumentMatchers.anyString())).thenReturn(httpGet);
@@ -130,15 +136,11 @@ public void it_should_throws_bitpayexception_when_something_is_wrong_for_get_req
}
);
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Error: GET failed\n" +
- "Exception message",
- exception2.getMessage()
- );
+ Assertions.assertEquals("Exception message", exception2.getMessage());
- BitPayException exception3 = Assertions.assertThrows(
- BitPayException.class,
+ BitPayApiException exception3 = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
final HttpGet httpGet = Mockito.mock(HttpGet.class);
Mockito.when(this.httpRequestFactory.createHttpGet(ArgumentMatchers.anyString())).thenReturn(httpGet);
@@ -149,18 +151,14 @@ public void it_should_throws_bitpayexception_when_something_is_wrong_for_get_req
"Error: GET failed\n" + "Exception message"
);
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Error: GET failed\n" +
- "Exception message",
- exception3.getMessage()
- );
+ Assertions.assertEquals("Exception message", exception3.getMessage());
}
@Test
- public void it_should_throws_bitpayexception_when_something_is_wrong_for_delete_requests()
+ public void it_should_throws_bitpay_api_exception_when_something_is_wrong_for_delete_requests()
throws IOException, URISyntaxException {
- BitPayException exception1 = Assertions.assertThrows(
- BitPayException.class,
+ BitPayApiException exception1 = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
final HttpDelete httpDelete = Mockito.mock(HttpDelete.class);
Mockito.when(this.httpRequestFactory.createHttpDelete(ArgumentMatchers.anyString()))
@@ -171,13 +169,12 @@ public void it_should_throws_bitpayexception_when_something_is_wrong_for_delete_
);
Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Error: DELETE failed\n" +
"Illegal character in hostname at index 16: http://localhost[/]?",
exception1.getMessage()
);
- BitPayException exception2 = Assertions.assertThrows(
- BitPayException.class,
+ BitPayApiException exception2 = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
final HttpDelete httpDelete = Mockito.mock(HttpDelete.class);
Mockito.when(this.httpRequestFactory.createHttpDelete(ArgumentMatchers.anyString()))
@@ -190,13 +187,12 @@ public void it_should_throws_bitpayexception_when_something_is_wrong_for_delete_
);
Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Error: DELETE failed\n" +
- "Exception message",
+ "Exception message",
exception2.getMessage()
);
- BitPayException exception3 = Assertions.assertThrows(
- BitPayException.class,
+ BitPayApiException exception3 = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
final HttpDelete httpDelete = Mockito.mock(HttpDelete.class);
Mockito.when(this.httpRequestFactory.createHttpDelete(ArgumentMatchers.anyString()))
@@ -207,18 +203,14 @@ public void it_should_throws_bitpayexception_when_something_is_wrong_for_delete_
}
);
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Error: DELETE failed\n" +
- "Exception message",
- exception3.getMessage()
- );
+ Assertions.assertEquals("Exception message", exception3.getMessage());
}
@Test
- public void it_should_throws_bitpayexception_when_something_is_wrong_for_post_requests()
+ public void it_should_throws_bitpay_api_exception_when_something_is_wrong_for_post_requests()
throws IOException, URISyntaxException {
- BitPayException exception1 = Assertions.assertThrows(
- BitPayException.class,
+ BitPayApiException exception1 = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
final HttpPost httpPost = Mockito.mock(HttpPost.class);
Mockito.when(this.httpRequestFactory.createHttpPost(ArgumentMatchers.anyString()))
@@ -230,15 +222,11 @@ public void it_should_throws_bitpayexception_when_something_is_wrong_for_post_re
}
);
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Error: POST failed\n" +
- "Exception message",
- exception1.getMessage()
- );
+ Assertions.assertEquals("Exception message", exception1.getMessage());
- BitPayException exception2 = Assertions.assertThrows(
- BitPayException.class,
+ BitPayApiException exception2 = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
final HttpPost httpPost = Mockito.mock(HttpPost.class);
Mockito.when(this.httpRequestFactory.createHttpPost(ArgumentMatchers.anyString()))
@@ -249,18 +237,14 @@ public void it_should_throws_bitpayexception_when_something_is_wrong_for_post_re
}
);
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Error: POST failed\n" +
- "Exception message",
- exception2.getMessage()
- );
+ Assertions.assertEquals("Exception message", exception2.getMessage());
}
@Test
- public void it_should_throws_bitpayexception_when_something_is_wrong_for_put_requests()
+ public void it_should_throws_bitpay_api_exception_when_something_is_wrong_for_put_requests()
throws IOException, URISyntaxException {
- BitPayException exception1 = Assertions.assertThrows(
- BitPayException.class,
+ BitPayApiException exception1 = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
final HttpPut httpPut = Mockito.mock(HttpPut.class);
Mockito.when(this.httpRequestFactory.createHttpPut(ArgumentMatchers.anyString()))
@@ -272,14 +256,10 @@ public void it_should_throws_bitpayexception_when_something_is_wrong_for_put_req
}
);
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Error: PUT failed\n"
- + "Exception message",
- exception1.getMessage()
- );
+ Assertions.assertEquals("Exception message", exception1.getMessage());
- BitPayException exception2 = Assertions.assertThrows(
- BitPayException.class,
+ BitPayApiException exception2 = Assertions.assertThrows(
+ BitPayApiException.class,
() -> {
final HttpPut httpPut = Mockito.mock(HttpPut.class);
Mockito.when(this.httpRequestFactory.createHttpPut(ArgumentMatchers.anyString()))
@@ -290,15 +270,11 @@ public void it_should_throws_bitpayexception_when_something_is_wrong_for_put_req
}
);
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Error: PUT failed\n" +
- "Exception message",
- exception2.getMessage()
- );
+ Assertions.assertEquals("Exception message", exception2.getMessage());
}
@Test
- public void it_should_test_delete_request() throws IOException, URISyntaxException {
+ public void it_should_prepare_delete_request() throws IOException, URISyntaxException {
// given
final String testUrl = "/test";
final HttpDelete httpDelete = Mockito.mock(HttpDelete.class);
@@ -310,7 +286,11 @@ public void it_should_test_delete_request() throws IOException, URISyntaxExcepti
BitPayClient testedClass = this.getTestedClass();
// when
- testedClass.delete(testUrl, parameters);
+ try {
+ testedClass.delete(testUrl, parameters);
+ } catch (Exception e) {
+ // missing response
+ }
// then
Mockito.verify(httpClient, Mockito.times(1)).execute(httpDelete);
@@ -327,7 +307,7 @@ public void it_should_test_delete_request() throws IOException, URISyntaxExcepti
}
@Test
- public void it_should_test_post_request() throws IOException, URISyntaxException {
+ public void it_should_prepare_post_request() throws IOException {
// given
final String testUrl = "/test";
final String json = "{\"key\": \"value\"}";
@@ -338,7 +318,11 @@ public void it_should_test_post_request() throws IOException, URISyntaxException
BitPayClient testedClass = this.getTestedClass();
// when
- testedClass.post(testUrl, json, true);
+ try {
+ testedClass.post(testUrl, json, true);
+ } catch (Exception e) {
+ // missing response
+ }
// then
Mockito.verify(httpClient, Mockito.times(1)).execute(httpPost);
@@ -355,7 +339,7 @@ public void it_should_test_post_request() throws IOException, URISyntaxException
}
@Test
- public void it_should_test_put_request() throws IOException, URISyntaxException {
+ public void it_should_prepare_put_request() throws BitPayGenericException, BitPayApiException, IOException {
// given
final String testUrl = "/test";
final String json = "{\"key\": \"value\"}";
@@ -366,7 +350,11 @@ public void it_should_test_put_request() throws IOException, URISyntaxException
BitPayClient testedClass = this.getTestedClass();
// when
- testedClass.update(testUrl, json);
+ try {
+ testedClass.update(testUrl, json);
+ } catch (Exception e) {
+ // missing response
+ }
// then
Mockito.verify(httpClient, Mockito.times(1)).execute(httpPut);
@@ -382,107 +370,7 @@ public void it_should_test_put_request() throws IOException, URISyntaxException
.addHeader("x-bitpay-api-frame-version", Config.BITPAY_API_FRAME_VERSION);
}
- @Test
- public void it_should_test_convert_httpResponse_for_json() throws BitPayException {
- // given
- final String responseContent = "{\"status\":\"success\",\"data\":{},\"message\":null}";
- BitPayClient testedClass = this.getTestedClass();
- HttpResponse httpResponse = Mockito.mock(HttpResponse.class);
- HttpEntity httpEntity = new StringEntity(responseContent, "UTF-8");
- Mockito.when(httpResponse.getEntity()).thenReturn(httpEntity);
-
- // when
- String result = testedClass.responseToJsonString(httpResponse);
-
- // then
- Assertions.assertEquals(responseContent, result);
- }
-
- @Test
- public void it_should_return_data_value_from_httpResponse() throws BitPayException {
- // given
- final String responseContent = "{\"status\":\"success\",\"data\":{\"my\":\"data\"},\"message\":null}";
- BitPayClient testedClass = this.getTestedClass();
- HttpResponse httpResponse = Mockito.mock(HttpResponse.class);
- HttpEntity httpEntity = new StringEntity(responseContent, "UTF-8");
- Mockito.when(httpResponse.getEntity()).thenReturn(httpEntity);
-
- // when
- String result = testedClass.responseToJsonString(httpResponse);
-
- // then
- Assertions.assertEquals("{\"my\":\"data\"}", result);
- }
-
- @Test
- public void it_should_throws_bitpayexception_for_missing_response() {
- BitPayException exception = Assertions.assertThrows(
- BitPayException.class,
- () -> {
- // given
- BitPayClient testedClass = this.getTestedClass();
-
- // when
- testedClass.responseToJsonString(null);
- }
- );
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Error: HTTP response is null",
- exception.getMessage()
- );
- }
-
- @Test
- public void it_should_throws_bitpayexception_for_response_with_error() {
- BitPayException exception = Assertions.assertThrows(
- BitPayException.class,
- () -> {
- // given
- final String responseContent = "{\"code\":\"500\",\"status\":\"error\",\"data\":{},\"message\":\"Error message text\"}";
- BitPayClient testedClass = this.getTestedClass();
- HttpResponse httpResponse = Mockito.mock(HttpResponse.class);
- HttpEntity httpEntity = new StringEntity(responseContent, "UTF-8");
- Mockito.when(httpResponse.getEntity()).thenReturn(httpEntity);
- // when
- String result = testedClass.responseToJsonString(httpResponse);
-
- // then
- Assertions.assertEquals(responseContent, result);
- }
- );
- Assertions.assertEquals(
- "Status: 500 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Error message text",
- exception.getMessage()
- );
-
- }
-
- @Test
- public void it_should_throws_bitpayexception_for_response_with_errors() {
- BitPayException exception = Assertions.assertThrows(
- BitPayException.class,
- () -> {
- // given
- final String responseContent = "{\"code\":\"500\",\"status\":\"errors\",\"errors\":[\"Error1\", \"Error2\"],\"data\":{},\"message\":\"Error message text\"}";
- BitPayClient testedClass = this.getTestedClass();
- HttpResponse httpResponse = Mockito.mock(HttpResponse.class);
- HttpEntity httpEntity = new StringEntity(responseContent, "UTF-8");
- Mockito.when(httpResponse.getEntity()).thenReturn(httpEntity);
-
- // when
- String result = testedClass.responseToJsonString(httpResponse);
-
- // then
- Assertions.assertEquals(responseContent, result);
- }
- );
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> Multiple errors:\n" +
- "Error1\n" + "Error2",
- exception.getMessage()
- );
- }
private BitPayClient getTestedClass() {
return new BitPayClient(this.httpClient, this.httpRequestFactory, BASE_URL, new ECKey());
diff --git a/src/test/java/com/bitpay/sdk/client/RateClientTest.java b/src/test/java/com/bitpay/sdk/client/RateClientTest.java
index 0fbead0b..40bb137d 100644
--- a/src/test/java/com/bitpay/sdk/client/RateClientTest.java
+++ b/src/test/java/com/bitpay/sdk/client/RateClientTest.java
@@ -4,7 +4,8 @@
package com.bitpay.sdk.client;
-import com.bitpay.sdk.exceptions.RateQueryException;
+import com.bitpay.sdk.exceptions.BitPayApiException;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
import com.bitpay.sdk.model.rate.Rate;
import com.bitpay.sdk.model.rate.Rates;
import org.junit.jupiter.api.Assertions;
@@ -13,7 +14,7 @@
public class RateClientTest extends AbstractClientTest {
@Test
- public void it_should_get_rate() throws RateQueryException {
+ public void it_should_get_rate() throws BitPayGenericException, BitPayApiException {
// given
this.addServerJsonResponse(
"/rates/BCH/USD",
@@ -30,7 +31,7 @@ public void it_should_get_rate() throws RateQueryException {
}
@Test
- public void it_should_get_rates() throws RateQueryException {
+ public void it_should_get_rates() throws BitPayGenericException, BitPayApiException {
// given
this.addServerJsonResponse(
"/rates",
@@ -48,7 +49,7 @@ public void it_should_get_rates() throws RateQueryException {
}
@Test
- public void it_should_get_rates_by_base_currency() throws RateQueryException {
+ public void it_should_get_rates_by_base_currency() throws BitPayGenericException, BitPayApiException {
// given
this.addServerJsonResponse(
"/rates/BTC",
diff --git a/src/test/java/com/bitpay/sdk/client/ResponseParserTest.java b/src/test/java/com/bitpay/sdk/client/ResponseParserTest.java
new file mode 100644
index 00000000..7ae84028
--- /dev/null
+++ b/src/test/java/com/bitpay/sdk/client/ResponseParserTest.java
@@ -0,0 +1,86 @@
+package com.bitpay.sdk.client;
+
+import com.bitpay.sdk.exceptions.BitPayApiException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class ResponseParserTest {
+
+ @Test
+ public void it_should_test_convert_success_response() throws BitPayApiException {
+ // given
+ final String responseContent = "{\"status\":\"success\",\"data\":{},\"message\":null}";
+
+ // when
+ String result = ResponseParser.getJsonDataFromJsonResponse(responseContent);
+
+ // then
+ Assertions.assertEquals(responseContent, result);
+ }
+
+ @Test
+ public void it_should_return_data_value_from_json_response() throws BitPayApiException {
+ // given
+ final String responseContent = "{\"status\":\"success\",\"data\":{\"my\":\"data\"},\"message\":null}";
+
+ // when
+ String result = ResponseParser.getJsonDataFromJsonResponse(responseContent);
+
+ // then
+ Assertions.assertEquals("{\"my\":\"data\"}", result);
+ }
+
+ @Test
+ public void it_should_throws_bitpay_api_exception_for_missing_response() {
+ BitPayApiException exception = Assertions.assertThrows(
+ BitPayApiException.class,
+ () -> {
+ // given
+
+
+ // when
+ ResponseParser.getJsonDataFromJsonResponse(null);
+ }
+ );
+ Assertions.assertEquals(
+ "HTTP response is null",
+ exception.getMessage()
+ );
+ }
+
+ @Test
+ public void it_should_throws_bitpay_api_exception_for_response_with_error() {
+ BitPayApiException exception = Assertions.assertThrows(
+ BitPayApiException.class,
+ () -> {
+ // given
+ final String responseContent = "{\"code\":\"500\",\"status\":\"error\",\"data\":{},\"message\":\"Error message text\"}";
+
+ // when
+ String result = ResponseParser.getJsonDataFromJsonResponse(responseContent);
+
+ // then
+ Assertions.assertEquals(responseContent, result);
+ }
+ );
+ Assertions.assertEquals("Error message text", exception.getMessage());
+ }
+
+ @Test
+ public void it_should_throws_bitpay_api_exception_for_response_with_errors() {
+ BitPayApiException exception = Assertions.assertThrows(
+ BitPayApiException.class,
+ () -> {
+ // given
+ final String responseContent = "{\"code\":\"500\",\"status\":\"error\",\"data\":{},\"message\":\"Error message text\"}";
+
+ // when
+ String result = ResponseParser.getJsonDataFromJsonResponse(responseContent);
+
+ // then
+ Assertions.assertEquals(responseContent, result);
+ }
+ );
+ Assertions.assertEquals("Error message text", exception.getMessage());
+ }
+}
diff --git a/src/test/java/com/bitpay/sdk/client/SettlementClientTest.java b/src/test/java/com/bitpay/sdk/client/SettlementClientTest.java
index 78bc0811..30daf338 100644
--- a/src/test/java/com/bitpay/sdk/client/SettlementClientTest.java
+++ b/src/test/java/com/bitpay/sdk/client/SettlementClientTest.java
@@ -4,8 +4,9 @@
package com.bitpay.sdk.client;
+import com.bitpay.sdk.exceptions.BitPayApiException;
import com.bitpay.sdk.exceptions.BitPayException;
-import com.bitpay.sdk.exceptions.SettlementQueryException;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
import com.bitpay.sdk.model.settlement.Settlement;
import java.util.List;
import org.junit.jupiter.api.Assertions;
@@ -17,7 +18,7 @@ public class SettlementClientTest extends AbstractClientTest {
public void it_should_get_settlements() throws BitPayException {
// given
this.addServerJsonResponse(
- "/settlements?token=someMerchantToken&startDate=2021-5-10&endDate=2021-5-12&status=processing&limit=100&offset=0",
+ "/settlements?token=someMerchantToken&startDate=2021-5-10&endDate=2021-5-12&status=processing",
"GET",
null,
getPreparedJsonDataFromFile("getSettlementsResponse.json")
@@ -120,7 +121,7 @@ public void it_should_get_settlement() throws BitPayException {
}
@Test
- public void it_should_get_settlement_reconciliation_report() throws SettlementQueryException {
+ public void it_should_get_settlement_reconciliation_report() throws BitPayGenericException, BitPayApiException {
// given
this.addServerJsonResponse(
//
diff --git a/src/test/java/com/bitpay/sdk/exceptions/AbstractTestException.java b/src/test/java/com/bitpay/sdk/exceptions/AbstractTestException.java
deleted file mode 100644
index d3589584..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/AbstractTestException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2019 BitPay
- */
-
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-
-abstract class AbstractTestException {
-
- protected static final String REASON_MESSAGE = "reasonMsg";
- protected static final String STATUS_CODE = "123456";
-
- protected void testExceptionWithoutStatus(
- final BitPayException exception,
- final String message,
- final String code
- ) {
- Assertions.assertEquals(
- code + ": " + message + " -> " + REASON_MESSAGE,
- exception.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 000000 -> Reason: " + code + ": " + message + " -> " + REASON_MESSAGE,
- exception.getMessage());
- Assertions.assertNull(exception.getStatusCode());
- }
-
- protected void testExceptionWithStatus(
- final BitPayException exception,
- final String message,
- final String code
- ) {
- Assertions.assertEquals(
- code + ": " + message + " -> " + REASON_MESSAGE,
- exception.getReasonPhrase());
- Assertions.assertEquals(
- "Status: " + STATUS_CODE + " -> Reason: " + code + ": " + message + " -> " + REASON_MESSAGE,
- exception.getMessage());
- }
-}
diff --git a/src/test/java/com/bitpay/sdk/exceptions/BillCreationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/BillCreationExceptionTest.java
deleted file mode 100644
index d9b2d840..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/BillCreationExceptionTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class BillCreationExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- // given
- String message = "reasonMsg";
-
- // when
- BillCreationException testedClass = this.getTestedClass(null, message);
-
- // then
- Assertions
- .assertEquals("BITPAY-BILL-CREATE: Failed to create bill -> reasonMsg", testedClass.getReasonPhrase());
- Assertions.assertEquals("Status: 000000 -> Reason: BITPAY-BILL-CREATE: Failed to create bill -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertNull(testedClass.getStatusCode());
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- // given
- String message = "reasonMsg";
- String status = "123456";
-
- // when
- BillCreationException testedClass = this.getTestedClass(status, message);
-
- // then
- Assertions
- .assertEquals("BITPAY-BILL-CREATE: Failed to create bill -> reasonMsg", testedClass.getReasonPhrase());
- Assertions.assertEquals("Status: 123456 -> Reason: BITPAY-BILL-CREATE: Failed to create bill -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertSame("123456", testedClass.getStatusCode());
- }
-
- private BillCreationException getTestedClass(String status, String message) {
- return new BillCreationException(status, message);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/BillDeliveryExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/BillDeliveryExceptionTest.java
deleted file mode 100644
index 279c0457..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/BillDeliveryExceptionTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class BillDeliveryExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- // given
- String message = "reasonMsg";
-
- // when
- BillDeliveryException testedClass = this.getTestedClass(null, message);
-
- // then
- Assertions
- .assertEquals("BITPAY-BILL-DELIVERY: Failed to deliver bill -> reasonMsg", testedClass.getReasonPhrase());
- Assertions.assertEquals("Status: 000000 -> Reason: BITPAY-BILL-DELIVERY: Failed to deliver bill -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertNull(testedClass.getStatusCode());
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- // given
- String message = "reasonMsg";
- String status = "123456";
-
- // when
- BillDeliveryException testedClass = this.getTestedClass(status, message);
-
- // then
- Assertions
- .assertEquals("BITPAY-BILL-DELIVERY: Failed to deliver bill -> reasonMsg", testedClass.getReasonPhrase());
- Assertions.assertEquals("Status: 123456 -> Reason: BITPAY-BILL-DELIVERY: Failed to deliver bill -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertSame("123456", testedClass.getStatusCode());
- }
-
- private BillDeliveryException getTestedClass(String status, String message) {
- return new BillDeliveryException(status, message);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/BillExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/BillExceptionTest.java
deleted file mode 100644
index 87f40530..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/BillExceptionTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class BillExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- // given
- String message = "reasonMsg";
-
- // when
- BillException testedClass = this.getTestedClass(null, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-BILL-GENERIC: An unexpected error occurred while trying to manage the bill -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-BILL-GENERIC: An unexpected error occurred while trying to manage the bill -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertNull(testedClass.getStatusCode());
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- // given
- String message = "reasonMsg";
- String status = "123456";
-
- // when
- BillException testedClass = this.getTestedClass(status, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-BILL-GENERIC: An unexpected error occurred while trying to manage the bill -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 123456 -> Reason: BITPAY-BILL-GENERIC: An unexpected error occurred while trying to manage the bill -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertSame("123456", testedClass.getStatusCode());
- }
-
- private BillException getTestedClass(String status, String message) {
- return new BillException(status, message);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/BillQueryExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/BillQueryExceptionTest.java
deleted file mode 100644
index ce2a4780..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/BillQueryExceptionTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class BillQueryExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- // given
- String message = "reasonMsg";
-
- // when
- BillQueryException testedClass = this.getTestedClass(null, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-BILL-GET: Failed to retrieve bill -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-BILL-GET: Failed to retrieve bill -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertNull(testedClass.getStatusCode());
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- // given
- String message = "reasonMsg";
- String status = "123456";
-
- // when
- BillQueryException testedClass = this.getTestedClass(status, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-BILL-GET: Failed to retrieve bill -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 123456 -> Reason: BITPAY-BILL-GET: Failed to retrieve bill -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertSame("123456", testedClass.getStatusCode());
- }
-
- private BillQueryException getTestedClass(String status, String message) {
- return new BillQueryException(status, message);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/BillUpdateExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/BillUpdateExceptionTest.java
deleted file mode 100644
index 0c7f0268..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/BillUpdateExceptionTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class BillUpdateExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- // given
- String message = "reasonMsg";
-
- // when
- BillUpdateException testedClass = this.getTestedClass(null, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-BILL-UPDATE: Failed to update bill -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-BILL-UPDATE: Failed to update bill -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertNull(testedClass.getStatusCode());
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- // given
- String message = "reasonMsg";
- String status = "123456";
-
- // when
- BillUpdateException testedClass = this.getTestedClass(status, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-BILL-UPDATE: Failed to update bill -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 123456 -> Reason: BITPAY-BILL-UPDATE: Failed to update bill -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertSame("123456", testedClass.getStatusCode());
- }
-
- private BillUpdateException getTestedClass(String status, String message) {
- return new BillUpdateException(status, message);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/BitPayExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/BitPayExceptionTest.java
deleted file mode 100644
index 251fd402..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/BitPayExceptionTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class BitPayExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- // given
- String message = "reasonMsg";
-
- // when
- BitPayException testedClass = this.getTestedClass(null, message);
-
- // then
- Assertions.assertEquals("reasonMsg", testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertNull(testedClass.getStatusCode());
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- // given
- String message = "reasonMsg";
- String status = "123456";
-
- // when
- BitPayException testedClass = this.getTestedClass(status, message);
-
- // then
- Assertions.assertEquals(
- "reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 123456 -> Reason: BITPAY-GENERIC: Unexpected Bitpay exeption. -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertSame("123456", testedClass.getStatusCode());
- }
-
- private BitPayException getTestedClass(String status, String message) {
- return new BitPayException(status, message);
- }
-}
diff --git a/src/test/java/com/bitpay/sdk/exceptions/CurrencyExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/CurrencyExceptionTest.java
deleted file mode 100644
index 66f3138e..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/CurrencyExceptionTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class CurrencyExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- // given
- String message = "reasonMsg";
-
- // when
- CurrencyException testedClass = this.getTestedClass(null, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-CURRENCY-GENERIC: An unexpected error occurred while trying to manage the currencies -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-CURRENCY-GENERIC: An unexpected error occurred while trying to manage the currencies -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertNull(testedClass.getStatusCode());
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- // given
- String message = "reasonMsg";
- String status = "123456";
-
- // when
- CurrencyException testedClass = this.getTestedClass(status, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-CURRENCY-GENERIC: An unexpected error occurred while trying to manage the currencies -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 123456 -> Reason: BITPAY-CURRENCY-GENERIC: An unexpected error occurred while trying to manage the currencies -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertSame("123456", testedClass.getStatusCode());
- }
-
- private CurrencyException getTestedClass(String status, String message) {
- return new CurrencyException(status, message);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/CurrencyQueryExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/CurrencyQueryExceptionTest.java
deleted file mode 100644
index 331037db..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/CurrencyQueryExceptionTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class CurrencyQueryExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- // given
- String message = "reasonMsg";
-
- // when
- CurrencyQueryException testedClass = this.getTestedClass(null, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-CURRENCY-GET: Failed to retrieve currencies -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-CURRENCY-GET: Failed to retrieve currencies -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertNull(testedClass.getStatusCode());
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- // given
- String message = "reasonMsg";
- String status = "123456";
-
- // when
- CurrencyQueryException testedClass = this.getTestedClass(status, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-CURRENCY-GET: Failed to retrieve currencies -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 123456 -> Reason: BITPAY-CURRENCY-GET: Failed to retrieve currencies -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertSame("123456", testedClass.getStatusCode());
- }
-
- private CurrencyQueryException getTestedClass(String status, String message) {
- return new CurrencyQueryException(status, message);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/InvoiceCancellationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/InvoiceCancellationExceptionTest.java
deleted file mode 100644
index bd947ebd..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/InvoiceCancellationExceptionTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class InvoiceCancellationExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- // given
- String message = "reasonMsg";
-
- // when
- InvoiceCancellationException testedClass = this.getTestedClass(null, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-INVOICE-CANCEL: Failed to cancel invoice -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-INVOICE-CANCEL: Failed to cancel invoice -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertNull(testedClass.getStatusCode());
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- // given
- String message = "reasonMsg";
- String status = "123456";
-
- // when
- InvoiceCancellationException testedClass = this.getTestedClass(status, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-INVOICE-CANCEL: Failed to cancel invoice -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 123456 -> Reason: BITPAY-INVOICE-CANCEL: Failed to cancel invoice -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertSame("123456", testedClass.getStatusCode());
- }
-
- private InvoiceCancellationException getTestedClass(String status, String message) {
- return new InvoiceCancellationException(status, message);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/InvoiceCreationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/InvoiceCreationExceptionTest.java
deleted file mode 100644
index 1a9396b5..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/InvoiceCreationExceptionTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class InvoiceCreationExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- // given
- String message = "reasonMsg";
-
- // when
- InvoiceCreationException testedClass = this.getTestedClass(null, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-INVOICE-CREATE: Failed to create invoice -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-INVOICE-CREATE: Failed to create invoice -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertNull(testedClass.getStatusCode());
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- // given
- String message = "reasonMsg";
- String status = "123456";
-
- // when
- InvoiceCreationException testedClass = this.getTestedClass(status, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-INVOICE-CREATE: Failed to create invoice -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 123456 -> Reason: BITPAY-INVOICE-CREATE: Failed to create invoice -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertSame("123456", testedClass.getStatusCode());
- }
-
- private InvoiceCreationException getTestedClass(String status, String message) {
- return new InvoiceCreationException(status, message);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/InvoiceExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/InvoiceExceptionTest.java
deleted file mode 100644
index f7a0f278..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/InvoiceExceptionTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class InvoiceExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- // given
- String message = "reasonMsg";
-
- // when
- InvoiceException testedClass = this.getTestedClass(null, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-INVOICE-GENERIC: An unexpected error occurred while trying to manage the invoice -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-INVOICE-GENERIC: An unexpected error occurred while trying to manage the invoice -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertNull(testedClass.getStatusCode());
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- // given
- String message = "reasonMsg";
- String status = "123456";
-
- // when
- InvoiceException testedClass = this.getTestedClass(status, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-INVOICE-GENERIC: An unexpected error occurred while trying to manage the invoice -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 123456 -> Reason: BITPAY-INVOICE-GENERIC: An unexpected error occurred while trying to manage the invoice -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertSame("123456", testedClass.getStatusCode());
- }
-
- private InvoiceException getTestedClass(String status, String message) {
- return new InvoiceException(status, message);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/InvoiceQueryExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/InvoiceQueryExceptionTest.java
deleted file mode 100644
index 223d0075..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/InvoiceQueryExceptionTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class InvoiceQueryExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- // given
- String message = "reasonMsg";
-
- // when
- InvoiceQueryException testedClass = this.getTestedClass(null, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-INVOICE-GET: Failed to retrieve invoice -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 000000 -> Reason: BITPAY-INVOICE-GET: Failed to retrieve invoice -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertNull(testedClass.getStatusCode());
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- // given
- String message = "reasonMsg";
- String status = "123456";
-
- // when
- InvoiceQueryException testedClass = this.getTestedClass(status, message);
-
- // then
- Assertions.assertEquals(
- "BITPAY-INVOICE-GET: Failed to retrieve invoice -> reasonMsg",
- testedClass.getReasonPhrase());
- Assertions.assertEquals(
- "Status: 123456 -> Reason: BITPAY-INVOICE-GET: Failed to retrieve invoice -> reasonMsg",
- testedClass.getMessage());
- Assertions.assertSame("123456", testedClass.getStatusCode());
- }
-
- private InvoiceQueryException getTestedClass(String status, String message) {
- return new InvoiceQueryException(status, message);
- }
-
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/InvoiceUpdateExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/InvoiceUpdateExceptionTest.java
deleted file mode 100644
index db7cc89a..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/InvoiceUpdateExceptionTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class InvoiceUpdateExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(
- this.getTestedClass(null),
- "Failed to update invoice",
- "BITPAY-INVOICE-UPDATE"
- );
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(
- this.getTestedClass(AbstractTestException.STATUS_CODE),
- "Failed to update invoice",
- "BITPAY-INVOICE-UPDATE"
- );
- }
-
- private InvoiceUpdateException getTestedClass(String status) {
- return new InvoiceUpdateException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/LedgerExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/LedgerExceptionTest.java
deleted file mode 100644
index d7436805..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/LedgerExceptionTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class LedgerExceptionTest extends AbstractTestException {
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(
- this.getTestedClass(null),
- "An unexpected error occurred while trying to manage the ledger",
- "BITPAY-LEDGER-GENERIC"
- );
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(
- this.getTestedClass(AbstractTestException.STATUS_CODE),
- "An unexpected error occurred while trying to manage the ledger",
- "BITPAY-LEDGER-GENERIC"
- );
- }
-
- @Test
- public void it_should_build_exception_with_different_bitpay_message() {
- final String message = "BITPAY-CUSTOM";
- LedgerException exception = new LedgerException(null, message);
- Assertions.assertEquals(message, exception.getReasonPhrase());
- }
-
- private LedgerException getTestedClass(String status) {
- return new LedgerException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/LedgerQueryExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/LedgerQueryExceptionTest.java
deleted file mode 100644
index d48b4845..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/LedgerQueryExceptionTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class LedgerQueryExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to retrieve ledger";
- private static final String CODE = "BITPAY-LEDGER-GET";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(
- this.getTestedClass(null),
- MESSAGE,
- CODE
- );
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(
- this.getTestedClass(AbstractTestException.STATUS_CODE),
- MESSAGE,
- CODE
- );
- }
-
- private LedgerQueryException getTestedClass(String status) {
- return new LedgerQueryException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchCancellationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchCancellationExceptionTest.java
deleted file mode 100644
index d78899cd..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchCancellationExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class PayoutBatchCancellationExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to cancel payout batch.";
- private static final String CODE = "BITPAY-PAYOUT-BATCH-CANCELLATION";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private PayoutBatchCancellationException getTestedClass(String status) {
- return new PayoutBatchCancellationException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchCreationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchCreationExceptionTest.java
deleted file mode 100644
index f16e4698..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchCreationExceptionTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class PayoutBatchCreationExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to create payout batch.";
- private static final String CODE = "BITPAY-PAYOUT-BATCH-CREATE";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_build_exception_with_different_bitpay_message() {
- final String message = "BITPAY-CUSTOM";
- PayoutBatchCreationException exception = new PayoutBatchCreationException(null, message);
- Assertions.assertEquals(message, exception.getReasonPhrase());
- }
-
- private PayoutBatchCreationException getTestedClass(String status) {
- return new PayoutBatchCreationException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchExceptionTest.java
deleted file mode 100644
index 4f3029bc..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchExceptionTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class PayoutBatchExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "An unexpected error occured while trying to manage the payout batch.";
- private static final String CODE = "BITPAY-PAYOUT-BATCH-GENERIC";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_build_exception_with_different_bitpay_message() {
- final String message = "BITPAY-CUSTOM";
- PayoutBatchException exception = new PayoutBatchException(null, message);
- Assertions.assertEquals(message, exception.getReasonPhrase());
- }
-
- private PayoutBatchException getTestedClass(String status) {
- return new PayoutBatchException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchNotificationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchNotificationExceptionTest.java
deleted file mode 100644
index 4f1df87b..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchNotificationExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class PayoutBatchNotificationExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to send payout batch notification.";
- private static final String CODE = "BITPAY-PAYOUT-BATCH-NOTIFICATION";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private PayoutBatchNotificationException getTestedClass(String status) {
- return new PayoutBatchNotificationException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchQueryExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchQueryExceptionTest.java
deleted file mode 100644
index b894fff0..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutBatchQueryExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class PayoutBatchQueryExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to retrieve payout batch.";
- private static final String CODE = "BITPAY-PAYOUT-BATCH-GET";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private PayoutBatchQueryException getTestedClass(String status) {
- return new PayoutBatchQueryException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutCancellationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutCancellationExceptionTest.java
deleted file mode 100644
index f0bf5eca..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutCancellationExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class PayoutCancellationExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to cancel payout.";
- private static final String CODE = "BITPAY-PAYOUT-CANCEL";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private PayoutCancellationException getTestedClass(String status) {
- return new PayoutCancellationException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutCreationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutCreationExceptionTest.java
deleted file mode 100644
index b080323b..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutCreationExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class PayoutCreationExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to create payout.";
- private static final String CODE = "BITPAY-PAYOUT-SUBMIT";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private PayoutCreationException getTestedClass(String status) {
- return new PayoutCreationException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutExceptionTest.java
deleted file mode 100644
index 01d18dc5..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutExceptionTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class PayoutExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "An unexpected error occurred while trying to manage the payout.";
- private static final String CODE = "BITPAY-PAYOUT-GENERIC";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_build_exception_with_different_bitpay_message() {
- final String message = "BITPAY-CUSTOM";
- PayoutException exception = new PayoutException(null, message);
- Assertions.assertEquals(message, exception.getReasonPhrase());
- }
-
- private PayoutException getTestedClass(String status) {
- return new PayoutException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutNotificationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutNotificationExceptionTest.java
deleted file mode 100644
index 97029c95..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutNotificationExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class PayoutNotificationExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to send payout notification.";
- private static final String CODE = "BITPAY-PAYOUT-NOTIFICATION";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private PayoutNotificationException getTestedClass(String status) {
- return new PayoutNotificationException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutQueryExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutQueryExceptionTest.java
deleted file mode 100644
index 42b9371c..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutQueryExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class PayoutQueryExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to retrieve payout.";
- private static final String CODE = "BITPAY-PAYOUT-GET";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private PayoutQueryException getTestedClass(String status) {
- return new PayoutQueryException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientCancellationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientCancellationExceptionTest.java
deleted file mode 100644
index 2e88a564..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientCancellationExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class PayoutRecipientCancellationExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to cancel payout recipient";
- private static final String CODE = "BITPAY-PAYOUT-RECIPIENT-CANCELLATION";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private PayoutRecipientCancellationException getTestedClass(String status) {
- return new PayoutRecipientCancellationException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientCreationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientCreationExceptionTest.java
deleted file mode 100644
index d8786a7f..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientCreationExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class PayoutRecipientCreationExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to submit payout recipient.";
- private static final String CODE = "BITPAY-PAYOUT-RECIPIENT-CREATE";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private PayoutRecipientCreationException getTestedClass(String status) {
- return new PayoutRecipientCreationException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientExceptionTest.java
deleted file mode 100644
index 4865fe67..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientExceptionTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class PayoutRecipientExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "An unexpected error occurred while trying to manage the payout recipient";
- private static final String CODE = "BITPAY-PAYOUT-RECIPIENT-GENERIC";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_build_exception_with_different_bitpay_message() {
- final String message = "BITPAY-CUSTOM";
- PayoutRecipientException exception = new PayoutRecipientException(null, message);
- Assertions.assertEquals(message, exception.getReasonPhrase());
- }
-
- private PayoutRecipientException getTestedClass(String status) {
- return new PayoutRecipientException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientNotificationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientNotificationExceptionTest.java
deleted file mode 100644
index 040177e9..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientNotificationExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class PayoutRecipientNotificationExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to send payout recipient notification.";
- private static final String CODE = "BITPAY-PAYOUT-RECIPIENT-NOTIFICATION";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private PayoutRecipientNotificationException getTestedClass(String status) {
- return new PayoutRecipientNotificationException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientQueryExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientQueryExceptionTest.java
deleted file mode 100644
index 1e6f6c97..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientQueryExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class PayoutRecipientQueryExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to retrieve payout recipient.";
- private static final String CODE = "BITPAY-PAYOUT-RECIPIENT-GET";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private PayoutRecipientQueryException getTestedClass(String status) {
- return new PayoutRecipientQueryException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
diff --git a/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientUpdateExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientUpdateExceptionTest.java
deleted file mode 100644
index 7fdf6226..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/PayoutRecipientUpdateExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class PayoutRecipientUpdateExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to update payout recipient.";
- private static final String CODE = "BITPAY-PAYOUT-RECIPIENT-UPDATE";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private PayoutRecipientUpdateException getTestedClass(String status) {
- return new PayoutRecipientUpdateException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
diff --git a/src/test/java/com/bitpay/sdk/exceptions/RateExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/RateExceptionTest.java
deleted file mode 100644
index c55b7120..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/RateExceptionTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class RateExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "An unexpected error occurred while trying to manage the rates";
- private static final String CODE = "BITPAY-RATES-GENERIC";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_build_exception_with_different_bitpay_message() {
- final String message = "BITPAY-CUSTOM";
- RateException exception = new RateException(null, message);
- Assertions.assertEquals(message, exception.getReasonPhrase());
- }
-
- private RateException getTestedClass(String status) {
- return new RateException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/RateQueryExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/RateQueryExceptionTest.java
deleted file mode 100644
index fab7e7a6..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/RateQueryExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class RateQueryExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to retrieve rates";
- private static final String CODE = "BITPAY-RATES-GET";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private RateQueryException getTestedClass(String status) {
- return new RateQueryException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/RefundCancellationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/RefundCancellationExceptionTest.java
deleted file mode 100644
index b439028d..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/RefundCancellationExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class RefundCancellationExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to cancel refund";
- private static final String CODE = "BITPAY-REFUND-CANCEL";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private RefundCancellationException getTestedClass(String status) {
- return new RefundCancellationException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/RefundCreationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/RefundCreationExceptionTest.java
deleted file mode 100644
index 46474b75..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/RefundCreationExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class RefundCreationExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to create refund";
- private static final String CODE = "BITPAY-REFUND-CREATE";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private RefundCreationException getTestedClass(String status) {
- return new RefundCreationException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/RefundExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/RefundExceptionTest.java
deleted file mode 100644
index 33173a82..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/RefundExceptionTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class RefundExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "An unexpected error occurred while trying to manage the refund";
- private static final String CODE = "BITPAY-REFUND-GENERIC";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_build_exception_with_different_bitpay_message() {
- final String message = "BITPAY-CUSTOM";
- RefundException exception = new RefundException(null, message);
- Assertions.assertEquals(message, exception.getReasonPhrase());
- }
-
- private RefundException getTestedClass(String status) {
- return new RefundException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/RefundQueryExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/RefundQueryExceptionTest.java
deleted file mode 100644
index f75ebe00..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/RefundQueryExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class RefundQueryExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to retrieve refund";
- private static final String CODE = "BITPAY-REFUND-GET";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private RefundQueryException getTestedClass(String status) {
- return new RefundQueryException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/RefundUpdateExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/RefundUpdateExceptionTest.java
deleted file mode 100644
index 7462d037..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/RefundUpdateExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class RefundUpdateExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to update refund";
- private static final String CODE = "BITPAY-REFUND-UPDATE";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private RefundUpdateException getTestedClass(String status) {
- return new RefundUpdateException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/SettlementExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/SettlementExceptionTest.java
deleted file mode 100644
index 8571cd3b..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/SettlementExceptionTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class SettlementExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "An unexpected error occurred while trying to manage the settlements";
- private static final String CODE = "BITPAY-SETTLEMENTS-GENERIC";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_build_exception_with_different_bitpay_message() {
- final String message = "BITPAY-CUSTOM";
- SettlementException exception = new SettlementException(null, message);
- Assertions.assertEquals(message, exception.getReasonPhrase());
- }
-
- private SettlementException getTestedClass(String status) {
- return new SettlementException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/SettlementQueryExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/SettlementQueryExceptionTest.java
deleted file mode 100644
index d75fd48e..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/SettlementQueryExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class SettlementQueryExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to retrieve settlements";
- private static final String CODE = "BITPAY-SETTLEMENTS-GET";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private SettlementQueryException getTestedClass(String status) {
- return new SettlementQueryException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/SubscriptionCreationExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/SubscriptionCreationExceptionTest.java
deleted file mode 100644
index a9df6890..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/SubscriptionCreationExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class SubscriptionCreationExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to create subscription";
- private static final String CODE = "BITPAY-SUBSCRIPTION-CREATE";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private SubscriptionCreationException getTestedClass(String status) {
- return new SubscriptionCreationException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/SubscriptionExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/SubscriptionExceptionTest.java
deleted file mode 100644
index b2f2b950..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/SubscriptionExceptionTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class SubscriptionExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "An unexpected error occurred while trying to manage the subscription";
- private static final String CODE = "BITPAY-SUBSCRIPTION-GENERIC";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_build_exception_with_different_bitpay_message() {
- final String message = "BITPAY-CUSTOM";
- SubscriptionException exception = new SubscriptionException(null, message);
- Assertions.assertEquals(message, exception.getReasonPhrase());
- }
-
- private SubscriptionException getTestedClass(String status) {
- return new SubscriptionException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/SubscriptionQueryExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/SubscriptionQueryExceptionTest.java
deleted file mode 100644
index c368e6ae..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/SubscriptionQueryExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class SubscriptionQueryExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to retrieve subscription";
- private static final String CODE = "BITPAY-SUBSCRIPTION-GET";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private SubscriptionQueryException getTestedClass(String status) {
- return new SubscriptionQueryException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/SubscriptionUpdateExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/SubscriptionUpdateExceptionTest.java
deleted file mode 100644
index 6665ff89..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/SubscriptionUpdateExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class SubscriptionUpdateExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to update subscription";
- private static final String CODE = "BITPAY-SUBSCRIPTION-UPDATE";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private SubscriptionUpdateException getTestedClass(String status) {
- return new SubscriptionUpdateException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/WalletExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/WalletExceptionTest.java
deleted file mode 100644
index 552484c4..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/WalletExceptionTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-public class WalletExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "An unexpected error occurred while trying to manage wallets";
- private static final String CODE = "BITPAY-WALLET-GENERIC";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_build_exception_with_different_bitpay_message() {
- final String message = "BITPAY-CUSTOM";
- WalletException exception = new WalletException(null, message);
- Assertions.assertEquals(message, exception.getReasonPhrase());
- }
-
- private WalletException getTestedClass(String status) {
- return new WalletException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/exceptions/WalletQueryExceptionTest.java b/src/test/java/com/bitpay/sdk/exceptions/WalletQueryExceptionTest.java
deleted file mode 100644
index e3b9af4d..00000000
--- a/src/test/java/com/bitpay/sdk/exceptions/WalletQueryExceptionTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.bitpay.sdk.exceptions;
-
-import org.junit.jupiter.api.Test;
-
-public class WalletQueryExceptionTest extends AbstractTestException {
-
- private static final String MESSAGE = "Failed to retrieve supported wallets";
- private static final String CODE = "BITPAY-WALLET-GET";
-
- @Test
- public void it_should_create_exception_without_status() {
- this.testExceptionWithoutStatus(this.getTestedClass(null), MESSAGE, CODE);
- }
-
- @Test
- public void it_should_create_exception_with_status() {
- this.testExceptionWithStatus(this.getTestedClass(AbstractTestException.STATUS_CODE), MESSAGE, CODE);
- }
-
- private WalletQueryException getTestedClass(String status) {
- return new WalletQueryException(status, AbstractTestException.REASON_MESSAGE);
- }
-}
\ No newline at end of file
diff --git a/src/test/java/com/bitpay/sdk/functional/ClientFunctionalTest.java b/src/test/java/com/bitpay/sdk/functional/ClientFunctionalTest.java
index a1807fd8..6f63cd82 100644
--- a/src/test/java/com/bitpay/sdk/functional/ClientFunctionalTest.java
+++ b/src/test/java/com/bitpay/sdk/functional/ClientFunctionalTest.java
@@ -6,8 +6,9 @@
import com.bitpay.sdk.Client;
import com.bitpay.sdk.ConfigFilePath;
+import com.bitpay.sdk.exceptions.BitPayApiException;
import com.bitpay.sdk.exceptions.BitPayException;
-import com.bitpay.sdk.exceptions.RateQueryException;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
import com.bitpay.sdk.model.bill.Bill;
import com.bitpay.sdk.model.bill.Item;
import com.bitpay.sdk.model.Currency;
@@ -68,7 +69,7 @@ public ClientFunctionalTest() throws BitPayException {
* - GetRates(string currency)
*/
@Test
- public void it_should_test_rate_requests() throws RateQueryException {
+ public void it_should_test_rate_requests() throws BitPayGenericException, BitPayApiException {
Rate rate = this.client.getRate(Currency.BCH, Currency.USD);
Assertions.assertTrue(rate.getValue() != 0);
diff --git a/src/test/java/com/bitpay/sdk/model/rate/RatesTest.java b/src/test/java/com/bitpay/sdk/model/rate/RatesTest.java
index e451f66a..b1730d99 100644
--- a/src/test/java/com/bitpay/sdk/model/rate/RatesTest.java
+++ b/src/test/java/com/bitpay/sdk/model/rate/RatesTest.java
@@ -4,7 +4,8 @@
package com.bitpay.sdk.model.rate;
import com.bitpay.sdk.client.RateClient;
-import com.bitpay.sdk.exceptions.RateQueryException;
+import com.bitpay.sdk.exceptions.BitPayApiException;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -61,7 +62,7 @@ public void it_should_get_specific_rate() {
}
@Test
- public void it_should_update_rates() throws RateQueryException {
+ public void it_should_update_rates() throws BitPayGenericException, BitPayApiException {
// given
List rates = Arrays.asList(rate1, rate2);
List expectedRates = Collections.singletonList(rate1);
@@ -77,10 +78,10 @@ public void it_should_update_rates() throws RateQueryException {
}
@Test
- public void it_should_throws_rateQueryException() throws RateQueryException {
- Mockito.when(this.client.getRates()).thenThrow(RateQueryException.class);
+ public void it_should_throws_rateQueryException() throws BitPayGenericException, BitPayApiException {
+ Mockito.when(this.client.getRates()).thenThrow(BitPayApiException.class);
- Assertions.assertThrows(RateQueryException.class, () -> {
+ Assertions.assertThrows(BitPayApiException.class, () -> {
// given
List rates = Arrays.asList(rate1, rate2);
Rates testedClass = this.getTestedClass(rates);
diff --git a/src/test/java/com/bitpay/sdk/util/KeyUtilsTest.java b/src/test/java/com/bitpay/sdk/util/KeyUtilsTest.java
index d2ee6223..ce370f1b 100644
--- a/src/test/java/com/bitpay/sdk/util/KeyUtilsTest.java
+++ b/src/test/java/com/bitpay/sdk/util/KeyUtilsTest.java
@@ -7,10 +7,9 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.bitcoinj.core.ECKey;
-
-import com.bitpay.sdk.util.KeyUtils;
+import com.bitpay.sdk.exceptions.BitPayGenericException;
+import org.bitcoinj.core.ECKey;
import org.junit.jupiter.api.Test;
public class KeyUtilsTest {
@@ -38,7 +37,7 @@ public void it_should_be_not_null() {
}
@Test
- public void it_should_convert_hex_to_bytes() {
+ public void it_should_convert_hex_to_bytes() throws BitPayGenericException {
String hex = "0123456789abcdef";
byte[] expectedBytes = { 1, 35, 69, 103, -119, -85, -51, -17 };