Skip to content

Commit 57a9a81

Browse files
authored
Create MSKFirehoseEventHandlerTest.java
Adding test class.
1 parent df1e0e4 commit 57a9a81

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package example;
2+
3+
import com.amazonaws.services.lambda.runtime.Context;
4+
import com.amazonaws.services.lambda.runtime.tests.annotations.Event;
5+
import com.amazonaws.services.lambda.runtime.events.MSKFirehoseEvent;
6+
import com.amazonaws.services.lambda.runtime.events.MSKFirehoseResponse;
7+
import org.junit.jupiter.api.Assertions;
8+
import org.junit.jupiter.params.ParameterizedTest;
9+
10+
import static java.nio.charset.StandardCharsets.UTF_8;
11+
12+
public class MSKFirehoseEventHandlerTest {
13+
14+
private Context context; // intentionally null as it's not used in the test
15+
16+
@ParameterizedTest
17+
@Event(value = "event.json", type = MSKFirehoseEvent.class)
18+
public void testEventHandler(MSKFirehoseEvent event) {
19+
Sample Sample = new Sample();
20+
MSKFirehoseResponse response = Sample.handleRequest(event, context);
21+
22+
String expectedString = "{\"Name\":\"Hello World\"}";
23+
MSKFirehoseResponse.Record firstRecord = response.getRecords().get(0);
24+
Assertions.assertEquals(expectedString, UTF_8.decode(firstRecord.getKafkaRecordValue()).toString());
25+
Assertions.assertEquals(MSKFirehoseResponse.Result.Ok, firstRecord.getResult());
26+
}
27+
}

0 commit comments

Comments
 (0)