lundi 1 mai 2017

How to mock dynamodbmapper scan

I have following code that i am trying to mock

public void getOrders(Response response){
    logger.log("Getting all orders");

    DynamoDBScanExpression scanExpression = new DynamoDBScanExpression()
            .withProjectionExpression("OrderId");

    PaginatedScanList<Orders> orders = dynamoDBMapper.scan(Orders.class, scanExpression);

    response.setData(orders..stream()
            .collect(Collectors.toList()));
}

And the way i am trying to mock is

Mockito.when(mockDynamoDBMapper.scan(Orders.class, Mockito.any())).thenReturn(mockPaginatedList);

and i am getting following exception

This exception may occur if matchers are combined with raw values:
    //incorrect:
    someMethod(anyObject(), "raw String");
When using matchers, all arguments have to be provided by matchers.
For example:
    //correct:
    someMethod(anyObject(), eq("String by matcher"));

For more info see javadoc for Matchers class.

how should i mock dbmapper.scan method with any DynamoDBScanExpression object

Aucun commentaire:

Enregistrer un commentaire