Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JsonMappingException when run as junit at Eclipse Amazon lambda function

In Eclipse, i created a new Amazon lambda function to a dynamodb event. I didn't implement anything, the code is as the Amazon wizard creates the project.

When i run the test as junit, it returns:

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

I try to solve this with @JsonIgnore, but i get the same result.

Any suggestion?

like image 879
Carlos Tomas Avatar asked Feb 21 '16 18:02

Carlos Tomas


1 Answers

I pass the junit test modifying the class of the object input from DynamodbEvent to Object at 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 at the lambda function I change the class to the input object too:

public class LambdaFunctionHandler implements RequestHandler<Object, Object> {

@Override
public Object handleRequest(Object input, Context context) {
like image 184
Carlos Tomas Avatar answered Oct 23 '22 23:10

Carlos Tomas