Skip to content

Commit

Permalink
Use correct exception type in unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Chase Engelbrecht <[email protected]>
  • Loading branch information
engechas committed Oct 23, 2023
1 parent c28d48f commit 6db4177
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public class DynamicIndexManagerTests {
@Mock
private TemplateStrategy templateStrategy;

@Mock
private OpenSearchException openSearchException;

static final String EVENT_TYPE = "event";

@BeforeEach
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 6db4177

Please sign in to comment.