From 6db417744fd508ef3540711b451a741a93e36da8 Mon Sep 17 00:00:00 2001 From: Chase Engelbrecht Date: Mon, 23 Oct 2023 17:35:48 -0500 Subject: [PATCH] Use correct exception type in unit tests Signed-off-by: Chase Engelbrecht --- .../opensearch/index/DynamicIndexManagerTests.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/DynamicIndexManagerTests.java b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/DynamicIndexManagerTests.java index de8eb37f4e..d752370d4e 100644 --- a/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/DynamicIndexManagerTests.java +++ b/data-prepper-plugins/opensearch/src/test/java/org/opensearch/dataprepper/plugins/sink/opensearch/index/DynamicIndexManagerTests.java @@ -74,6 +74,9 @@ public class DynamicIndexManagerTests { @Mock private TemplateStrategy templateStrategy; + @Mock + private OpenSearchException openSearchException; + static final String EVENT_TYPE = "event"; @BeforeEach @@ -195,8 +198,8 @@ public void getIndexName_DoesRetryOnOpenSearchExceptions_UntilSuccess() throws I innerIndexManager = mock(IndexManager.class); when(mockIndexManagerFactory.getIndexManager( IndexType.CUSTOM, openSearchClient, restHighLevelClient, openSearchSinkConfiguration, templateStrategy, expectedIndexAlias)).thenReturn(innerIndexManager); - doThrow(new OpenSearchException(new RuntimeException())) - .doThrow(new OpenSearchException(new RuntimeException())) + doThrow(openSearchException) + .doThrow(openSearchException) .doNothing() .when(innerIndexManager).setupIndex(); when(innerIndexManager.getIndexName(expectedIndexAlias)).thenReturn(expectedIndexAlias); @@ -216,8 +219,8 @@ public void getIndexName_DoesRetryOnOpenSearchExceptions_UntilFailure() throws I innerIndexManager = mock(IndexManager.class); when(mockIndexManagerFactory.getIndexManager( IndexType.CUSTOM, openSearchClient, restHighLevelClient, openSearchSinkConfiguration, templateStrategy, expectedIndexAlias)).thenReturn(innerIndexManager); - doThrow(new OpenSearchException(new RuntimeException())) - .doThrow(new OpenSearchException(new RuntimeException())) + doThrow(openSearchException) + .doThrow(openSearchException) .doThrow(new RuntimeException()) .when(innerIndexManager).setupIndex(); when(innerIndexManager.getIndexName(expectedIndexAlias)).thenReturn(expectedIndexAlias);