From 7c65590096ea9393ebbfa194b7d2ac91df5d8975 Mon Sep 17 00:00:00 2001 From: shalin-shaji Date: Mon, 23 Sep 2024 10:21:40 +0530 Subject: [PATCH] sdk-java issue : "Environment not set. Set environment using setter or use overloaded method to pass appropriate environment #163" Changed 'nullEnvironmentErrorMessage' as a constant to avoid confusion. --- .../net/authorize/api/controller/base/ApiOperationBase.java | 5 ++--- src/main/java/net/authorize/util/Constants.java | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/authorize/api/controller/base/ApiOperationBase.java b/src/main/java/net/authorize/api/controller/base/ApiOperationBase.java index 52e3d7cc..c59b2c55 100644 --- a/src/main/java/net/authorize/api/controller/base/ApiOperationBase.java +++ b/src/main/java/net/authorize/api/controller/base/ApiOperationBase.java @@ -121,12 +121,11 @@ public S executeWithApiResponse(Environment environment) { return this.getApiResponse(); } - final String nullEnvironmentErrorMessage = "Environment not set. Set environment using setter or use overloaded method to pass appropriate environment"; public void execute() { if ( null == ApiOperationBase.getEnvironment()) { - throw new InvalidParameterException(nullEnvironmentErrorMessage); + throw new InvalidParameterException(Constants.NULL_ENVIRONMENT_ERROR_MESSAGE); } else { @@ -139,7 +138,7 @@ public void execute(Environment environment) { logger.debug(String.format("Executing Request:'%s'", this.getApiRequest())); - if ( null == environment) throw new InvalidParameterException(nullEnvironmentErrorMessage); + if ( null == environment) throw new InvalidParameterException(Constants.NULL_ENVIRONMENT_ERROR_MESSAGE); ANetApiResponse httpApiResponse = HttpUtility.postData(environment, this.getApiRequest(), this.responseClass); if ( null != httpApiResponse) diff --git a/src/main/java/net/authorize/util/Constants.java b/src/main/java/net/authorize/util/Constants.java index 2a2b42c5..af19aa91 100644 --- a/src/main/java/net/authorize/util/Constants.java +++ b/src/main/java/net/authorize/util/Constants.java @@ -36,4 +36,6 @@ public final class Constants { public static final int HTTP_READ_TIME_OUT_DEFAULT_VALUE = 30000; public static final String CLIENT_ID = "sdk-java-2.0.3"; + public static final String NULL_ENVIRONMENT_ERROR_MESSAGE = "Environment not set. Set environment using setter or use overloaded method to pass appropriate environment"; + }