### Question:
DatabaseMailStatusResult extends AbstractMailStatusResult { @Override public Iterator<MailStatus> getAll() { if (this.batchId == null) { return Collections.emptyIterator(); } try { return this.mailStatusStore.load(Collections.<String, Object>singletonMap(BATCHID_KEY, this.batchId), 0, 0, DATE_FIELD, true).iterator(); } catch (MailStoreException e) { LOGGER.error("Failed to get all results. Returning an empty result.", e); return Collections.emptyIterator(); } } DatabaseMailStatusResult(MailStatusStore mailStatusStore); void setBatchId(String batchId); @Override Iterator<MailStatus> getAll(); @Override Iterator<MailStatus> getAllErrors(); @Override Iterator<MailStatus> getByState(MailState state);  }### Answer:
@Test public void getAll() throws Exception { MailStatusStore store = mock(MailStatusStore.class); MailStatus status = new MailStatus(); when(store.load(Collections.<String, Object>singletonMap("batchId", "batchid"), 0, 0, "date", true)) .thenReturn(Arrays.asList(status)); DatabaseMailStatusResult result = new DatabaseMailStatusResult(store); result.setBatchId("batchid"); Iterator<MailStatus> resultStatuses = result.getAll(); MailStatus resultStatus = resultStatuses.next(); assertSame(status, resultStatus); assertFalse(resultStatuses.hasNext()); }