use of com.amazonaws.services.lambda.runtime.events.SQSEvent in project aws-doc-sdk-examples by awsdocs.
the class SQSEventDeserializer method deserialize.
@Override
public SQSEvent deserialize(JsonElement eventJson, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
SQSEvent event = new SQSEvent();
logger.info("DESERIALIZING TEST EVENT");
logger.info("EVENT JSON: " + eventJson.toString());
// Records key is capitalized in test event, but lowercase in type
JsonArray recordsArray = eventJson.getAsJsonObject().get("Records").getAsJsonArray();
ArrayList<SQSMessage> records = gson.fromJson(recordsArray, sqsMessageArray);
event.setRecords(records);
return event;
}
use of com.amazonaws.services.lambda.runtime.events.SQSEvent in project aws-doc-sdk-examples by awsdocs.
the class InvokeTest method invokeTest.
@Test
void invokeTest() {
AWSXRay.beginSegment("blank-java-test");
String path = "src/test/resources/event.json";
String eventString = loadJsonFile(path);
SQSEvent event = gson.fromJson(eventString, SQSEvent.class);
Context context = new TestContext();
String requestId = context.getAwsRequestId();
Handler handler = new Handler();
String result = handler.handleRequest(event, context);
assertTrue(result.contains("totalCodeSize"));
AWSXRay.endSegment();
}
Aggregations