@Test
@SuppressWarnings("unchecked")
void testProcessUnfinishedOrders() {

    List<Order> desiredOrders = TestData.unfinishedOrders();

    TypedQuery mockQuery = mock(TypedQuery.class);
    when(testObject.entityManager.createNamedQuery(Order.FIND_UNFINISHED, Order.class)).thenReturn(mockQuery);
    when(mockQuery.getResultList()).thenReturn(desiredOrders);
    ArgumentCaptor<Order> orderCaptor = ArgumentCaptor.forClass(Order.class);

    testObject.processUnfinishedOrders();

    verify(testObject.entityManager).createNamedQuery(Order.FIND_UNFINISHED, Order.class);
    verify(testObject.orderProcessor, times(desiredOrders.size())).processOrder(orderCaptor.capture());

    assertThat(orderCaptor.getAllValues()).containsExactlyElementsOf(desiredOrders);

    orderCaptor.getAllValues().forEach(o -> assertThat(o).isPreparing());
}