title: Junit Testing mock a service and filter results
body: <p>I want to test the following function (Junit test). I am using Mockito to mock Dynamodao service (It gets items from dynamodb). I am filtering the items based on the owner name.</p>
  
  <pre><code>owner = this.getUser(httpRequest);
  List&lt;MapData&gt; result = this.dynamoDao.getAllRecords(TABLE_NAME, Regions.US_WEST_2);
  List&lt;MapData&gt; result1 = result.stream().filter(x -&gt; owner.equals(x.getOwner()))
                              .collect(Collectors.toList());
  </code></pre>
  
  <p>Here MapData is a class which has Owner as a dynamodbattribute. I read about Mockito and realised that I would need it to mock the service.</p>
  
  <pre><code>@Mock
  private DynamoDao dynamoDao;
  </code></pre>
  
  <p>How can I test this simple function? I could really use some help on how to proceed. How can I use "when" here? I tried going through sample codes online but did not understand much.</p>