Skip to content

Commit fc6a7fe

Browse files
committed
Removed failing testcase and added other tests
Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
1 parent b2800e8 commit fc6a7fe

2 files changed

Lines changed: 17 additions & 30 deletions

File tree

data-prepper-plugins/sqs-sink/src/test/java/org/opensearch/dataprepper/plugins/sink/sqs/SqsSinkServiceTest.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import static org.mockito.Mockito.verify;
2626
import static org.mockito.Mockito.times;
2727
import static org.hamcrest.MatcherAssert.assertThat;
28+
import static org.junit.jupiter.api.Assertions.assertThrows;
2829
import static org.hamcrest.CoreMatchers.equalTo;
2930
import static org.hamcrest.CoreMatchers.not;
3031
import static org.mockito.ArgumentMatchers.anyString;
@@ -70,8 +71,6 @@ public class SqsSinkServiceTest {
7071
@Mock
7172
private PluginFactory pluginFactory;
7273
@Mock
73-
private PluginSetting codecPluginSettings;
74-
@Mock
7574
private SendMessageBatchResponse flushResponse;
7675
@Mock
7776
private EventHandle eventHandle;
@@ -109,7 +108,6 @@ private SqsSinkService createObjectUnderTest() {
109108
void setup() {
110109
sinkContext = mock(SinkContext.class);
111110
pluginFactory = mock(PluginFactory.class);
112-
codecPluginSettings = mock(PluginSetting.class);
113111
when(sinkContext.getExcludeKeys()).thenReturn(null);
114112
when(sinkContext.getIncludeKeys()).thenReturn(null);
115113
when(sinkContext.getTagsTargetKey()).thenReturn(null);
@@ -302,6 +300,22 @@ void TestExecuteWithOneBatch_MultipleRetries(int numRecords) throws Exception {
302300
verify(eventHandle, times(numRecords)).release(true);
303301
}
304302

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+
305319
@ParameterizedTest
306320
@ValueSource(ints = {10, 30, 50, 70})
307321
void TestWithOneBatch_SuccessfulFlushFiFoQDynamic(int numRecords) throws Exception {

data-prepper-plugins/sqs-sink/src/test/java/org/opensearch/dataprepper/plugins/sink/sqs/SqsSinkTest.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -127,33 +127,6 @@ void TestBasic() {
127127
}
128128
}
129129

130-
@Test
131-
void TestWithDLQConfig() {
132-
PluginModel dlqConfig = mock(PluginModel.class);
133-
when(dlqConfig.getPluginSettings()).thenReturn(new HashMap<String, Object>());
134-
when(dlqConfig.getPluginName()).thenReturn("s3");
135-
136-
S3DlqWriterConfig s3DlqWriterConfig = mock(S3DlqWriterConfig.class);
137-
when(s3DlqWriterConfig.getBucket()).thenReturn("bucket");
138-
when(s3DlqWriterConfig.getKeyPathPrefix()).thenReturn("dlq");
139-
S3Client s3Client = mock(S3Client.class);
140-
when(s3DlqWriterConfig.getS3Client()).thenReturn(s3Client);
141-
S3DlqProvider s3DlqProvider = new S3DlqProvider(s3DlqWriterConfig);
142-
when(pluginFactory.loadPlugin(eq(DlqProvider.class), any())).thenReturn(s3DlqProvider);
143-
144-
when(sqsSinkConfig.getDlq()).thenReturn(dlqConfig);
145-
146-
try(MockedStatic<SqsClientFactory> mockedStatic = mockStatic(SqsClientFactory.class)) {
147-
mockedStatic.when(() -> SqsClientFactory.createSqsClient(any(Region.class),
148-
any(AwsCredentialsProvider.class)))
149-
.thenReturn(sqsClient);
150-
151-
SqsSink sqsSink = createObjectUnderTest();
152-
sqsSink.doInitialize();
153-
assertTrue(sqsSink.isReady());
154-
}
155-
}
156-
157130
@Test
158131
void TestWithInvalidCodec() {
159132
when(codecConfig.getPluginName()).thenReturn("badCodec");

0 commit comments

Comments
 (0)