JsonMappingException when running as junit in Amazon lambda Eclipse function

In Eclipse, I created a new Amazon lambda function for the dynamodb event. I have not implemented anything, the code, since the Amazon wizard creates the project.

When I run the test as junit, it returns:

com.fasterxml.jackson.databind.JsonMappingException: conflicting setter definitions for the eventName property: com.amazonaws.services.dynamodbv2.model.Record # setEventName (1 params) vs com.amazonaws.services.dynamodbv2.model. Record # setEventName (1 parameter)

I am trying to solve this with @JsonIgnore , but I get the same result.

Any suggestion?

+5
source share
1 answer

I pass the junit test by changing the class of the input object from DynamodbEvent to Object in the test method:

 public class LambdaFunctionHandlerTest { //private static DynamodbEvent input; private static Object input; @BeforeClass public static void createInput() throws IOException { //input = TestUtils.parse("dynamodb-update-event.json", DynamodbEvent.class); input = TestUtils.parse("dynamodb-update-event.json", Object.class); } 

And with the lambda function, I also change the class to the input object:

 public class LambdaFunctionHandler implements RequestHandler<Object, Object> { @Override public Object handleRequest(Object input, Context context) { 
+2
source

Source: https://habr.com/ru/post/1243526/


All Articles