|
25 | 25 | import static org.mockito.Mockito.verify; |
26 | 26 | import static org.mockito.Mockito.times; |
27 | 27 | import static org.hamcrest.MatcherAssert.assertThat; |
| 28 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
28 | 29 | import static org.hamcrest.CoreMatchers.equalTo; |
29 | 30 | import static org.hamcrest.CoreMatchers.not; |
30 | 31 | import static org.mockito.ArgumentMatchers.anyString; |
@@ -70,8 +71,6 @@ public class SqsSinkServiceTest { |
70 | 71 | @Mock |
71 | 72 | private PluginFactory pluginFactory; |
72 | 73 | @Mock |
73 | | - private PluginSetting codecPluginSettings; |
74 | | - @Mock |
75 | 74 | private SendMessageBatchResponse flushResponse; |
76 | 75 | @Mock |
77 | 76 | private EventHandle eventHandle; |
@@ -109,7 +108,6 @@ private SqsSinkService createObjectUnderTest() { |
109 | 108 | void setup() { |
110 | 109 | sinkContext = mock(SinkContext.class); |
111 | 110 | pluginFactory = mock(PluginFactory.class); |
112 | | - codecPluginSettings = mock(PluginSetting.class); |
113 | 111 | when(sinkContext.getExcludeKeys()).thenReturn(null); |
114 | 112 | when(sinkContext.getIncludeKeys()).thenReturn(null); |
115 | 113 | when(sinkContext.getTagsTargetKey()).thenReturn(null); |
@@ -302,6 +300,22 @@ void TestExecuteWithOneBatch_MultipleRetries(int numRecords) throws Exception { |
302 | 300 | verify(eventHandle, times(numRecords)).release(true); |
303 | 301 | } |
304 | 302 |
|
| 303 | + @Test |
| 304 | + void TestFiFoQWithInvalidDeDupIdExpression() { |
| 305 | + when(expressionEvaluator.isValidFormatExpression(anyString())).thenReturn(false); |
| 306 | + when (sqsSinkConfig.getQueueUrl()).thenReturn(queueUrl+".fifo"); |
| 307 | + when (sqsSinkConfig.getDeDuplicationId()).thenReturn(UUID.randomUUID().toString()+"${/id - }"); |
| 308 | + assertThrows(IllegalArgumentException.class, ()-> createObjectUnderTest()); |
| 309 | + } |
| 310 | + |
| 311 | + @Test |
| 312 | + void TestFiFoQWithInvalidGroupIdExpression() { |
| 313 | + when(expressionEvaluator.isValidFormatExpression(anyString())).thenReturn(false); |
| 314 | + when (sqsSinkConfig.getQueueUrl()).thenReturn(queueUrl+".fifo"); |
| 315 | + when (sqsSinkConfig.getGroupId()).thenReturn(UUID.randomUUID().toString()+"${/id - }"); |
| 316 | + assertThrows(IllegalArgumentException.class, ()-> createObjectUnderTest()); |
| 317 | + } |
| 318 | + |
305 | 319 | @ParameterizedTest |
306 | 320 | @ValueSource(ints = {10, 30, 50, 70}) |
307 | 321 | void TestWithOneBatch_SuccessfulFlushFiFoQDynamic(int numRecords) throws Exception { |
|
0 commit comments