6

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?

1 Answer 1

2

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) {
Sign up to request clarification or add additional context in comments.

3 Comments

Did you ever get a better answer to this? I'm running into the exact same problem. In my code, parsing the JSON works just fine. However, when running it as a JUnit test I get the parsing exception.
Sorry, I did not find a better answer to this.
Please have a look to Joost Den Boer workaround which solved problem for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.