forked from aws/aws-lambda-java-libs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMSKFirehoseEventHandlerTest.java
27 lines (21 loc) · 1.17 KB
/
MSKFirehoseEventHandlerTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package example;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.tests.annotations.Event;
import com.amazonaws.services.lambda.runtime.events.MSKFirehoseEvent;
import com.amazonaws.services.lambda.runtime.events.MSKFirehoseResponse;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import static java.nio.charset.StandardCharsets.UTF_8;
public class MSKFirehoseEventHandlerTest {
private Context context; // intentionally null as it's not used in the test
@ParameterizedTest
@Event(value = "event.json", type = MSKFirehoseEvent.class)
public void testEventHandler(MSKFirehoseEvent event) {
MSKFirehoseEventHandler Sample = new MSKFirehoseEventHandler();
MSKFirehoseResponse response = Sample.handleRequest(event, context);
String expectedString = "{\"Name\":\"Hello World\"}";
MSKFirehoseResponse.Record firstRecord = response.getRecords().get(0);
Assertions.assertEquals(expectedString, UTF_8.decode(firstRecord.getKafkaRecordValue()).toString());
Assertions.assertEquals(MSKFirehoseResponse.Result.Ok, firstRecord.getResult());
}
}