From 8c763da7a760ec01f6b2e0244d85843416bda069 Mon Sep 17 00:00:00 2001 From: sagaofsilence Date: Thu, 28 Mar 2024 19:28:23 +0530 Subject: [PATCH] Refactored code. Added package for config. --- .../classic/helper/UserSimpleHttpRequestHelper.java | 5 ++++- .../classic/helper/UserTypeHttpRequestHelper.java | 9 ++++----- .../example/classic/util/RequestProcessingUtils.java | 5 +++-- .../example/{util => config}/ConfigurationUtils.java | 2 +- .../helper/HttpConfigurationHelper.java | 9 +++++---- .../interceptor/CustomHttpExecutionInterceptor.java | 2 +- .../interceptor/CustomHttpRequestInterceptor.java | 2 +- .../interceptor/CustomHttpResponseInterceptor.java | 2 +- .../{classic => }/helper/BaseHttpRequestHelper.java | 4 ++-- .../client/example/classic/BaseClassicExampleTests.java | 2 +- 10 files changed, 23 insertions(+), 19 deletions(-) rename apache-http-client/src/main/java/io/refactoring/http5/client/example/{util => config}/ConfigurationUtils.java (97%) rename apache-http-client/src/main/java/io/refactoring/http5/client/example/{classic => config}/helper/HttpConfigurationHelper.java (93%) rename apache-http-client/src/main/java/io/refactoring/http5/client/example/{classic => config}/interceptor/CustomHttpExecutionInterceptor.java (94%) rename apache-http-client/src/main/java/io/refactoring/http5/client/example/{classic => config}/interceptor/CustomHttpRequestInterceptor.java (91%) rename apache-http-client/src/main/java/io/refactoring/http5/client/example/{classic => config}/interceptor/CustomHttpResponseInterceptor.java (88%) rename apache-http-client/src/main/java/io/refactoring/http5/client/example/{classic => }/helper/BaseHttpRequestHelper.java (59%) diff --git a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/UserSimpleHttpRequestHelper.java b/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/UserSimpleHttpRequestHelper.java index b9525d1ef..433e33965 100644 --- a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/UserSimpleHttpRequestHelper.java +++ b/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/UserSimpleHttpRequestHelper.java @@ -1,6 +1,7 @@ package io.refactoring.http5.client.example.classic.helper; import io.refactoring.http5.client.example.RequestProcessingException; +import io.refactoring.http5.client.example.helper.BaseHttpRequestHelper; import java.net.URI; import java.nio.charset.StandardCharsets; import java.text.MessageFormat; @@ -19,7 +20,9 @@ import org.apache.hc.core5.http.message.BasicNameValuePair; import org.apache.hc.core5.net.URIBuilder; -/** Utility to handle HTTP requests for user entities.It uses built in types for HTTP processing */ +/** + * Utility to handle HTTP requests for user entities. It uses built in types for HTTP processing. + */ @Slf4j public class UserSimpleHttpRequestHelper extends BaseHttpRequestHelper { diff --git a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/UserTypeHttpRequestHelper.java b/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/UserTypeHttpRequestHelper.java index 77fe76afc..c117f9aa1 100644 --- a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/UserTypeHttpRequestHelper.java +++ b/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/UserTypeHttpRequestHelper.java @@ -1,15 +1,14 @@ package io.refactoring.http5.client.example.classic.helper; import io.refactoring.http5.client.example.RequestProcessingException; +import io.refactoring.http5.client.example.classic.handler.DataObjectResponseHandler; +import io.refactoring.http5.client.example.classic.util.UserRequestProcessingUtils; +import io.refactoring.http5.client.example.helper.BaseHttpRequestHelper; import io.refactoring.http5.client.example.model.User; import io.refactoring.http5.client.example.model.UserPage; - import java.net.URI; import java.text.MessageFormat; import java.util.Map; - -import io.refactoring.http5.client.example.classic.handler.DataObjectResponseHandler; -import io.refactoring.http5.client.example.classic.util.UserRequestProcessingUtils; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.apache.hc.client5.http.classic.methods.HttpGet; @@ -22,7 +21,7 @@ /** * Utility to handle HTTP requests for {@linkplain User} entities. It uses the user-defined types - * for HTTP processing + * for HTTP processing. */ @Slf4j public class UserTypeHttpRequestHelper extends BaseHttpRequestHelper { diff --git a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/util/RequestProcessingUtils.java b/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/util/RequestProcessingUtils.java index f2cc9b18b..12db3a09f 100644 --- a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/util/RequestProcessingUtils.java +++ b/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/util/RequestProcessingUtils.java @@ -2,7 +2,8 @@ import java.net.URISyntaxException; -import io.refactoring.http5.client.example.util.ConfigurationUtils; +import io.refactoring.http5.client.example.config.ConfigurationUtils; +import io.refactoring.http5.client.example.util.JsonUtils; import lombok.NonNull; import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.HttpHost; @@ -16,7 +17,7 @@ public abstract class RequestProcessingUtils { protected final ConfigurationUtils configurationUtils = new ConfigurationUtils(); /** - * Converts a source object into string entity. + * Converts a source object into a string entity. * * @param source source object * @return string entity diff --git a/apache-http-client/src/main/java/io/refactoring/http5/client/example/util/ConfigurationUtils.java b/apache-http-client/src/main/java/io/refactoring/http5/client/example/config/ConfigurationUtils.java similarity index 97% rename from apache-http-client/src/main/java/io/refactoring/http5/client/example/util/ConfigurationUtils.java rename to apache-http-client/src/main/java/io/refactoring/http5/client/example/config/ConfigurationUtils.java index f2cfde601..f10628e6c 100644 --- a/apache-http-client/src/main/java/io/refactoring/http5/client/example/util/ConfigurationUtils.java +++ b/apache-http-client/src/main/java/io/refactoring/http5/client/example/config/ConfigurationUtils.java @@ -1,4 +1,4 @@ -package io.refactoring.http5.client.example.util; +package io.refactoring.http5.client.example.config; import lombok.NonNull; import org.apache.commons.configuration2.Configuration; diff --git a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/HttpConfigurationHelper.java b/apache-http-client/src/main/java/io/refactoring/http5/client/example/config/helper/HttpConfigurationHelper.java similarity index 93% rename from apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/HttpConfigurationHelper.java rename to apache-http-client/src/main/java/io/refactoring/http5/client/example/config/helper/HttpConfigurationHelper.java index d228023d0..50e4eac08 100644 --- a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/HttpConfigurationHelper.java +++ b/apache-http-client/src/main/java/io/refactoring/http5/client/example/config/helper/HttpConfigurationHelper.java @@ -1,8 +1,9 @@ -package io.refactoring.http5.client.example.classic.helper; +package io.refactoring.http5.client.example.config.helper; -import io.refactoring.http5.client.example.classic.interceptor.CustomHttpExecutionInterceptor; -import io.refactoring.http5.client.example.classic.interceptor.CustomHttpRequestInterceptor; -import io.refactoring.http5.client.example.classic.interceptor.CustomHttpResponseInterceptor; +import io.refactoring.http5.client.example.config.interceptor.CustomHttpExecutionInterceptor; +import io.refactoring.http5.client.example.config.interceptor.CustomHttpRequestInterceptor; +import io.refactoring.http5.client.example.config.interceptor.CustomHttpResponseInterceptor; +import io.refactoring.http5.client.example.helper.BaseHttpRequestHelper; import lombok.extern.slf4j.Slf4j; import org.apache.hc.client5.http.HttpRoute; import org.apache.hc.client5.http.config.RequestConfig; diff --git a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/interceptor/CustomHttpExecutionInterceptor.java b/apache-http-client/src/main/java/io/refactoring/http5/client/example/config/interceptor/CustomHttpExecutionInterceptor.java similarity index 94% rename from apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/interceptor/CustomHttpExecutionInterceptor.java rename to apache-http-client/src/main/java/io/refactoring/http5/client/example/config/interceptor/CustomHttpExecutionInterceptor.java index 63d1b30c1..bed220acc 100644 --- a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/interceptor/CustomHttpExecutionInterceptor.java +++ b/apache-http-client/src/main/java/io/refactoring/http5/client/example/config/interceptor/CustomHttpExecutionInterceptor.java @@ -1,4 +1,4 @@ -package io.refactoring.http5.client.example.classic.interceptor; +package io.refactoring.http5.client.example.config.interceptor; import io.refactoring.http5.client.example.RequestProcessingException; import java.io.IOException; diff --git a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/interceptor/CustomHttpRequestInterceptor.java b/apache-http-client/src/main/java/io/refactoring/http5/client/example/config/interceptor/CustomHttpRequestInterceptor.java similarity index 91% rename from apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/interceptor/CustomHttpRequestInterceptor.java rename to apache-http-client/src/main/java/io/refactoring/http5/client/example/config/interceptor/CustomHttpRequestInterceptor.java index fb92c95d2..5fd01aabc 100644 --- a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/interceptor/CustomHttpRequestInterceptor.java +++ b/apache-http-client/src/main/java/io/refactoring/http5/client/example/config/interceptor/CustomHttpRequestInterceptor.java @@ -1,4 +1,4 @@ -package io.refactoring.http5.client.example.classic.interceptor; +package io.refactoring.http5.client.example.config.interceptor; import java.io.IOException; import java.util.UUID; diff --git a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/interceptor/CustomHttpResponseInterceptor.java b/apache-http-client/src/main/java/io/refactoring/http5/client/example/config/interceptor/CustomHttpResponseInterceptor.java similarity index 88% rename from apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/interceptor/CustomHttpResponseInterceptor.java rename to apache-http-client/src/main/java/io/refactoring/http5/client/example/config/interceptor/CustomHttpResponseInterceptor.java index 6ad67f415..1bf6aa5e1 100644 --- a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/interceptor/CustomHttpResponseInterceptor.java +++ b/apache-http-client/src/main/java/io/refactoring/http5/client/example/config/interceptor/CustomHttpResponseInterceptor.java @@ -1,4 +1,4 @@ -package io.refactoring.http5.client.example.classic.interceptor; +package io.refactoring.http5.client.example.config.interceptor; import java.io.IOException; import lombok.extern.slf4j.Slf4j; diff --git a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/BaseHttpRequestHelper.java b/apache-http-client/src/main/java/io/refactoring/http5/client/example/helper/BaseHttpRequestHelper.java similarity index 59% rename from apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/BaseHttpRequestHelper.java rename to apache-http-client/src/main/java/io/refactoring/http5/client/example/helper/BaseHttpRequestHelper.java index 0702bcea6..409fda6d4 100644 --- a/apache-http-client/src/main/java/io/refactoring/http5/client/example/classic/helper/BaseHttpRequestHelper.java +++ b/apache-http-client/src/main/java/io/refactoring/http5/client/example/helper/BaseHttpRequestHelper.java @@ -1,6 +1,6 @@ -package io.refactoring.http5.client.example.classic.helper; +package io.refactoring.http5.client.example.helper; -import io.refactoring.http5.client.example.classic.util.JsonUtils; +import io.refactoring.http5.client.example.util.JsonUtils; import lombok.extern.slf4j.Slf4j; /** Base HTTP request handler. */ diff --git a/apache-http-client/src/test/java/io/refactoring/http5/client/example/classic/BaseClassicExampleTests.java b/apache-http-client/src/test/java/io/refactoring/http5/client/example/classic/BaseClassicExampleTests.java index 650d8142f..dd06f917a 100644 --- a/apache-http-client/src/test/java/io/refactoring/http5/client/example/classic/BaseClassicExampleTests.java +++ b/apache-http-client/src/test/java/io/refactoring/http5/client/example/classic/BaseClassicExampleTests.java @@ -1,7 +1,7 @@ package io.refactoring.http5.client.example.classic; import io.refactoring.http5.client.example.BaseExampleTests; -import io.refactoring.http5.client.example.classic.util.JsonUtils; +import io.refactoring.http5.client.example.util.JsonUtils; abstract class BaseClassicExampleTests extends BaseExampleTests { protected final JsonUtils jsonUtils = new JsonUtils();