SearchStreams { public List<Order> p6_getLast3Orders(Customer customer) { return null; }  List<Order> p1_getActiveOrders(Customer customer); Order p2_getOrderById(List<Order> orders, long orderId); boolean p3_hasActiveOrders(Customer customer); boolean p4_canBeReturned(Order order); Order p5_getMaxPriceOrder(Customer customer); List<Order> p6_getLast3Orders(Customer customer);  }
@Test public void p6_getLast3Orders() { Order order1 = new Order().setCreationDate(LocalDate.parse("2016-01-01")); Order order2 = new Order().setCreationDate(LocalDate.parse("2016-01-02")); Order order3 = new Order().setCreationDate(LocalDate.parse("2016-01-03")); Order order4 = new Order().setCreationDate(LocalDate.parse("2016-01-04")); Customer customer = new Customer(order1, order2, order3, order4); assertEquals(Arrays.asList(order4,order3,order2), service.p6_getLast3Orders(customer)); }
@Test public void p6_getLast3Orders_whenOnlyTwoOrders() { Order order1 = new Order().setCreationDate(LocalDate.parse("2016-01-01")); Order order2 = new Order().setCreationDate(LocalDate.parse("2016-01-02")); Customer customer = new Customer(order1, order2); assertEquals(Arrays.asList(order2, order1), service.p6_getLast3Orders(customer)); }
@Test public void p6_getLast3Orders_whenNoOrders() { Customer customer = new Customer(); assertEquals(Arrays.asList(), service.p6_getLast3Orders(customer)); }