diff --git a/src/main/java/org/opensearch/ad/caching/PriorityCache.java b/src/main/java/org/opensearch/ad/caching/PriorityCache.java index dfae6b931..d3bacc7ec 100644 --- a/src/main/java/org/opensearch/ad/caching/PriorityCache.java +++ b/src/main/java/org/opensearch/ad/caching/PriorityCache.java @@ -58,10 +58,10 @@ import org.opensearch.ad.settings.EnabledSetting; import org.opensearch.ad.util.DateUtils; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.Strings; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.common.Strings; import org.opensearch.threadpool.ThreadPool; import com.google.common.cache.Cache; diff --git a/src/main/java/org/opensearch/ad/common/exception/NotSerializedADExceptionName.java b/src/main/java/org/opensearch/ad/common/exception/NotSerializedADExceptionName.java index 0631d29d3..31668cb5e 100644 --- a/src/main/java/org/opensearch/ad/common/exception/NotSerializedADExceptionName.java +++ b/src/main/java/org/opensearch/ad/common/exception/NotSerializedADExceptionName.java @@ -16,7 +16,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.OpenSearchException; +import org.opensearch.BaseExceptionsHelper; import org.opensearch.common.io.stream.NotSerializableExceptionWrapper; /** @@ -29,16 +29,16 @@ */ public enum NotSerializedADExceptionName { - RESOURCE_NOT_FOUND_EXCEPTION_NAME_UNDERSCORE(OpenSearchException.getExceptionName(new ResourceNotFoundException("", ""))), - LIMIT_EXCEEDED_EXCEPTION_NAME_UNDERSCORE(OpenSearchException.getExceptionName(new LimitExceededException("", "", false))), - END_RUN_EXCEPTION_NAME_UNDERSCORE(OpenSearchException.getExceptionName(new EndRunException("", "", false))), - ANOMALY_DETECTION_EXCEPTION_NAME_UNDERSCORE(OpenSearchException.getExceptionName(new AnomalyDetectionException("", ""))), - INTERNAL_FAILURE_NAME_UNDERSCORE(OpenSearchException.getExceptionName(new InternalFailure("", ""))), - CLIENT_EXCEPTION_NAME_UNDERSCORE(OpenSearchException.getExceptionName(new ClientException("", ""))), - CANCELLATION_EXCEPTION_NAME_UNDERSCORE(OpenSearchException.getExceptionName(new ADTaskCancelledException("", ""))), - DUPLICATE_TASK_EXCEPTION_NAME_UNDERSCORE(OpenSearchException.getExceptionName(new DuplicateTaskException(""))), - AD_VERSION_EXCEPTION_NAME_UNDERSCORE(OpenSearchException.getExceptionName(new ADVersionException(""))), - AD_VALIDATION_EXCEPTION_NAME_UNDERSCORE(OpenSearchException.getExceptionName(new ADValidationException("", null, null))); + RESOURCE_NOT_FOUND_EXCEPTION_NAME_UNDERSCORE(BaseExceptionsHelper.getExceptionName(new ResourceNotFoundException("", ""))), + LIMIT_EXCEEDED_EXCEPTION_NAME_UNDERSCORE(BaseExceptionsHelper.getExceptionName(new LimitExceededException("", "", false))), + END_RUN_EXCEPTION_NAME_UNDERSCORE(BaseExceptionsHelper.getExceptionName(new EndRunException("", "", false))), + ANOMALY_DETECTION_EXCEPTION_NAME_UNDERSCORE(BaseExceptionsHelper.getExceptionName(new AnomalyDetectionException("", ""))), + INTERNAL_FAILURE_NAME_UNDERSCORE(BaseExceptionsHelper.getExceptionName(new InternalFailure("", ""))), + CLIENT_EXCEPTION_NAME_UNDERSCORE(BaseExceptionsHelper.getExceptionName(new ClientException("", ""))), + CANCELLATION_EXCEPTION_NAME_UNDERSCORE(BaseExceptionsHelper.getExceptionName(new ADTaskCancelledException("", ""))), + DUPLICATE_TASK_EXCEPTION_NAME_UNDERSCORE(BaseExceptionsHelper.getExceptionName(new DuplicateTaskException(""))), + AD_VERSION_EXCEPTION_NAME_UNDERSCORE(BaseExceptionsHelper.getExceptionName(new ADVersionException(""))), + AD_VALIDATION_EXCEPTION_NAME_UNDERSCORE(BaseExceptionsHelper.getExceptionName(new ADValidationException("", null, null))); private static final Logger LOG = LogManager.getLogger(NotSerializedADExceptionName.class); private final String name; diff --git a/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java b/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java index acd14a092..8c035678d 100644 --- a/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java +++ b/src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java @@ -30,7 +30,6 @@ import java.util.Arrays; import java.util.EnumMap; import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -74,7 +73,6 @@ import org.opensearch.cluster.metadata.AliasMetadata; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.Strings; import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; @@ -82,6 +80,7 @@ import org.opensearch.common.xcontent.XContentHelper; import org.opensearch.common.xcontent.XContentType; import org.opensearch.commons.InjectSecurity; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -91,8 +90,6 @@ import org.opensearch.threadpool.Scheduler; import org.opensearch.threadpool.ThreadPool; -import com.carrotsearch.hppc.cursors.ObjectCursor; -import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.google.common.base.Charsets; import com.google.common.io.Resources; @@ -759,8 +756,7 @@ void deleteOldHistoryIndices() { adminClient.cluster().state(clusterStateRequest, ActionListener.wrap(clusterStateResponse -> { String latestToDelete = null; long latest = Long.MIN_VALUE; - for (ObjectCursor cursor : clusterStateResponse.getState().metadata().indices().values()) { - IndexMetadata indexMetaData = cursor.value; + for (IndexMetadata indexMetaData : clusterStateResponse.getState().metadata().indices().values()) { long creationTime = indexMetaData.getCreationDate(); if ((Instant.now().toEpochMilli() - creationTime) > historyRetentionPeriod.millis()) { @@ -986,10 +982,10 @@ private void shouldUpdateIndex(ADIndex index, ActionListener thenDo) { .indicesOptions(IndicesOptions.lenientExpandOpenHidden()); adminClient.indices().getAliases(getAliasRequest, ActionListener.wrap(getAliasResponse -> { String concreteIndex = null; - for (ObjectObjectCursor> entry : getAliasResponse.getAliases()) { - if (false == entry.value.isEmpty()) { + for (Map.Entry> entry : getAliasResponse.getAliases().entrySet()) { + if (false == entry.getValue().isEmpty()) { // we assume the alias map to one concrete index, thus we can return after finding one - concreteIndex = entry.key; + concreteIndex = entry.getKey(); break; } } @@ -1137,9 +1133,7 @@ private void updateJobIndexSettingIfNecessary(IndexState jobIndexState, ActionLi private static Integer getIntegerSetting(GetSettingsResponse settingsResponse, String settingKey) { Integer value = null; - Iterator iter = settingsResponse.getIndexToSettings().valuesIt(); - while (iter.hasNext()) { - Settings settings = iter.next(); + for (Settings settings : settingsResponse.getIndexToSettings().values()) { value = settings.getAsInt(settingKey, null); if (value != null) { break; @@ -1150,9 +1144,7 @@ private static Integer getIntegerSetting(GetSettingsResponse settingsResponse, S private static String getStringSetting(GetSettingsResponse settingsResponse, String settingKey) { String value = null; - Iterator iter = settingsResponse.getIndexToSettings().valuesIt(); - while (iter.hasNext()) { - Settings settings = iter.next(); + for (Settings settings : settingsResponse.getIndexToSettings().values()) { value = settings.get(settingKey, null); if (value != null) { break; diff --git a/src/main/java/org/opensearch/ad/model/AnomalyDetectorExecutionInput.java b/src/main/java/org/opensearch/ad/model/AnomalyDetectorExecutionInput.java index 6e636d00c..d7a8a9437 100644 --- a/src/main/java/org/opensearch/ad/model/AnomalyDetectorExecutionInput.java +++ b/src/main/java/org/opensearch/ad/model/AnomalyDetectorExecutionInput.java @@ -18,7 +18,7 @@ import org.opensearch.ad.annotation.Generated; import org.opensearch.ad.util.ParseUtils; -import org.opensearch.common.Strings; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; diff --git a/src/main/java/org/opensearch/ad/ratelimit/CheckPointMaintainRequestAdapter.java b/src/main/java/org/opensearch/ad/ratelimit/CheckPointMaintainRequestAdapter.java index 8723e3d35..072855069 100644 --- a/src/main/java/org/opensearch/ad/ratelimit/CheckPointMaintainRequestAdapter.java +++ b/src/main/java/org/opensearch/ad/ratelimit/CheckPointMaintainRequestAdapter.java @@ -27,10 +27,10 @@ import org.opensearch.ad.ml.ModelState; import org.opensearch.ad.util.DateUtils; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.Strings; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; +import org.opensearch.core.common.Strings; public class CheckPointMaintainRequestAdapter { private static final Logger LOG = LogManager.getLogger(CheckPointMaintainRequestAdapter.class); diff --git a/src/main/java/org/opensearch/ad/ratelimit/CheckpointWriteWorker.java b/src/main/java/org/opensearch/ad/ratelimit/CheckpointWriteWorker.java index 56caddd54..fc7fc0a07 100644 --- a/src/main/java/org/opensearch/ad/ratelimit/CheckpointWriteWorker.java +++ b/src/main/java/org/opensearch/ad/ratelimit/CheckpointWriteWorker.java @@ -39,9 +39,9 @@ import org.opensearch.ad.model.AnomalyDetector; import org.opensearch.ad.util.ExceptionUtil; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.Strings; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Settings; +import org.opensearch.core.common.Strings; import org.opensearch.threadpool.ThreadPool; public class CheckpointWriteWorker extends BatchWorker { diff --git a/src/main/java/org/opensearch/ad/rest/RestGetAnomalyDetectorAction.java b/src/main/java/org/opensearch/ad/rest/RestGetAnomalyDetectorAction.java index 216cfaf94..eefc52bda 100644 --- a/src/main/java/org/opensearch/ad/rest/RestGetAnomalyDetectorAction.java +++ b/src/main/java/org/opensearch/ad/rest/RestGetAnomalyDetectorAction.java @@ -30,7 +30,7 @@ import org.opensearch.ad.transport.GetAnomalyDetectorAction; import org.opensearch.ad.transport.GetAnomalyDetectorRequest; import org.opensearch.client.node.NodeClient; -import org.opensearch.common.Strings; +import org.opensearch.core.common.Strings; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.RestRequest; import org.opensearch.rest.action.RestActions; diff --git a/src/main/java/org/opensearch/ad/rest/RestPreviewAnomalyDetectorAction.java b/src/main/java/org/opensearch/ad/rest/RestPreviewAnomalyDetectorAction.java index 0228d4912..e144b05ee 100644 --- a/src/main/java/org/opensearch/ad/rest/RestPreviewAnomalyDetectorAction.java +++ b/src/main/java/org/opensearch/ad/rest/RestPreviewAnomalyDetectorAction.java @@ -28,7 +28,7 @@ import org.opensearch.ad.transport.PreviewAnomalyDetectorAction; import org.opensearch.ad.transport.PreviewAnomalyDetectorRequest; import org.opensearch.ad.util.RestHandlerUtils; -import org.opensearch.common.Strings; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.BytesRestResponse; diff --git a/src/main/java/org/opensearch/ad/rest/RestStatsAnomalyDetectorAction.java b/src/main/java/org/opensearch/ad/rest/RestStatsAnomalyDetectorAction.java index 16860cd97..5ad871fc6 100644 --- a/src/main/java/org/opensearch/ad/rest/RestStatsAnomalyDetectorAction.java +++ b/src/main/java/org/opensearch/ad/rest/RestStatsAnomalyDetectorAction.java @@ -29,7 +29,7 @@ import org.opensearch.client.node.NodeClient; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.Strings; +import org.opensearch.core.common.Strings; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.RestRequest; import org.opensearch.rest.action.RestToXContentListener; diff --git a/src/main/java/org/opensearch/ad/transport/ADBatchAnomalyResultRequest.java b/src/main/java/org/opensearch/ad/transport/ADBatchAnomalyResultRequest.java index 53cdb4a76..7d2d86f90 100644 --- a/src/main/java/org/opensearch/ad/transport/ADBatchAnomalyResultRequest.java +++ b/src/main/java/org/opensearch/ad/transport/ADBatchAnomalyResultRequest.java @@ -19,9 +19,9 @@ import org.opensearch.action.ActionRequestValidationException; import org.opensearch.ad.model.ADTask; import org.opensearch.ad.model.AnomalyDetector; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; public class ADBatchAnomalyResultRequest extends ActionRequest { private ADTask adTask; diff --git a/src/main/java/org/opensearch/ad/transport/ADCancelTaskRequest.java b/src/main/java/org/opensearch/ad/transport/ADCancelTaskRequest.java index 7b65f8fd7..23be17d5d 100644 --- a/src/main/java/org/opensearch/ad/transport/ADCancelTaskRequest.java +++ b/src/main/java/org/opensearch/ad/transport/ADCancelTaskRequest.java @@ -19,9 +19,9 @@ import org.opensearch.action.support.nodes.BaseNodesRequest; import org.opensearch.ad.constant.CommonErrorMessages; import org.opensearch.cluster.node.DiscoveryNode; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; public class ADCancelTaskRequest extends BaseNodesRequest { diff --git a/src/main/java/org/opensearch/ad/transport/ADTaskProfileRequest.java b/src/main/java/org/opensearch/ad/transport/ADTaskProfileRequest.java index af8266b31..8787d540b 100644 --- a/src/main/java/org/opensearch/ad/transport/ADTaskProfileRequest.java +++ b/src/main/java/org/opensearch/ad/transport/ADTaskProfileRequest.java @@ -19,9 +19,9 @@ import org.opensearch.action.support.nodes.BaseNodesRequest; import org.opensearch.ad.constant.CommonErrorMessages; import org.opensearch.cluster.node.DiscoveryNode; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; public class ADTaskProfileRequest extends BaseNodesRequest { diff --git a/src/main/java/org/opensearch/ad/transport/AnomalyResultRequest.java b/src/main/java/org/opensearch/ad/transport/AnomalyResultRequest.java index cb7d4f662..995fdba46 100644 --- a/src/main/java/org/opensearch/ad/transport/AnomalyResultRequest.java +++ b/src/main/java/org/opensearch/ad/transport/AnomalyResultRequest.java @@ -22,11 +22,11 @@ import org.opensearch.action.ActionRequestValidationException; import org.opensearch.ad.constant.CommonErrorMessages; import org.opensearch.ad.constant.CommonName; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.InputStreamStreamInput; import org.opensearch.common.io.stream.OutputStreamStreamOutput; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/src/main/java/org/opensearch/ad/transport/DeleteAnomalyDetectorRequest.java b/src/main/java/org/opensearch/ad/transport/DeleteAnomalyDetectorRequest.java index aba3a935b..ac69af780 100644 --- a/src/main/java/org/opensearch/ad/transport/DeleteAnomalyDetectorRequest.java +++ b/src/main/java/org/opensearch/ad/transport/DeleteAnomalyDetectorRequest.java @@ -18,9 +18,9 @@ import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.ad.constant.CommonErrorMessages; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; public class DeleteAnomalyDetectorRequest extends ActionRequest { diff --git a/src/main/java/org/opensearch/ad/transport/DeleteModelRequest.java b/src/main/java/org/opensearch/ad/transport/DeleteModelRequest.java index a083af76f..b84adddbf 100644 --- a/src/main/java/org/opensearch/ad/transport/DeleteModelRequest.java +++ b/src/main/java/org/opensearch/ad/transport/DeleteModelRequest.java @@ -20,9 +20,9 @@ import org.opensearch.ad.constant.CommonErrorMessages; import org.opensearch.ad.constant.CommonName; import org.opensearch.cluster.node.DiscoveryNode; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/src/main/java/org/opensearch/ad/transport/EntityProfileRequest.java b/src/main/java/org/opensearch/ad/transport/EntityProfileRequest.java index 2de7e11aa..c79d9e627 100644 --- a/src/main/java/org/opensearch/ad/transport/EntityProfileRequest.java +++ b/src/main/java/org/opensearch/ad/transport/EntityProfileRequest.java @@ -24,9 +24,9 @@ import org.opensearch.ad.model.Entity; import org.opensearch.ad.model.EntityProfileName; import org.opensearch.ad.util.Bwc; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/src/main/java/org/opensearch/ad/transport/EntityResultRequest.java b/src/main/java/org/opensearch/ad/transport/EntityResultRequest.java index b8a71fc98..d4e5c0d69 100644 --- a/src/main/java/org/opensearch/ad/transport/EntityResultRequest.java +++ b/src/main/java/org/opensearch/ad/transport/EntityResultRequest.java @@ -26,9 +26,9 @@ import org.opensearch.ad.constant.CommonName; import org.opensearch.ad.model.Entity; import org.opensearch.ad.util.Bwc; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/src/main/java/org/opensearch/ad/transport/GetAnomalyDetectorTransportAction.java b/src/main/java/org/opensearch/ad/transport/GetAnomalyDetectorTransportAction.java index c43fd0864..0d1d73e29 100644 --- a/src/main/java/org/opensearch/ad/transport/GetAnomalyDetectorTransportAction.java +++ b/src/main/java/org/opensearch/ad/transport/GetAnomalyDetectorTransportAction.java @@ -62,11 +62,11 @@ import org.opensearch.client.Client; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.CheckedConsumer; -import org.opensearch.common.Strings; import org.opensearch.common.inject.Inject; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.commons.authuser.User; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.rest.RestStatus; diff --git a/src/main/java/org/opensearch/ad/transport/RCFPollingRequest.java b/src/main/java/org/opensearch/ad/transport/RCFPollingRequest.java index 20cb5b392..6046184b7 100644 --- a/src/main/java/org/opensearch/ad/transport/RCFPollingRequest.java +++ b/src/main/java/org/opensearch/ad/transport/RCFPollingRequest.java @@ -19,9 +19,9 @@ import org.opensearch.action.ActionRequestValidationException; import org.opensearch.ad.constant.CommonErrorMessages; import org.opensearch.ad.constant.CommonName; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/src/main/java/org/opensearch/ad/transport/RCFResultRequest.java b/src/main/java/org/opensearch/ad/transport/RCFResultRequest.java index f59706f52..452354f8e 100644 --- a/src/main/java/org/opensearch/ad/transport/RCFResultRequest.java +++ b/src/main/java/org/opensearch/ad/transport/RCFResultRequest.java @@ -19,9 +19,9 @@ import org.opensearch.action.ActionRequestValidationException; import org.opensearch.ad.constant.CommonErrorMessages; import org.opensearch.ad.constant.CommonName; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/src/main/java/org/opensearch/ad/transport/SearchTopAnomalyResultTransportAction.java b/src/main/java/org/opensearch/ad/transport/SearchTopAnomalyResultTransportAction.java index 75b1f2d22..9e80569a7 100644 --- a/src/main/java/org/opensearch/ad/transport/SearchTopAnomalyResultTransportAction.java +++ b/src/main/java/org/opensearch/ad/transport/SearchTopAnomalyResultTransportAction.java @@ -39,8 +39,8 @@ import org.opensearch.ad.model.AnomalyResultBucket; import org.opensearch.ad.transport.handler.ADSearchHandler; import org.opensearch.client.Client; -import org.opensearch.common.Strings; import org.opensearch.common.inject.Inject; +import org.opensearch.core.common.Strings; import org.opensearch.index.query.BoolQueryBuilder; import org.opensearch.index.query.ExistsQueryBuilder; import org.opensearch.index.query.QueryBuilder; diff --git a/src/main/java/org/opensearch/ad/transport/StopDetectorRequest.java b/src/main/java/org/opensearch/ad/transport/StopDetectorRequest.java index 1932970a7..a40e77759 100644 --- a/src/main/java/org/opensearch/ad/transport/StopDetectorRequest.java +++ b/src/main/java/org/opensearch/ad/transport/StopDetectorRequest.java @@ -21,11 +21,11 @@ import org.opensearch.action.ActionRequestValidationException; import org.opensearch.ad.constant.CommonErrorMessages; import org.opensearch.ad.constant.CommonName; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.InputStreamStreamInput; import org.opensearch.common.io.stream.OutputStreamStreamOutput; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/src/main/java/org/opensearch/ad/transport/ThresholdResultRequest.java b/src/main/java/org/opensearch/ad/transport/ThresholdResultRequest.java index 6b841060f..f0c5d0fe4 100644 --- a/src/main/java/org/opensearch/ad/transport/ThresholdResultRequest.java +++ b/src/main/java/org/opensearch/ad/transport/ThresholdResultRequest.java @@ -19,9 +19,9 @@ import org.opensearch.action.ActionRequestValidationException; import org.opensearch.ad.constant.CommonErrorMessages; import org.opensearch.ad.constant.CommonName; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/src/main/java/org/opensearch/ad/util/ADSafeSecurityInjector.java b/src/main/java/org/opensearch/ad/util/ADSafeSecurityInjector.java index 8fcd11ce0..b38455d36 100644 --- a/src/main/java/org/opensearch/ad/util/ADSafeSecurityInjector.java +++ b/src/main/java/org/opensearch/ad/util/ADSafeSecurityInjector.java @@ -19,10 +19,10 @@ import org.opensearch.ad.NodeStateManager; import org.opensearch.ad.common.exception.EndRunException; import org.opensearch.ad.model.AnomalyDetector; -import org.opensearch.common.Strings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.commons.authuser.User; +import org.opensearch.core.common.Strings; public class ADSafeSecurityInjector extends SafeSecurityInjector { private static final Logger LOG = LogManager.getLogger(ADSafeSecurityInjector.class); diff --git a/src/main/java/org/opensearch/ad/util/RestHandlerUtils.java b/src/main/java/org/opensearch/ad/util/RestHandlerUtils.java index 76edee7d7..9793b9383 100644 --- a/src/main/java/org/opensearch/ad/util/RestHandlerUtils.java +++ b/src/main/java/org/opensearch/ad/util/RestHandlerUtils.java @@ -31,6 +31,7 @@ import org.opensearch.ad.constant.CommonErrorMessages; import org.opensearch.ad.model.AnomalyDetector; import org.opensearch.ad.model.Feature; +import org.opensearch.common.Nullable; import org.opensearch.common.Strings; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.xcontent.LoggingDeprecationHandler; @@ -96,7 +97,7 @@ private RestHandlerUtils() {} * @return instance of {@link org.opensearch.search.fetch.subphase.FetchSourceContext} */ public static FetchSourceContext getSourceContext(RestRequest request, SearchSourceBuilder searchSourceBuilder) { - String userAgent = Strings.coalesceToEmpty(request.header("User-Agent")); + String userAgent = coalesceToEmpty(request.header("User-Agent")); // If there is a _source given in request than we either add UI_Metadata to exclude or not depending on if request // is from OpenSearch-Dashboards, if no _source field then we either exclude UI_metadata or return nothing at all. @@ -238,4 +239,8 @@ public static boolean isProperExceptionToReturn(Throwable e) { } return e instanceof OpenSearchStatusException || e instanceof IndexNotFoundException || e instanceof InvalidIndexNameException; } + + private static String coalesceToEmpty(@Nullable String s) { + return s == null ? "" : s; + } } diff --git a/src/test/java/org/opensearch/EntityProfileRequest1_0.java b/src/test/java/org/opensearch/EntityProfileRequest1_0.java index 2c339551f..2fa1c04af 100644 --- a/src/test/java/org/opensearch/EntityProfileRequest1_0.java +++ b/src/test/java/org/opensearch/EntityProfileRequest1_0.java @@ -22,9 +22,9 @@ import org.opensearch.ad.constant.CommonErrorMessages; import org.opensearch.ad.constant.CommonName; import org.opensearch.ad.model.EntityProfileName; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/src/test/java/org/opensearch/EntityResultRequest1_0.java b/src/test/java/org/opensearch/EntityResultRequest1_0.java index 8ab7a7a51..7728d4262 100644 --- a/src/test/java/org/opensearch/EntityResultRequest1_0.java +++ b/src/test/java/org/opensearch/EntityResultRequest1_0.java @@ -21,9 +21,9 @@ import org.opensearch.action.ActionRequestValidationException; import org.opensearch.ad.constant.CommonErrorMessages; import org.opensearch.ad.constant.CommonName; -import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/src/test/java/org/opensearch/ad/ADIntegTestCase.java b/src/test/java/org/opensearch/ad/ADIntegTestCase.java index 68184578c..3a489cd37 100644 --- a/src/test/java/org/opensearch/ad/ADIntegTestCase.java +++ b/src/test/java/org/opensearch/ad/ADIntegTestCase.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -53,7 +52,6 @@ import org.opensearch.client.node.NodeClient; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodes; -import org.opensearch.common.collect.ImmutableOpenMap; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.query.MatchAllQueryBuilder; @@ -65,7 +63,6 @@ import org.opensearch.test.OpenSearchIntegTestCase; import org.opensearch.test.transport.MockTransportService; -import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.google.common.collect.ImmutableMap; public abstract class ADIntegTestCase extends OpenSearchIntegTestCase { @@ -252,7 +249,7 @@ public ClusterUpdateSettingsResponse updateTransientSettings(Map sett return clusterAdmin().updateSettings(updateSettingsRequest).actionGet(timeout); } - public ImmutableOpenMap getDataNodes() { + public Map getDataNodes() { DiscoveryNodes nodes = clusterService().state().getNodes(); return nodes.getDataNodes(); } @@ -268,10 +265,10 @@ public Client getDataNodeClient() { public DiscoveryNode[] getDataNodesArray() { DiscoveryNodes nodes = clusterService().state().getNodes(); - Iterator> iterator = nodes.getDataNodes().iterator(); + Collection nodeCollection = nodes.getDataNodes().values(); List dataNodes = new ArrayList<>(); - while (iterator.hasNext()) { - dataNodes.add(iterator.next().value); + for (DiscoveryNode node : nodeCollection) { + dataNodes.add(node); } return dataNodes.toArray(new DiscoveryNode[0]); } diff --git a/src/test/java/org/opensearch/ad/TestHelpers.java b/src/test/java/org/opensearch/ad/TestHelpers.java index f358ce32f..ea4c17eab 100644 --- a/src/test/java/org/opensearch/ad/TestHelpers.java +++ b/src/test/java/org/opensearch/ad/TestHelpers.java @@ -109,7 +109,6 @@ import org.opensearch.common.UUIDs; import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.bytes.BytesReference; -import org.opensearch.common.collect.ImmutableOpenMap; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; @@ -1510,9 +1509,9 @@ public static DetectorValidationIssue randomDetectorValidationIssueWithDetectorI } public static ClusterState createClusterState() { - ImmutableOpenMap immutableOpenMap = ImmutableOpenMap - .builder() - .fPut( + final Map mappings = new HashMap<>(); + mappings + .put( ANOMALY_DETECTOR_JOB_INDEX, IndexMetadata .builder("test") @@ -1524,10 +1523,20 @@ public static ClusterState createClusterState() { .put("index.version.created", Version.CURRENT.id) ) .build() - ) - .build(); - Metadata metaData = Metadata.builder().indices(immutableOpenMap).build(); - ClusterState clusterState = new ClusterState(new ClusterName("test_name"), 1l, "uuid", metaData, null, null, null, null, 1, true); + ); + Metadata metaData = Metadata.builder().indices(mappings).build(); + ClusterState clusterState = new ClusterState( + new ClusterName("test_name"), + 1l, + "uuid", + metaData, + null, + null, + null, + new HashMap<>(), + 1, + true + ); return clusterState; } } diff --git a/src/test/java/org/opensearch/ad/e2e/AbstractSyntheticDataTest.java b/src/test/java/org/opensearch/ad/e2e/AbstractSyntheticDataTest.java index 20544a221..1230a5d6c 100644 --- a/src/test/java/org/opensearch/ad/e2e/AbstractSyntheticDataTest.java +++ b/src/test/java/org/opensearch/ad/e2e/AbstractSyntheticDataTest.java @@ -35,8 +35,8 @@ import org.opensearch.client.Response; import org.opensearch.client.RestClient; import org.opensearch.client.WarningsHandler; -import org.opensearch.common.Strings; import org.opensearch.common.xcontent.json.JsonXContent; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.XContentBuilder; import com.google.common.collect.ImmutableList; @@ -67,7 +67,7 @@ protected void disableResourceNotFoundFaultTolerence() throws IOException { settingCommand.endObject(); settingCommand.endObject(); Request request = new Request("PUT", "/_cluster/settings"); - request.setJsonEntity(Strings.toString(settingCommand)); + request.setJsonEntity(org.opensearch.common.Strings.toString(settingCommand)); adminClient().performRequest(request); } @@ -193,6 +193,7 @@ protected String createDetector( return detectorId; } + @Override protected void waitAllSyncheticDataIngested(int expectedSize, String datasetName, RestClient client) throws Exception { int maxWaitCycles = 3; do { diff --git a/src/test/java/org/opensearch/ad/indices/UpdateMappingTests.java b/src/test/java/org/opensearch/ad/indices/UpdateMappingTests.java index 224d4b980..a55ea9a9b 100644 --- a/src/test/java/org/opensearch/ad/indices/UpdateMappingTests.java +++ b/src/test/java/org/opensearch/ad/indices/UpdateMappingTests.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import org.junit.BeforeClass; import org.mockito.ArgumentCaptor; @@ -53,7 +54,6 @@ import org.opensearch.cluster.metadata.Metadata; import org.opensearch.cluster.routing.RoutingTable; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.collect.ImmutableOpenMap; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.index.IndexNotFoundException; @@ -109,8 +109,8 @@ public void setUp() throws Exception { when(clusterService.getClusterSettings()).thenReturn(clusterSettings); when(clusterService.state()).thenReturn(clusterState); - ImmutableOpenMap.Builder openMapBuilder = ImmutableOpenMap.builder(); - Metadata metadata = Metadata.builder().indices(openMapBuilder.build()).build(); + Map openMap = new HashMap<>(); + Metadata metadata = Metadata.builder().indices(openMap).build(); when(clusterState.getMetadata()).thenReturn(metadata); when(clusterState.metadata()).thenReturn(metadata); @@ -148,12 +148,12 @@ public void testUpdateMapping() throws IOException { doAnswer(invocation -> { ActionListener listener = (ActionListener) invocation.getArgument(1); - ImmutableOpenMap.Builder> builder = ImmutableOpenMap.builder(); + Map> builder = new HashMap<>(); List aliasMetadata = new ArrayList<>(); aliasMetadata.add(AliasMetadata.builder(ADIndex.RESULT.name()).build()); builder.put(resultIndexName, aliasMetadata); - listener.onResponse(new GetAliasesResponse(builder.build())); + listener.onResponse(new GetAliasesResponse(builder)); return null; }).when(indicesAdminClient).getAliases(any(GetAliasesRequest.class), any()); @@ -174,9 +174,9 @@ public void testUpdateMapping() throws IOException { } })) .build(); - ImmutableOpenMap.Builder openMapBuilder = ImmutableOpenMap.builder(); + Map openMapBuilder = new HashMap<>(); openMapBuilder.put(resultIndexName, indexMetadata); - Metadata metadata = Metadata.builder().indices(openMapBuilder.build()).build(); + Metadata metadata = Metadata.builder().indices(openMapBuilder).build(); when(clusterState.getMetadata()).thenReturn(metadata); when(clusterState.metadata()).thenReturn(metadata); adIndices.update(); @@ -186,7 +186,7 @@ public void testUpdateMapping() throws IOException { // since SETTING_AUTO_EXPAND_REPLICAS is set, we won't update @SuppressWarnings("unchecked") public void testJobSettingNoUpdate() { - ImmutableOpenMap.Builder indexToSettings = ImmutableOpenMap.builder(); + Map indexToSettings = new HashMap<>(); Settings jobSettings = Settings .builder() .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) @@ -194,7 +194,7 @@ public void testJobSettingNoUpdate() { .put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "1-all") .build(); indexToSettings.put(ADIndex.JOB.getIndexName(), jobSettings); - GetSettingsResponse getSettingsResponse = new GetSettingsResponse(indexToSettings.build(), ImmutableOpenMap.of()); + GetSettingsResponse getSettingsResponse = new GetSettingsResponse(indexToSettings, new HashMap<>()); doAnswer(invocation -> { ActionListener listener = (ActionListener) invocation.getArgument(2); @@ -207,7 +207,7 @@ public void testJobSettingNoUpdate() { @SuppressWarnings("unchecked") private void setUpSuccessfulGetJobSetting() { - ImmutableOpenMap.Builder indexToSettings = ImmutableOpenMap.builder(); + Map indexToSettings = new HashMap<>(); Settings jobSettings = Settings .builder() .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) @@ -215,7 +215,7 @@ private void setUpSuccessfulGetJobSetting() { .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .build(); indexToSettings.put(ADIndex.JOB.getIndexName(), jobSettings); - GetSettingsResponse getSettingsResponse = new GetSettingsResponse(indexToSettings.build(), ImmutableOpenMap.of()); + GetSettingsResponse getSettingsResponse = new GetSettingsResponse(indexToSettings, new HashMap<>()); doAnswer(invocation -> { ActionListener listener = (ActionListener) invocation.getArgument(2); @@ -249,10 +249,10 @@ public void testJobSettingUpdate() { // since SETTING_NUMBER_OF_SHARDS is not there, we skip updating @SuppressWarnings("unchecked") public void testMissingPrimaryJobShards() { - ImmutableOpenMap.Builder indexToSettings = ImmutableOpenMap.builder(); + Map indexToSettings = new HashMap<>(); Settings jobSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); indexToSettings.put(ADIndex.JOB.getIndexName(), jobSettings); - GetSettingsResponse getSettingsResponse = new GetSettingsResponse(indexToSettings.build(), ImmutableOpenMap.of()); + GetSettingsResponse getSettingsResponse = new GetSettingsResponse(indexToSettings, new HashMap<>()); doAnswer(invocation -> { ActionListener listener = (ActionListener) invocation.getArgument(2); diff --git a/src/test/java/org/opensearch/ad/transport/DeleteAnomalyDetectorTests.java b/src/test/java/org/opensearch/ad/transport/DeleteAnomalyDetectorTests.java index e7085ee31..d4d66ab66 100644 --- a/src/test/java/org/opensearch/ad/transport/DeleteAnomalyDetectorTests.java +++ b/src/test/java/org/opensearch/ad/transport/DeleteAnomalyDetectorTests.java @@ -20,7 +20,9 @@ import java.time.temporal.ChronoUnit; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Optional; import java.util.function.Consumer; @@ -50,7 +52,6 @@ import org.opensearch.cluster.metadata.Metadata; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.bytes.BytesReference; -import org.opensearch.common.collect.ImmutableOpenMap; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.core.xcontent.ToXContent; @@ -196,9 +197,9 @@ public void testDeleteADTransportAction_GetResponseException() { } private ClusterState createClusterState() { - ImmutableOpenMap immutableOpenMap = ImmutableOpenMap - .builder() - .fPut( + Map immutableOpenMap = new HashMap<>(); + immutableOpenMap + .put( ANOMALY_DETECTOR_JOB_INDEX, IndexMetadata .builder("test") @@ -210,10 +211,20 @@ private ClusterState createClusterState() { .put("index.version.created", Version.CURRENT.id) ) .build() - ) - .build(); + ); Metadata metaData = Metadata.builder().indices(immutableOpenMap).build(); - ClusterState clusterState = new ClusterState(new ClusterName("test_name"), 1l, "uuid", metaData, null, null, null, null, 1, true); + ClusterState clusterState = new ClusterState( + new ClusterName("test_name"), + 1l, + "uuid", + metaData, + null, + null, + null, + new HashMap<>(), + 1, + true + ); return clusterState; } diff --git a/src/test/java/org/opensearch/ad/transport/DeleteTests.java b/src/test/java/org/opensearch/ad/transport/DeleteTests.java index 01ebe30e9..cfed84500 100644 --- a/src/test/java/org/opensearch/ad/transport/DeleteTests.java +++ b/src/test/java/org/opensearch/ad/transport/DeleteTests.java @@ -40,7 +40,6 @@ import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.ActionFilters; import org.opensearch.action.support.PlainActionFuture; -import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.ad.AbstractADTest; import org.opensearch.ad.common.exception.JsonPathNotFoundException; import org.opensearch.ad.constant.CommonErrorMessages; @@ -200,14 +199,6 @@ public void testJsonRequestDeleteModel() throws IOException, JsonPathNotFoundExc testJsonRequestTemplate(request, request::getAdID); } - public void testNewResponse() throws IOException { - StreamInput input = mock(StreamInput.class); - when(input.readByte()).thenReturn((byte) 0x01); - AcknowledgedResponse response = new AcknowledgedResponse(input); - - assertTrue(response.isAcknowledged()); - } - private enum DetectorExecutionMode { DELETE_MODEL_NORMAL, DELETE_MODEL_FAILURE diff --git a/src/test/java/org/opensearch/ad/transport/IndexAnomalyDetectorTransportActionTests.java b/src/test/java/org/opensearch/ad/transport/IndexAnomalyDetectorTransportActionTests.java index b76ba44bb..609546ac7 100644 --- a/src/test/java/org/opensearch/ad/transport/IndexAnomalyDetectorTransportActionTests.java +++ b/src/test/java/org/opensearch/ad/transport/IndexAnomalyDetectorTransportActionTests.java @@ -19,8 +19,10 @@ import java.time.Instant; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Locale; +import java.util.Map; import org.junit.Assert; import org.junit.Before; @@ -49,7 +51,6 @@ import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.metadata.Metadata; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.collect.ImmutableOpenMap; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; @@ -98,10 +99,8 @@ public void setUp() throws Exception { .build(); final Settings.Builder existingSettings = Settings.builder().put(indexSettings).put(IndexMetadata.SETTING_INDEX_UUID, "test2UUID"); IndexMetadata indexMetaData = IndexMetadata.builder(AnomalyDetector.ANOMALY_DETECTORS_INDEX).settings(existingSettings).build(); - final ImmutableOpenMap indices = ImmutableOpenMap - .builder() - .fPut(AnomalyDetector.ANOMALY_DETECTORS_INDEX, indexMetaData) - .build(); + final Map indices = new HashMap<>(); + indices.put(AnomalyDetector.ANOMALY_DETECTORS_INDEX, indexMetaData); ClusterState clusterState = ClusterState.builder(clusterName).metadata(Metadata.builder().indices(indices).build()).build(); when(clusterService.state()).thenReturn(clusterState); diff --git a/src/test/java/org/opensearch/ad/transport/PreviewAnomalyDetectorTransportActionTests.java b/src/test/java/org/opensearch/ad/transport/PreviewAnomalyDetectorTransportActionTests.java index b10c66e7b..dcc9f565a 100644 --- a/src/test/java/org/opensearch/ad/transport/PreviewAnomalyDetectorTransportActionTests.java +++ b/src/test/java/org/opensearch/ad/transport/PreviewAnomalyDetectorTransportActionTests.java @@ -24,6 +24,7 @@ import java.time.Instant; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Locale; @@ -63,7 +64,6 @@ import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.metadata.Metadata; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.collect.ImmutableOpenMap; import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; @@ -121,10 +121,8 @@ public void setUp() throws Exception { .build(); final Settings.Builder existingSettings = Settings.builder().put(indexSettings).put(IndexMetadata.SETTING_INDEX_UUID, "test2UUID"); IndexMetadata indexMetaData = IndexMetadata.builder(AnomalyDetector.ANOMALY_DETECTORS_INDEX).settings(existingSettings).build(); - final ImmutableOpenMap indices = ImmutableOpenMap - .builder() - .fPut(AnomalyDetector.ANOMALY_DETECTORS_INDEX, indexMetaData) - .build(); + final Map indices = new HashMap<>(); + indices.put(AnomalyDetector.ANOMALY_DETECTORS_INDEX, indexMetaData); ClusterState clusterState = ClusterState.builder(clusterName).metadata(Metadata.builder().indices(indices).build()).build(); when(clusterService.state()).thenReturn(clusterState); diff --git a/src/test/java/org/opensearch/ad/util/ExceptionUtilsTests.java b/src/test/java/org/opensearch/ad/util/ExceptionUtilsTests.java index 94af37770..00c9d1a2d 100644 --- a/src/test/java/org/opensearch/ad/util/ExceptionUtilsTests.java +++ b/src/test/java/org/opensearch/ad/util/ExceptionUtilsTests.java @@ -56,7 +56,7 @@ public void testCountInStats() { public void testGetErrorMessage() { assertEquals("test", ExceptionUtil.getErrorMessage(new AnomalyDetectionException("test"))); assertEquals("test", ExceptionUtil.getErrorMessage(new IllegalArgumentException("test"))); - assertEquals("org.opensearch.OpenSearchException: test", ExceptionUtil.getErrorMessage(new OpenSearchException("test"))); + assertEquals("OpenSearchException[test]", ExceptionUtil.getErrorMessage(new OpenSearchException("test"))); assertTrue( ExceptionUtil .getErrorMessage(new RuntimeException("test"))