I have to add the PaginatedQueryList from to secondList which comes from dynamoDbMapper.query for testing. How can I achieve it?
List exampleList = secondList.addAll(dynamoDbMapper.query(MyDAOClass.class, queryExpression));
I tried to mock the PaginatedQueryList but am getting null pointer exception because elements in mocked PaginatedQueryList is empty.
Any suggestions please?
You can do the following and it will work:
Create mock for paginated result.
@Mock
private PaginatedQueryList<Object> queryResult;
Return mocked result when query is called.
when(dynamoDBMapper.query(any(), any())).thenReturn(queryResult);
set result in paginated result by mocking it with an array of expected list, say, firstList.
when(queryResult.toArray()).thenReturn(firstList);
Add result in secondList.
List exampleList = secondList.addAll(firstlist)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With