diff --git a/gradle/formatting.gradle b/gradle/formatting.gradle index 3e8120bb..88340057 100644 --- a/gradle/formatting.gradle +++ b/gradle/formatting.gradle @@ -7,6 +7,21 @@ allprojects { target '**/*.java' removeUnusedImports() + importOrder( + 'de.thetaphi', + 'com.carrotsearch', + 'com.fasterxml', + 'com.avast', + 'com.sun', + 'com.maxmind|com.github|com.networknt|groovy|nebula', + 'org.antlr', + 'software.amazon', + 'com.azure|com.microsoft|com.ibm|com.google|joptsimple|org.apache|org.bouncycastle|org.codehaus|org.opensearch|org.objectweb|org.joda|org.hamcrest|org.openjdk|org.gradle|org.junit', + 'javax', + 'java', + '', + '\\#java|\\#org.opensearch|\\#org.hamcrest|\\#' + ) eclipse().configFile rootProject.file('formatter/formatterConfig.xml') trimTrailingWhitespace() endWithNewline(); diff --git a/src/main/java/org/opensearch/sdk/Extension.java b/src/main/java/org/opensearch/sdk/Extension.java index cd440aed..cc11e04f 100644 --- a/src/main/java/org/opensearch/sdk/Extension.java +++ b/src/main/java/org/opensearch/sdk/Extension.java @@ -9,15 +9,15 @@ package org.opensearch.sdk; -import java.util.Collections; -import java.util.Collection; -import java.util.List; - import org.opensearch.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.settings.Setting; +import org.opensearch.common.settings.Settings; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.threadpool.ExecutorBuilder; -import org.opensearch.common.settings.Settings; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; /** * This interface defines methods which an extension must provide. Extensions diff --git a/src/main/java/org/opensearch/sdk/ExtensionsRunner.java b/src/main/java/org/opensearch/sdk/ExtensionsRunner.java index 7cb1f6f2..aeecf856 100644 --- a/src/main/java/org/opensearch/sdk/ExtensionsRunner.java +++ b/src/main/java/org/opensearch/sdk/ExtensionsRunner.java @@ -19,7 +19,6 @@ import org.opensearch.action.support.TransportAction; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.common.io.stream.NamedWriteableRegistry; -import org.opensearch.extensions.rest.ExtensionRestRequest; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; import org.opensearch.core.xcontent.NamedXContentRegistry; @@ -28,6 +27,7 @@ import org.opensearch.extensions.ExtensionsManager; import org.opensearch.extensions.UpdateSettingsRequest; import org.opensearch.extensions.action.ExtensionActionRequest; +import org.opensearch.extensions.rest.ExtensionRestRequest; import org.opensearch.sdk.action.SDKActionModule; import org.opensearch.sdk.api.ActionExtension; import org.opensearch.sdk.handlers.ExtensionActionRequestHandler; diff --git a/src/main/java/org/opensearch/sdk/NettyTransport.java b/src/main/java/org/opensearch/sdk/NettyTransport.java index a19f2108..6be1d58b 100644 --- a/src/main/java/org/opensearch/sdk/NettyTransport.java +++ b/src/main/java/org/opensearch/sdk/NettyTransport.java @@ -9,9 +9,6 @@ package org.opensearch.sdk; -import java.nio.file.Path; -import java.util.Collections; - import org.opensearch.Version; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.network.NetworkService; @@ -29,6 +26,9 @@ import org.opensearch.transport.TransportService; import org.opensearch.transport.netty4.Netty4Transport; +import java.nio.file.Path; +import java.util.Collections; + import static java.util.Collections.emptySet; import static org.opensearch.common.UUIDs.randomBase64UUID; diff --git a/src/main/java/org/opensearch/sdk/SDKClient.java b/src/main/java/org/opensearch/sdk/SDKClient.java index 149a049f..d05eaaa6 100644 --- a/src/main/java/org/opensearch/sdk/SDKClient.java +++ b/src/main/java/org/opensearch/sdk/SDKClient.java @@ -9,19 +9,15 @@ package org.opensearch.sdk; -import java.io.Closeable; -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.guava.GuavaModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; + +import org.apache.http.HttpHost; +import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionResponse; @@ -58,14 +54,12 @@ import org.opensearch.client.GetAliasesResponse; import org.opensearch.client.IndicesClient; import org.opensearch.client.Node; +import org.opensearch.client.Request; import org.opensearch.client.RequestOptions; import org.opensearch.client.Requests; -import org.apache.http.HttpHost; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.opensearch.client.RestClient; -import org.opensearch.client.Request; import org.opensearch.client.Response; import org.opensearch.client.ResponseListener; +import org.opensearch.client.RestClient; import org.opensearch.client.RestClientBuilder; import org.opensearch.client.RestHighLevelClient; import org.opensearch.client.indices.CreateIndexRequest; @@ -86,6 +80,13 @@ import org.opensearch.index.reindex.BulkByScrollResponse; import org.opensearch.index.reindex.DeleteByQueryRequest; +import java.io.Closeable; +import java.io.IOException; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + /** * This class creates SDKClient for an extension to make requests to OpenSearch */ diff --git a/src/main/java/org/opensearch/sdk/SDKClusterService.java b/src/main/java/org/opensearch/sdk/SDKClusterService.java index 1c8ea6c0..632b2fca 100644 --- a/src/main/java/org/opensearch/sdk/SDKClusterService.java +++ b/src/main/java/org/opensearch/sdk/SDKClusterService.java @@ -9,22 +9,22 @@ package org.opensearch.sdk; -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Consumer; - import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.ClusterState; +import org.opensearch.common.settings.AbstractScopedSettings; import org.opensearch.common.settings.Setting; +import org.opensearch.common.settings.Setting.Property; import org.opensearch.common.settings.SettingUpgrader; import org.opensearch.common.settings.Settings; -import org.opensearch.common.settings.AbstractScopedSettings; -import org.opensearch.common.settings.Setting.Property; import org.opensearch.extensions.DiscoveryExtensionNode; +import java.util.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Consumer; + /** * This class simulates methods normally called from OpenSearch ClusterService class. */ diff --git a/src/main/java/org/opensearch/sdk/SDKNamedXContentRegistry.java b/src/main/java/org/opensearch/sdk/SDKNamedXContentRegistry.java index 45dcb470..5c7f4139 100644 --- a/src/main/java/org/opensearch/sdk/SDKNamedXContentRegistry.java +++ b/src/main/java/org/opensearch/sdk/SDKNamedXContentRegistry.java @@ -9,22 +9,22 @@ package org.opensearch.sdk; -import static java.util.stream.Collectors.toList; - -import java.util.Collections; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Stream; - import org.opensearch.cluster.ClusterModule; import org.opensearch.common.network.NetworkModule; import org.opensearch.common.settings.Settings; -import org.opensearch.core.xcontent.XContentParser; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry.Entry; +import org.opensearch.core.xcontent.XContentParser; import org.opensearch.indices.IndicesModule; import org.opensearch.search.SearchModule; +import java.util.Collections; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Stream; + +import static java.util.stream.Collectors.toList; + /** * Combines Extension NamedXContent with core OpenSearch NamedXContent */ diff --git a/src/main/java/org/opensearch/sdk/SDKTransportService.java b/src/main/java/org/opensearch/sdk/SDKTransportService.java index ac873c73..35679ad6 100644 --- a/src/main/java/org/opensearch/sdk/SDKTransportService.java +++ b/src/main/java/org/opensearch/sdk/SDKTransportService.java @@ -9,16 +9,6 @@ package org.opensearch.sdk; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeoutException; -import java.util.function.Consumer; -import java.util.stream.Collectors; - import com.google.protobuf.ByteString; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -36,9 +26,9 @@ import org.opensearch.extensions.proto.ExtensionRequestProto; import org.opensearch.extensions.rest.RegisterRestActionsRequest; import org.opensearch.extensions.settings.RegisterCustomSettingsRequest; -import org.opensearch.sdk.api.ActionExtension.ActionHandler; import org.opensearch.sdk.action.RemoteExtensionActionRequest; import org.opensearch.sdk.action.SDKActionModule; +import org.opensearch.sdk.api.ActionExtension.ActionHandler; import org.opensearch.sdk.handlers.AcknowledgedResponseHandler; import org.opensearch.sdk.handlers.ClusterSettingsResponseHandler; import org.opensearch.sdk.handlers.ClusterStateResponseHandler; @@ -51,6 +41,16 @@ import org.opensearch.transport.TransportResponseHandler; import org.opensearch.transport.TransportService; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeoutException; +import java.util.function.Consumer; +import java.util.stream.Collectors; + /** * Wrapper class for {@link TransportService} and associated methods. * diff --git a/src/main/java/org/opensearch/sdk/action/RemoteExtensionActionRequest.java b/src/main/java/org/opensearch/sdk/action/RemoteExtensionActionRequest.java index b3242b4e..61bace35 100644 --- a/src/main/java/org/opensearch/sdk/action/RemoteExtensionActionRequest.java +++ b/src/main/java/org/opensearch/sdk/action/RemoteExtensionActionRequest.java @@ -9,9 +9,6 @@ package org.opensearch.sdk.action; -import java.io.IOException; -import java.util.Objects; - import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.ActionResponse; @@ -22,6 +19,9 @@ import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.extensions.action.ExtensionTransportActionsHandler; +import java.io.IOException; +import java.util.Objects; + /** * A request class to request an action be executed on another extension */ diff --git a/src/main/java/org/opensearch/sdk/action/RemoteExtensionTransportAction.java b/src/main/java/org/opensearch/sdk/action/RemoteExtensionTransportAction.java index fa9ce8ed..2cdd9caf 100644 --- a/src/main/java/org/opensearch/sdk/action/RemoteExtensionTransportAction.java +++ b/src/main/java/org/opensearch/sdk/action/RemoteExtensionTransportAction.java @@ -9,6 +9,7 @@ package org.opensearch.sdk.action; +import com.google.inject.Inject; import org.opensearch.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.TransportAction; @@ -17,8 +18,6 @@ import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskManager; -import com.google.inject.Inject; - /** * Sends a request to OpenSearch for a remote extension to execute an action. */ diff --git a/src/main/java/org/opensearch/sdk/action/SDKActionModule.java b/src/main/java/org/opensearch/sdk/action/SDKActionModule.java index a4e36cfe..fb679eae 100644 --- a/src/main/java/org/opensearch/sdk/action/SDKActionModule.java +++ b/src/main/java/org/opensearch/sdk/action/SDKActionModule.java @@ -9,21 +9,19 @@ package org.opensearch.sdk.action; -import java.util.Collections; -import java.util.Map; -import java.util.stream.Collectors; - +import com.google.inject.AbstractModule; +import com.google.inject.multibindings.MapBinder; import org.opensearch.action.ActionType; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.TransportAction; import org.opensearch.common.NamedRegistry; -import org.opensearch.sdk.api.ActionExtension.ActionHandler; import org.opensearch.sdk.Extension; - -import com.google.inject.AbstractModule; -import com.google.inject.multibindings.MapBinder; - import org.opensearch.sdk.api.ActionExtension; +import org.opensearch.sdk.api.ActionExtension.ActionHandler; + +import java.util.Collections; +import java.util.Map; +import java.util.stream.Collectors; import static java.util.Collections.unmodifiableMap; diff --git a/src/main/java/org/opensearch/sdk/api/ActionExtension.java b/src/main/java/org/opensearch/sdk/api/ActionExtension.java index 0c807f01..a6d645f6 100644 --- a/src/main/java/org/opensearch/sdk/api/ActionExtension.java +++ b/src/main/java/org/opensearch/sdk/api/ActionExtension.java @@ -9,17 +9,17 @@ package org.opensearch.sdk.api; -import org.opensearch.action.ActionType; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionResponse; +import org.opensearch.action.ActionType; import org.opensearch.action.RequestValidators; import org.opensearch.action.admin.indices.alias.IndicesAliasesRequest; import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest; import org.opensearch.action.support.ActionFilter; import org.opensearch.action.support.TransportAction; import org.opensearch.action.support.TransportActions; -import org.opensearch.core.common.Strings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.core.common.Strings; import org.opensearch.rest.RestHeaderDefinition; import org.opensearch.sdk.Extension; import org.opensearch.sdk.rest.ExtensionRestHandler; diff --git a/src/main/java/org/opensearch/sdk/api/SearchExtension.java b/src/main/java/org/opensearch/sdk/api/SearchExtension.java index 6249531c..ed801820 100644 --- a/src/main/java/org/opensearch/sdk/api/SearchExtension.java +++ b/src/main/java/org/opensearch/sdk/api/SearchExtension.java @@ -12,11 +12,11 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.Sort; import org.opensearch.common.CheckedFunction; -import org.opensearch.core.ParseField; import org.opensearch.common.io.stream.NamedWriteable; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.Writeable; import org.opensearch.common.lucene.search.function.ScoreFunction; +import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.ContextParser; import org.opensearch.core.xcontent.XContent; import org.opensearch.core.xcontent.XContentParser; diff --git a/src/main/java/org/opensearch/sdk/handlers/EnvironmentSettingsResponseHandler.java b/src/main/java/org/opensearch/sdk/handlers/EnvironmentSettingsResponseHandler.java index a70e4c0a..751fa550 100644 --- a/src/main/java/org/opensearch/sdk/handlers/EnvironmentSettingsResponseHandler.java +++ b/src/main/java/org/opensearch/sdk/handlers/EnvironmentSettingsResponseHandler.java @@ -11,10 +11,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.env.EnvironmentSettingsResponse; -import org.opensearch.extensions.ExtensionsManager; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.settings.Settings; +import org.opensearch.env.EnvironmentSettingsResponse; +import org.opensearch.extensions.ExtensionsManager; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportException; import org.opensearch.transport.TransportResponseHandler; diff --git a/src/main/java/org/opensearch/sdk/handlers/ExtensionActionRequestHandler.java b/src/main/java/org/opensearch/sdk/handlers/ExtensionActionRequestHandler.java index 4c0f8657..4002a07e 100644 --- a/src/main/java/org/opensearch/sdk/handlers/ExtensionActionRequestHandler.java +++ b/src/main/java/org/opensearch/sdk/handlers/ExtensionActionRequestHandler.java @@ -9,13 +9,6 @@ package org.opensearch.sdk.handlers; -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.action.ActionListener; @@ -33,6 +26,13 @@ import org.opensearch.sdk.SDKTransportService; import org.opensearch.sdk.action.RemoteExtensionActionRequest; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; + /** * This class handles a request from OpenSearch from another extension's {@link SDKTransportService#sendRemoteExtensionActionRequest} call. */ diff --git a/src/main/java/org/opensearch/sdk/handlers/ExtensionActionResponseHandler.java b/src/main/java/org/opensearch/sdk/handlers/ExtensionActionResponseHandler.java index 0932f105..f3be4a0b 100644 --- a/src/main/java/org/opensearch/sdk/handlers/ExtensionActionResponseHandler.java +++ b/src/main/java/org/opensearch/sdk/handlers/ExtensionActionResponseHandler.java @@ -11,10 +11,10 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.opensearch.common.io.stream.StreamInput; import org.opensearch.extensions.ExtensionsManager; import org.opensearch.extensions.action.RemoteExtensionActionResponse; import org.opensearch.sdk.SDKTransportService; -import org.opensearch.common.io.stream.StreamInput; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportException; import org.opensearch.transport.TransportResponseHandler; diff --git a/src/main/java/org/opensearch/sdk/handlers/ExtensionDependencyResponseHandler.java b/src/main/java/org/opensearch/sdk/handlers/ExtensionDependencyResponseHandler.java index 38de3eb6..96245be0 100644 --- a/src/main/java/org/opensearch/sdk/handlers/ExtensionDependencyResponseHandler.java +++ b/src/main/java/org/opensearch/sdk/handlers/ExtensionDependencyResponseHandler.java @@ -9,11 +9,6 @@ package org.opensearch.sdk.handlers; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.common.io.stream.StreamInput; @@ -24,6 +19,11 @@ import org.opensearch.transport.TransportException; import org.opensearch.transport.TransportResponseHandler; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; + /** * This class handles the response from OpenSearch to a {@link org.opensearch.sdk.SDKTransportService#sendExtensionDependencyRequest} call. */ diff --git a/src/main/java/org/opensearch/sdk/handlers/ExtensionsIndicesModuleNameRequestHandler.java b/src/main/java/org/opensearch/sdk/handlers/ExtensionsIndicesModuleNameRequestHandler.java index 5c046de6..30a22bad 100644 --- a/src/main/java/org/opensearch/sdk/handlers/ExtensionsIndicesModuleNameRequestHandler.java +++ b/src/main/java/org/opensearch/sdk/handlers/ExtensionsIndicesModuleNameRequestHandler.java @@ -12,8 +12,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.extensions.AcknowledgedResponse; -import org.opensearch.sdk.ExtensionsRunner; import org.opensearch.index.IndicesModuleRequest; +import org.opensearch.sdk.ExtensionsRunner; /** * This class handles the request from OpenSearch to a {@link ExtensionsRunner#startTransportService(TransportService transportService)} call. diff --git a/src/main/java/org/opensearch/sdk/handlers/ExtensionsInitRequestHandler.java b/src/main/java/org/opensearch/sdk/handlers/ExtensionsInitRequestHandler.java index fc4eb87a..55251b55 100644 --- a/src/main/java/org/opensearch/sdk/handlers/ExtensionsInitRequestHandler.java +++ b/src/main/java/org/opensearch/sdk/handlers/ExtensionsInitRequestHandler.java @@ -10,7 +10,6 @@ package org.opensearch.sdk.handlers; import org.apache.logging.log4j.LogManager; - import org.apache.logging.log4j.Logger; import org.opensearch.common.settings.Settings; import org.opensearch.discovery.InitializeExtensionRequest; diff --git a/src/main/java/org/opensearch/sdk/handlers/ExtensionsRestRequestHandler.java b/src/main/java/org/opensearch/sdk/handlers/ExtensionsRestRequestHandler.java index 30f9acfa..63cbde18 100644 --- a/src/main/java/org/opensearch/sdk/handlers/ExtensionsRestRequestHandler.java +++ b/src/main/java/org/opensearch/sdk/handlers/ExtensionsRestRequestHandler.java @@ -23,8 +23,8 @@ import org.opensearch.sdk.rest.SDKRestRequest; import static java.nio.charset.StandardCharsets.UTF_8; -import static java.util.Collections.emptyMap; import static java.util.Collections.emptyList; +import static java.util.Collections.emptyMap; import static org.opensearch.rest.BytesRestResponse.TEXT_CONTENT_TYPE; import static org.opensearch.rest.RestStatus.NOT_FOUND; diff --git a/src/main/java/org/opensearch/sdk/handlers/UpdateSettingsRequestHandler.java b/src/main/java/org/opensearch/sdk/handlers/UpdateSettingsRequestHandler.java index e7f72211..089b2e9f 100644 --- a/src/main/java/org/opensearch/sdk/handlers/UpdateSettingsRequestHandler.java +++ b/src/main/java/org/opensearch/sdk/handlers/UpdateSettingsRequestHandler.java @@ -9,10 +9,6 @@ package org.opensearch.sdk.handlers; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Consumer; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.opensearch.Version; @@ -23,6 +19,10 @@ import org.opensearch.extensions.AcknowledgedResponse; import org.opensearch.extensions.UpdateSettingsRequest; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; + /** * Handles requests to update settings */ diff --git a/src/main/java/org/opensearch/sdk/rest/BaseExtensionRestHandler.java b/src/main/java/org/opensearch/sdk/rest/BaseExtensionRestHandler.java index 524d3941..e262b936 100644 --- a/src/main/java/org/opensearch/sdk/rest/BaseExtensionRestHandler.java +++ b/src/main/java/org/opensearch/sdk/rest/BaseExtensionRestHandler.java @@ -9,31 +9,31 @@ package org.opensearch.sdk.rest; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import org.opensearch.rest.BaseRestHandler; -import static org.opensearch.rest.RestStatus.INTERNAL_SERVER_ERROR; -import static org.opensearch.rest.RestStatus.NOT_FOUND; - -import java.io.IOException; -import java.util.Objects; -import java.util.function.Function; - -import static org.apache.http.entity.ContentType.APPLICATION_JSON; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.extensions.rest.ExtensionRestResponse; +import org.opensearch.rest.BaseRestHandler; +import org.opensearch.rest.DeprecationRestHandler; import org.opensearch.rest.RestHandler.DeprecatedRoute; import org.opensearch.rest.RestHandler.ReplacedRoute; import org.opensearch.rest.RestHandler.Route; -import org.opensearch.rest.RestRequest.Method; -import org.opensearch.rest.DeprecationRestHandler; import org.opensearch.rest.RestRequest; +import org.opensearch.rest.RestRequest.Method; import org.opensearch.rest.RestStatus; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Function; + +import static org.opensearch.rest.RestStatus.INTERNAL_SERVER_ERROR; +import static org.opensearch.rest.RestStatus.NOT_FOUND; +import static org.apache.http.entity.ContentType.APPLICATION_JSON; + /** * Provides convenience methods to reduce boilerplate code in an {@link ExtensionRestHandler} implementation. */ diff --git a/src/main/java/org/opensearch/sdk/rest/ExtensionRestHandler.java b/src/main/java/org/opensearch/sdk/rest/ExtensionRestHandler.java index ed4d3c87..bc1e122f 100644 --- a/src/main/java/org/opensearch/sdk/rest/ExtensionRestHandler.java +++ b/src/main/java/org/opensearch/sdk/rest/ExtensionRestHandler.java @@ -9,9 +9,6 @@ package org.opensearch.sdk.rest; -import java.util.Collections; -import java.util.List; - import org.opensearch.extensions.rest.ExtensionRestResponse; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.RestHandler; @@ -20,6 +17,9 @@ import org.opensearch.rest.RestHandler.Route; import org.opensearch.rest.RestRequest; +import java.util.Collections; +import java.util.List; + /** * This interface defines methods which an extension REST handler (action) must provide. * It is the Extension counterpart to core OpenSearch {@link RestHandler}. diff --git a/src/main/java/org/opensearch/sdk/rest/ExtensionRestPathRegistry.java b/src/main/java/org/opensearch/sdk/rest/ExtensionRestPathRegistry.java index 3dd76950..a372f41c 100644 --- a/src/main/java/org/opensearch/sdk/rest/ExtensionRestPathRegistry.java +++ b/src/main/java/org/opensearch/sdk/rest/ExtensionRestPathRegistry.java @@ -9,9 +9,6 @@ package org.opensearch.sdk.rest; -import java.util.ArrayList; -import java.util.List; - import org.opensearch.common.Nullable; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.path.PathTrie; @@ -19,6 +16,9 @@ import org.opensearch.rest.RestUtils; import org.opensearch.sdk.rest.BaseExtensionRestHandler.ExtensionDeprecationRestHandler; +import java.util.ArrayList; +import java.util.List; + /** * This class registers REST paths from extension Rest Handlers. */ diff --git a/src/main/java/org/opensearch/sdk/rest/ReplacedRouteHandler.java b/src/main/java/org/opensearch/sdk/rest/ReplacedRouteHandler.java index 99d4c5ab..7378f3f1 100644 --- a/src/main/java/org/opensearch/sdk/rest/ReplacedRouteHandler.java +++ b/src/main/java/org/opensearch/sdk/rest/ReplacedRouteHandler.java @@ -9,14 +9,14 @@ package org.opensearch.sdk.rest; -import java.util.function.Function; - import org.opensearch.extensions.rest.ExtensionRestResponse; import org.opensearch.rest.RestHandler.ReplacedRoute; import org.opensearch.rest.RestHandler.Route; import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; +import java.util.function.Function; + /** * A subclass of {@link ReplacedRoute} that includes a handler method for that route. */ diff --git a/src/main/java/org/opensearch/sdk/rest/SDKRestRequest.java b/src/main/java/org/opensearch/sdk/rest/SDKRestRequest.java index 0d4187d8..b5e08ea8 100644 --- a/src/main/java/org/opensearch/sdk/rest/SDKRestRequest.java +++ b/src/main/java/org/opensearch/sdk/rest/SDKRestRequest.java @@ -9,14 +9,14 @@ package org.opensearch.sdk.rest; -import java.util.List; -import java.util.Map; - import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.http.HttpChannel; import org.opensearch.http.HttpRequest; import org.opensearch.rest.RestRequest; +import java.util.List; +import java.util.Map; + /** * This class helps to get instance of RestRequest */ diff --git a/src/main/java/org/opensearch/sdk/sample/helloworld/ExampleCustomSettingConfig.java b/src/main/java/org/opensearch/sdk/sample/helloworld/ExampleCustomSettingConfig.java index b5c7e38e..664de519 100644 --- a/src/main/java/org/opensearch/sdk/sample/helloworld/ExampleCustomSettingConfig.java +++ b/src/main/java/org/opensearch/sdk/sample/helloworld/ExampleCustomSettingConfig.java @@ -10,8 +10,8 @@ package org.opensearch.sdk.sample.helloworld; import org.opensearch.common.settings.Setting; -import org.opensearch.common.settings.Setting.RegexValidator; import org.opensearch.common.settings.Setting.Property; +import org.opensearch.common.settings.Setting.RegexValidator; /** * {@link ExampleCustomSettingConfig} contains the custom settings value and their static declarations. diff --git a/src/main/java/org/opensearch/sdk/sample/helloworld/HelloWorldExtension.java b/src/main/java/org/opensearch/sdk/sample/helloworld/HelloWorldExtension.java index f4b8566d..d28a7c64 100644 --- a/src/main/java/org/opensearch/sdk/sample/helloworld/HelloWorldExtension.java +++ b/src/main/java/org/opensearch/sdk/sample/helloworld/HelloWorldExtension.java @@ -9,10 +9,6 @@ package org.opensearch.sdk.sample.helloworld; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionResponse; import org.opensearch.common.settings.Setting; @@ -27,6 +23,10 @@ import org.opensearch.sdk.sample.helloworld.transport.SampleAction; import org.opensearch.sdk.sample.helloworld.transport.SampleTransportAction; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + /** * Sample class to demonstrate how to use the OpenSearch SDK for Java to create * an extension. diff --git a/src/main/java/org/opensearch/sdk/sample/helloworld/rest/RestHelloAction.java b/src/main/java/org/opensearch/sdk/sample/helloworld/rest/RestHelloAction.java index 8673d48c..c8068384 100644 --- a/src/main/java/org/opensearch/sdk/sample/helloworld/rest/RestHelloAction.java +++ b/src/main/java/org/opensearch/sdk/sample/helloworld/rest/RestHelloAction.java @@ -11,13 +11,14 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.common.bytes.BytesReference; -import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.extensions.rest.ExtensionRestResponse; import org.opensearch.rest.RestRequest; import org.opensearch.sdk.rest.BaseExtensionRestHandler; import org.opensearch.sdk.rest.ExtensionRestHandler; + import java.io.IOException; import java.net.URLDecoder; import java.nio.ByteBuffer; diff --git a/src/main/java/org/opensearch/sdk/sample/helloworld/transport/SampleRequest.java b/src/main/java/org/opensearch/sdk/sample/helloworld/transport/SampleRequest.java index 38f1eade..942597e8 100644 --- a/src/main/java/org/opensearch/sdk/sample/helloworld/transport/SampleRequest.java +++ b/src/main/java/org/opensearch/sdk/sample/helloworld/transport/SampleRequest.java @@ -9,13 +9,13 @@ package org.opensearch.sdk.sample.helloworld.transport; -import java.io.IOException; - import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import java.io.IOException; + /** * A sample request class to demonstrate extension actions */ diff --git a/src/main/java/org/opensearch/sdk/sample/helloworld/transport/SampleResponse.java b/src/main/java/org/opensearch/sdk/sample/helloworld/transport/SampleResponse.java index 80e60706..952b899e 100644 --- a/src/main/java/org/opensearch/sdk/sample/helloworld/transport/SampleResponse.java +++ b/src/main/java/org/opensearch/sdk/sample/helloworld/transport/SampleResponse.java @@ -9,12 +9,12 @@ package org.opensearch.sdk.sample.helloworld.transport; -import java.io.IOException; - import org.opensearch.action.ActionResponse; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import java.io.IOException; + /** * A sample response class to demonstrate extension actions */ diff --git a/src/main/java/org/opensearch/sdk/sample/helloworld/transport/SampleTransportAction.java b/src/main/java/org/opensearch/sdk/sample/helloworld/transport/SampleTransportAction.java index 2c80f1cf..356c59e9 100644 --- a/src/main/java/org/opensearch/sdk/sample/helloworld/transport/SampleTransportAction.java +++ b/src/main/java/org/opensearch/sdk/sample/helloworld/transport/SampleTransportAction.java @@ -9,14 +9,13 @@ package org.opensearch.sdk.sample.helloworld.transport; +import com.google.inject.Inject; import org.opensearch.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.TransportAction; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskManager; -import com.google.inject.Inject; - /** * A sample {@link TransportAction} used as they value for the action map */ diff --git a/src/main/java/org/opensearch/sdk/ssl/DefaultSslKeyStore.java b/src/main/java/org/opensearch/sdk/ssl/DefaultSslKeyStore.java index 8b0966db..51818ac0 100644 --- a/src/main/java/org/opensearch/sdk/ssl/DefaultSslKeyStore.java +++ b/src/main/java/org/opensearch/sdk/ssl/DefaultSslKeyStore.java @@ -9,6 +9,27 @@ package org.opensearch.sdk.ssl; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.opensearch.OpenSearchException; +import org.opensearch.OpenSearchSecurityException; +import org.opensearch.SpecialPermission; +import org.opensearch.common.settings.Settings; +import org.opensearch.env.Environment; +import org.opensearch.sdk.ssl.util.CertFileProps; +import org.opensearch.sdk.ssl.util.CertFromFile; +import org.opensearch.sdk.ssl.util.CertFromKeystore; +import org.opensearch.sdk.ssl.util.CertFromTruststore; +import org.opensearch.sdk.ssl.util.ExceptionUtils; +import org.opensearch.sdk.ssl.util.KeystoreProps; +import org.opensearch.transport.NettyAllocator; + +import javax.crypto.Cipher; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLEngine; +import javax.net.ssl.SSLException; +import javax.net.ssl.SSLParameters; + import java.io.File; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -35,12 +56,6 @@ import java.util.stream.Stream; import java.util.stream.StreamSupport; -import javax.crypto.Cipher; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLEngine; -import javax.net.ssl.SSLException; -import javax.net.ssl.SSLParameters; - import io.netty.handler.codec.http2.Http2SecurityUtil; import io.netty.handler.ssl.ApplicationProtocolConfig; import io.netty.handler.ssl.ApplicationProtocolConfig.Protocol; @@ -52,27 +67,6 @@ import io.netty.handler.ssl.SslContextBuilder; import io.netty.handler.ssl.SslProvider; import io.netty.handler.ssl.SupportedCipherSuiteFilter; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -//import org.bouncycastle.asn1.ASN1InputStream; -//import org.bouncycastle.asn1.ASN1ObjectIdentifier; -//import org.bouncycastle.asn1.ASN1Primitive; -//import org.bouncycastle.asn1.ASN1Sequence; -//import org.bouncycastle.asn1.ASN1String; -//import org.bouncycastle.asn1.ASN1TaggedObject; - -import org.opensearch.OpenSearchException; -import org.opensearch.OpenSearchSecurityException; -import org.opensearch.SpecialPermission; -import org.opensearch.common.settings.Settings; -import org.opensearch.env.Environment; -import org.opensearch.sdk.ssl.util.CertFileProps; -import org.opensearch.sdk.ssl.util.CertFromFile; -import org.opensearch.sdk.ssl.util.CertFromKeystore; -import org.opensearch.sdk.ssl.util.CertFromTruststore; -import org.opensearch.sdk.ssl.util.ExceptionUtils; -import org.opensearch.sdk.ssl.util.KeystoreProps; -import org.opensearch.transport.NettyAllocator; import static org.opensearch.sdk.ssl.SecureSSLSettings.SSLSetting.SSL_TRANSPORT_CLIENT_KEYSTORE_KEYPASSWORD; import static org.opensearch.sdk.ssl.SecureSSLSettings.SSLSetting.SSL_TRANSPORT_CLIENT_PEMKEY_PASSWORD; diff --git a/src/main/java/org/opensearch/sdk/ssl/SSLConfigConstants.java b/src/main/java/org/opensearch/sdk/ssl/SSLConfigConstants.java index c5735761..9032864e 100644 --- a/src/main/java/org/opensearch/sdk/ssl/SSLConfigConstants.java +++ b/src/main/java/org/opensearch/sdk/ssl/SSLConfigConstants.java @@ -9,12 +9,12 @@ package org.opensearch.sdk.ssl; +import org.opensearch.common.settings.Settings; + import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.opensearch.common.settings.Settings; - /** * Class containing constants for SSL */ diff --git a/src/main/java/org/opensearch/sdk/ssl/SSLNettyTransport.java b/src/main/java/org/opensearch/sdk/ssl/SSLNettyTransport.java index 38593d0f..a922a6f0 100644 --- a/src/main/java/org/opensearch/sdk/ssl/SSLNettyTransport.java +++ b/src/main/java/org/opensearch/sdk/ssl/SSLNettyTransport.java @@ -9,22 +9,8 @@ package org.opensearch.sdk.ssl; -import java.net.InetSocketAddress; -import java.net.SocketAddress; - -import javax.net.ssl.SSLEngine; -import javax.net.ssl.SSLException; - -import io.netty.channel.Channel; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelOutboundHandlerAdapter; -import io.netty.channel.ChannelPromise; -import io.netty.handler.codec.DecoderException; -import io.netty.handler.ssl.SslHandler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.ExceptionsHelper; import org.opensearch.Version; import org.opensearch.cluster.node.DiscoveryNode; @@ -38,6 +24,20 @@ import org.opensearch.transport.TcpChannel; import org.opensearch.transport.netty4.Netty4Transport; +import javax.net.ssl.SSLEngine; +import javax.net.ssl.SSLException; + +import java.net.InetSocketAddress; +import java.net.SocketAddress; + +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelPromise; +import io.netty.handler.codec.DecoderException; +import io.netty.handler.ssl.SslHandler; + /** * Class that setups up secure TLS channel for this extension to use with transport requests */ diff --git a/src/main/java/org/opensearch/sdk/ssl/SecureSSLSettings.java b/src/main/java/org/opensearch/sdk/ssl/SecureSSLSettings.java index 604a1973..61e2076d 100644 --- a/src/main/java/org/opensearch/sdk/ssl/SecureSSLSettings.java +++ b/src/main/java/org/opensearch/sdk/ssl/SecureSSLSettings.java @@ -9,16 +9,15 @@ package org.opensearch.sdk.ssl; -import java.util.Optional; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.opensearch.common.settings.SecureSetting; import org.opensearch.common.settings.SecureString; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; +import java.util.Optional; + import static org.opensearch.sdk.ssl.SSLConfigConstants.DEFAULT_STORE_PASSWORD; /** diff --git a/src/main/java/org/opensearch/sdk/ssl/SslKeyStore.java b/src/main/java/org/opensearch/sdk/ssl/SslKeyStore.java index 711b5d89..1f46ca48 100644 --- a/src/main/java/org/opensearch/sdk/ssl/SslKeyStore.java +++ b/src/main/java/org/opensearch/sdk/ssl/SslKeyStore.java @@ -9,11 +9,11 @@ package org.opensearch.sdk.ssl; -import java.security.cert.X509Certificate; - import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLException; +import java.security.cert.X509Certificate; + /** * Interface for an SslKeyStore */ diff --git a/src/test/java/org/opensearch/sdk/TestBaseExtension.java b/src/test/java/org/opensearch/sdk/TestBaseExtension.java index 64b7af1f..55a01b83 100644 --- a/src/test/java/org/opensearch/sdk/TestBaseExtension.java +++ b/src/test/java/org/opensearch/sdk/TestBaseExtension.java @@ -9,10 +9,10 @@ package org.opensearch.sdk; -import java.io.IOException; - -import org.junit.jupiter.api.Test; import org.opensearch.test.OpenSearchTestCase; +import org.junit.jupiter.api.Test; + +import java.io.IOException; /* * Most of the code in BaseExtension is tested by HelloWorld extension tests. diff --git a/src/test/java/org/opensearch/sdk/TestExtensionInterfaces.java b/src/test/java/org/opensearch/sdk/TestExtensionInterfaces.java index c0c8da3f..b2a9a05a 100644 --- a/src/test/java/org/opensearch/sdk/TestExtensionInterfaces.java +++ b/src/test/java/org/opensearch/sdk/TestExtensionInterfaces.java @@ -9,13 +9,6 @@ package org.opensearch.sdk; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; - -import java.util.Collections; -import java.util.Map; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; import org.opensearch.common.breaker.CircuitBreaker; import org.opensearch.common.settings.Settings; import org.opensearch.index.mapper.Mapper; @@ -35,11 +28,16 @@ import org.opensearch.sdk.api.ScriptExtension; import org.opensearch.sdk.api.SearchExtension; import org.opensearch.sdk.api.SystemIndexExtension; - import org.opensearch.test.OpenSearchTestCase; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import java.util.Collections; +import java.util.Map; import java.util.function.Predicate; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + public class TestExtensionInterfaces extends OpenSearchTestCase { @Test diff --git a/src/test/java/org/opensearch/sdk/TestExtensionSettings.java b/src/test/java/org/opensearch/sdk/TestExtensionSettings.java index b6edc8b4..21a1cfad 100644 --- a/src/test/java/org/opensearch/sdk/TestExtensionSettings.java +++ b/src/test/java/org/opensearch/sdk/TestExtensionSettings.java @@ -9,9 +9,9 @@ package org.opensearch.sdk; +import org.opensearch.test.OpenSearchTestCase; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.opensearch.test.OpenSearchTestCase; import java.io.IOException; diff --git a/src/test/java/org/opensearch/sdk/TestExtensionsRunner.java b/src/test/java/org/opensearch/sdk/TestExtensionsRunner.java index e6daa764..84e1075c 100644 --- a/src/test/java/org/opensearch/sdk/TestExtensionsRunner.java +++ b/src/test/java/org/opensearch/sdk/TestExtensionsRunner.java @@ -9,60 +9,60 @@ package org.opensearch.sdk; -import static java.util.Collections.emptyMap; -import static java.util.Collections.emptySet; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.nio.charset.StandardCharsets; -import java.security.Principal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import org.opensearch.Version; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.bytes.BytesArray; -import org.opensearch.common.settings.Settings; +import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Setting.Property; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.settings.WriteableSetting; import org.opensearch.common.transport.TransportAddress; import org.opensearch.discovery.InitializeExtensionRequest; import org.opensearch.discovery.InitializeExtensionResponse; -import org.opensearch.extensions.DiscoveryExtensionNode; import org.opensearch.extensions.AcknowledgedResponse; +import org.opensearch.extensions.DiscoveryExtensionNode; import org.opensearch.extensions.ExtensionDependency; +import org.opensearch.extensions.UpdateSettingsRequest; import org.opensearch.extensions.rest.ExtensionRestRequest; import org.opensearch.extensions.rest.RestExecuteOnExtensionResponse; import org.opensearch.http.HttpRequest; import org.opensearch.rest.BytesRestResponse; import org.opensearch.rest.RestRequest.Method; import org.opensearch.rest.RestStatus; -import org.opensearch.common.settings.Setting; -import org.opensearch.extensions.UpdateSettingsRequest; +import org.opensearch.sdk.handlers.AcknowledgedResponseHandler; import org.opensearch.sdk.handlers.ClusterSettingsResponseHandler; import org.opensearch.sdk.handlers.ClusterStateResponseHandler; import org.opensearch.sdk.handlers.EnvironmentSettingsResponseHandler; import org.opensearch.sdk.handlers.ExtensionsInitRequestHandler; import org.opensearch.sdk.handlers.ExtensionsRestRequestHandler; import org.opensearch.sdk.rest.ExtensionRestPathRegistry; -import org.opensearch.sdk.handlers.AcknowledgedResponseHandler; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.transport.Transport; import org.opensearch.transport.TransportService; import org.opensearch.transport.TransportSettings; -import org.opensearch.common.settings.WriteableSetting; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.nio.charset.StandardCharsets; +import java.security.Principal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; + +import static java.util.Collections.emptyMap; +import static java.util.Collections.emptySet; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; public class TestExtensionsRunner extends OpenSearchTestCase { diff --git a/src/test/java/org/opensearch/sdk/TestNetty4Transport.java b/src/test/java/org/opensearch/sdk/TestNetty4Transport.java index ed9ce102..d4c614d6 100644 --- a/src/test/java/org/opensearch/sdk/TestNetty4Transport.java +++ b/src/test/java/org/opensearch/sdk/TestNetty4Transport.java @@ -9,16 +9,16 @@ package org.opensearch.sdk; -import java.io.IOException; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import org.opensearch.common.component.Lifecycle; import org.opensearch.common.settings.Settings; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportSettings; - import org.opensearch.transport.netty4.Netty4Transport; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.IOException; public class TestNetty4Transport extends OpenSearchTestCase { diff --git a/src/test/java/org/opensearch/sdk/TestSDKClient.java b/src/test/java/org/opensearch/sdk/TestSDKClient.java index 0be408f6..091e5728 100644 --- a/src/test/java/org/opensearch/sdk/TestSDKClient.java +++ b/src/test/java/org/opensearch/sdk/TestSDKClient.java @@ -9,7 +9,6 @@ package org.opensearch.sdk; -import org.junit.jupiter.api.Test; import org.opensearch.action.ActionListener; import org.opensearch.action.admin.cluster.health.ClusterHealthRequest; import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; @@ -45,15 +44,15 @@ import org.opensearch.sdk.SDKClient.SDKIndicesClient; import org.opensearch.sdk.SDKClient.SDKRestClient; import org.opensearch.test.OpenSearchTestCase; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; - import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.net.ConnectException; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; + @SuppressWarnings("deprecation") public class TestSDKClient extends OpenSearchTestCase { private SDKClient sdkClient; diff --git a/src/test/java/org/opensearch/sdk/TestSDKClusterService.java b/src/test/java/org/opensearch/sdk/TestSDKClusterService.java index f931a509..c1f7316a 100644 --- a/src/test/java/org/opensearch/sdk/TestSDKClusterService.java +++ b/src/test/java/org/opensearch/sdk/TestSDKClusterService.java @@ -9,8 +9,6 @@ package org.opensearch.sdk; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import org.opensearch.cluster.ClusterName; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Setting.Property; @@ -20,6 +18,12 @@ import org.opensearch.sdk.handlers.AcknowledgedResponseHandler; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.transport.TransportService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.Collections; +import java.util.List; +import java.util.function.Consumer; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertInstanceOf; @@ -31,10 +35,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.util.Collections; -import java.util.List; -import java.util.function.Consumer; - public class TestSDKClusterService extends OpenSearchTestCase { private ExtensionsRunner extensionsRunner; private SDKClusterService sdkClusterService; diff --git a/src/test/java/org/opensearch/sdk/TestSDKNamedWriteableRegistry.java b/src/test/java/org/opensearch/sdk/TestSDKNamedWriteableRegistry.java index 54b25110..d412aa78 100644 --- a/src/test/java/org/opensearch/sdk/TestSDKNamedWriteableRegistry.java +++ b/src/test/java/org/opensearch/sdk/TestSDKNamedWriteableRegistry.java @@ -9,8 +9,6 @@ package org.opensearch.sdk; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import org.opensearch.common.io.stream.NamedWriteable; import org.opensearch.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.io.stream.StreamInput; @@ -18,6 +16,8 @@ import org.opensearch.common.io.stream.Writeable; import org.opensearch.common.settings.Settings; import org.opensearch.test.OpenSearchTestCase; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.util.Collections; diff --git a/src/test/java/org/opensearch/sdk/TestSDKNamedXContentRegistry.java b/src/test/java/org/opensearch/sdk/TestSDKNamedXContentRegistry.java index 43212bed..4bfc014a 100644 --- a/src/test/java/org/opensearch/sdk/TestSDKNamedXContentRegistry.java +++ b/src/test/java/org/opensearch/sdk/TestSDKNamedXContentRegistry.java @@ -9,28 +9,28 @@ package org.opensearch.sdk; -import static org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken; - -import org.opensearch.core.ParseField; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.LoggingDeprecationHandler; +import org.opensearch.common.xcontent.XContentType; +import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.ParseField; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry.Entry; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParseException; import org.opensearch.core.xcontent.XContentParser; -import org.opensearch.common.xcontent.XContentType; -import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.test.OpenSearchTestCase; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.Objects; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import static org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken; public class TestSDKNamedXContentRegistry extends OpenSearchTestCase { private ExampleRunnerForTest runner; diff --git a/src/test/java/org/opensearch/sdk/TestSDKTransportService.java b/src/test/java/org/opensearch/sdk/TestSDKTransportService.java index 60a1bc2a..5e2826ee 100644 --- a/src/test/java/org/opensearch/sdk/TestSDKTransportService.java +++ b/src/test/java/org/opensearch/sdk/TestSDKTransportService.java @@ -9,9 +9,6 @@ package org.opensearch.sdk; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; import org.opensearch.Version; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.settings.Settings; @@ -25,10 +22,14 @@ import org.opensearch.test.OpenSearchTestCase; import org.opensearch.transport.Transport; import org.opensearch.transport.TransportService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.net.InetAddress; import java.util.Collections; +import org.mockito.ArgumentCaptor; + import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; import static org.mockito.ArgumentMatchers.any; diff --git a/src/test/java/org/opensearch/sdk/TestThreadPool.java b/src/test/java/org/opensearch/sdk/TestThreadPool.java index 6ec24919..664fbfef 100644 --- a/src/test/java/org/opensearch/sdk/TestThreadPool.java +++ b/src/test/java/org/opensearch/sdk/TestThreadPool.java @@ -9,16 +9,17 @@ package org.opensearch.sdk; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.OpenSearchExecutors; import org.opensearch.node.Node; import org.opensearch.threadpool.ExecutorBuilder; import org.opensearch.threadpool.ThreadPool; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; + public class TestThreadPool extends ThreadPool { private final CountDownLatch blockingLatch; private volatile boolean returnRejectingExecutor; diff --git a/src/test/java/org/opensearch/sdk/action/TestProxyActionRequest.java b/src/test/java/org/opensearch/sdk/action/TestProxyActionRequest.java index 6c432c3f..1887aad1 100644 --- a/src/test/java/org/opensearch/sdk/action/TestProxyActionRequest.java +++ b/src/test/java/org/opensearch/sdk/action/TestProxyActionRequest.java @@ -9,14 +9,6 @@ package org.opensearch.sdk.action; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; - -import java.io.IOException; -import java.util.Collections; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.ActionResponse; @@ -34,6 +26,14 @@ import org.opensearch.test.OpenSearchTestCase; import org.opensearch.transport.Transport; import org.opensearch.transport.TransportService; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.util.Collections; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; public class TestProxyActionRequest extends OpenSearchTestCase { private ExtensionsRunner extensionsRunner; diff --git a/src/test/java/org/opensearch/sdk/action/TestSDKActionModule.java b/src/test/java/org/opensearch/sdk/action/TestSDKActionModule.java index 714db721..fc4e32bd 100644 --- a/src/test/java/org/opensearch/sdk/action/TestSDKActionModule.java +++ b/src/test/java/org/opensearch/sdk/action/TestSDKActionModule.java @@ -9,15 +9,15 @@ package org.opensearch.sdk.action; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionResponse; import org.opensearch.action.ActionType; -import org.opensearch.sdk.api.ActionExtension; import org.opensearch.sdk.BaseExtension; import org.opensearch.sdk.ExtensionSettings; +import org.opensearch.sdk.api.ActionExtension; import org.opensearch.test.OpenSearchTestCase; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; diff --git a/src/test/java/org/opensearch/sdk/rest/TestBaseExtensionRestHandler.java b/src/test/java/org/opensearch/sdk/rest/TestBaseExtensionRestHandler.java index 7fa02c83..6c47c295 100644 --- a/src/test/java/org/opensearch/sdk/rest/TestBaseExtensionRestHandler.java +++ b/src/test/java/org/opensearch/sdk/rest/TestBaseExtensionRestHandler.java @@ -9,12 +9,6 @@ package org.opensearch.sdk.rest; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.List; -import java.util.function.Function; - -import org.junit.jupiter.api.Test; import org.opensearch.common.bytes.BytesArray; import org.opensearch.extensions.rest.ExtensionRestResponse; import org.opensearch.rest.RestHandler.Route; @@ -22,6 +16,12 @@ import org.opensearch.rest.RestRequest.Method; import org.opensearch.rest.RestStatus; import org.opensearch.test.OpenSearchTestCase; +import org.junit.jupiter.api.Test; + +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.List; +import java.util.function.Function; public class TestBaseExtensionRestHandler extends OpenSearchTestCase { diff --git a/src/test/java/org/opensearch/sdk/rest/TestExtensionRestHandler.java b/src/test/java/org/opensearch/sdk/rest/TestExtensionRestHandler.java index a1ee68d8..b6fad1a5 100644 --- a/src/test/java/org/opensearch/sdk/rest/TestExtensionRestHandler.java +++ b/src/test/java/org/opensearch/sdk/rest/TestExtensionRestHandler.java @@ -9,10 +9,10 @@ package org.opensearch.sdk.rest; -import org.junit.jupiter.api.Test; import org.opensearch.extensions.rest.ExtensionRestResponse; import org.opensearch.rest.RestRequest; import org.opensearch.test.OpenSearchTestCase; +import org.junit.jupiter.api.Test; public class TestExtensionRestHandler extends OpenSearchTestCase { private static class NoOpExtensionRestHandler implements ExtensionRestHandler { diff --git a/src/test/java/org/opensearch/sdk/rest/TestExtensionRestPathRegistry.java b/src/test/java/org/opensearch/sdk/rest/TestExtensionRestPathRegistry.java index 8d794cb7..6def1419 100644 --- a/src/test/java/org/opensearch/sdk/rest/TestExtensionRestPathRegistry.java +++ b/src/test/java/org/opensearch/sdk/rest/TestExtensionRestPathRegistry.java @@ -9,10 +9,6 @@ package org.opensearch.sdk.rest; -import java.util.List; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import org.opensearch.extensions.rest.ExtensionRestResponse; import org.opensearch.rest.RestHandler.DeprecatedRoute; import org.opensearch.rest.RestHandler.ReplacedRoute; @@ -21,6 +17,10 @@ import org.opensearch.rest.RestRequest.Method; import org.opensearch.sdk.rest.BaseExtensionRestHandler.ExtensionDeprecationRestHandler; import org.opensearch.test.OpenSearchTestCase; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.List; public class TestExtensionRestPathRegistry extends OpenSearchTestCase { diff --git a/src/test/java/org/opensearch/sdk/rest/TestSDKRestRequest.java b/src/test/java/org/opensearch/sdk/rest/TestSDKRestRequest.java index 48b0b33e..aa031719 100644 --- a/src/test/java/org/opensearch/sdk/rest/TestSDKRestRequest.java +++ b/src/test/java/org/opensearch/sdk/rest/TestSDKRestRequest.java @@ -9,12 +9,6 @@ package org.opensearch.sdk.rest; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import org.junit.jupiter.api.Test; import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.xcontent.XContentType; @@ -23,6 +17,12 @@ import org.opensearch.rest.RestRequest; import org.opensearch.rest.RestRequest.Method; import org.opensearch.test.OpenSearchTestCase; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Map; import static java.util.Map.entry; diff --git a/src/test/java/org/opensearch/sdk/sample/helloworld/TestHelloWorldExtension.java b/src/test/java/org/opensearch/sdk/sample/helloworld/TestHelloWorldExtension.java index 1d37c840..4c43e2d4 100644 --- a/src/test/java/org/opensearch/sdk/sample/helloworld/TestHelloWorldExtension.java +++ b/src/test/java/org/opensearch/sdk/sample/helloworld/TestHelloWorldExtension.java @@ -9,17 +9,10 @@ package org.opensearch.sdk.sample.helloworld; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; - +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Key; import org.apache.http.HttpHost; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionResponse; @@ -29,23 +22,29 @@ import org.opensearch.client.opensearch.OpenSearchAsyncClient; import org.opensearch.client.transport.rest_client.RestClientTransport; import org.opensearch.common.settings.Settings; +import org.opensearch.sdk.ExtensionSettings; +import org.opensearch.sdk.ExtensionsRunner; +import org.opensearch.sdk.SDKClient; +import org.opensearch.sdk.SDKClient.SDKRestClient; +import org.opensearch.sdk.action.SDKActionModule; import org.opensearch.sdk.api.ActionExtension.ActionHandler; import org.opensearch.sdk.rest.ExtensionRestHandler; import org.opensearch.sdk.sample.helloworld.transport.SampleAction; import org.opensearch.sdk.sample.helloworld.transport.SampleRequest; import org.opensearch.sdk.sample.helloworld.transport.SampleResponse; import org.opensearch.tasks.TaskManager; -import org.opensearch.sdk.ExtensionSettings; -import org.opensearch.sdk.ExtensionsRunner; -import org.opensearch.sdk.SDKClient; -import org.opensearch.sdk.SDKClient.SDKRestClient; -import org.opensearch.sdk.action.SDKActionModule; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.ThreadPool; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import com.google.inject.Guice; -import com.google.inject.Injector; -import com.google.inject.Key; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; import static org.opensearch.sdk.sample.helloworld.ExampleCustomSettingConfig.VALIDATED_SETTING; diff --git a/src/test/java/org/opensearch/sdk/sample/helloworld/rest/TestHelloWorldIT.java b/src/test/java/org/opensearch/sdk/sample/helloworld/rest/TestHelloWorldIT.java index a9235020..224f158e 100644 --- a/src/test/java/org/opensearch/sdk/sample/helloworld/rest/TestHelloWorldIT.java +++ b/src/test/java/org/opensearch/sdk/sample/helloworld/rest/TestHelloWorldIT.java @@ -9,21 +9,21 @@ package org.opensearch.sdk.sample.helloworld.rest; -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.Callable; - import org.apache.http.HttpEntity; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.Test; import org.opensearch.client.Request; import org.opensearch.client.Response; import org.opensearch.client.RestClient; import org.opensearch.rest.RestStatus; import org.opensearch.test.rest.OpenSearchRestTestCase; +import org.junit.Test; + +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.Callable; public class TestHelloWorldIT extends OpenSearchRestTestCase { private static final Logger logger = LogManager.getLogger(TestHelloWorldIT.class); diff --git a/src/test/java/org/opensearch/sdk/sample/helloworld/rest/TestRestHelloAction.java b/src/test/java/org/opensearch/sdk/sample/helloworld/rest/TestRestHelloAction.java index 8c4ee0a2..101bc43d 100644 --- a/src/test/java/org/opensearch/sdk/sample/helloworld/rest/TestRestHelloAction.java +++ b/src/test/java/org/opensearch/sdk/sample/helloworld/rest/TestRestHelloAction.java @@ -9,25 +9,25 @@ package org.opensearch.sdk.sample.helloworld.rest; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.opensearch.rest.RestHandler.Route; -import org.opensearch.rest.RestRequest; -import org.opensearch.rest.RestRequest.Method; import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.xcontent.XContentType; import org.opensearch.http.HttpRequest.HttpVersion; +import org.opensearch.rest.RestHandler.Route; +import org.opensearch.rest.RestRequest; +import org.opensearch.rest.RestRequest.Method; import org.opensearch.rest.RestResponse; import org.opensearch.rest.RestStatus; import org.opensearch.sdk.rest.ExtensionRestHandler; import org.opensearch.sdk.rest.TestSDKRestRequest; import org.opensearch.test.OpenSearchTestCase; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.List; +import java.util.Map; public class TestRestHelloAction extends OpenSearchTestCase { diff --git a/src/test/java/org/opensearch/sdk/sample/helloworld/transport/TestSampleAction.java b/src/test/java/org/opensearch/sdk/sample/helloworld/transport/TestSampleAction.java index 8e2e09e7..ad3f2e86 100644 --- a/src/test/java/org/opensearch/sdk/sample/helloworld/transport/TestSampleAction.java +++ b/src/test/java/org/opensearch/sdk/sample/helloworld/transport/TestSampleAction.java @@ -9,20 +9,20 @@ package org.opensearch.sdk.sample.helloworld.transport; +import org.opensearch.action.ActionListener; +import org.opensearch.action.support.ActionFilters; +import org.opensearch.common.bytes.BytesReference; +import org.opensearch.common.io.stream.BytesStreamInput; +import org.opensearch.common.io.stream.BytesStreamOutput; +import org.opensearch.test.OpenSearchTestCase; +import org.junit.jupiter.api.Test; + import java.io.IOException; import java.util.Collections; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import org.junit.jupiter.api.Test; -import org.opensearch.common.bytes.BytesReference; -import org.opensearch.common.io.stream.BytesStreamInput; -import org.opensearch.common.io.stream.BytesStreamOutput; -import org.opensearch.action.ActionListener; -import org.opensearch.action.support.ActionFilters; -import org.opensearch.test.OpenSearchTestCase; - public class TestSampleAction extends OpenSearchTestCase { @Test