TransformStreams { public List<Product> p07_getAllOrderedProducts(Customer customer) { return customer.getOrders().stream() .flatMap(order -> order.getOrderLines().stream()) .map(OrderLine::getProduct) .distinct() .sorted(Comparator.comparing(Product::getName)) .collect(toList()); }  List<OrderDto> p01_toDtos(List<Order> orders); Set<PaymentMethod> p02_getUsedPaymentMethods(Customer customer); SortedSet<LocalDate> p03_getOrderDatesAscending(Customer customer); Map<Long, Order> p04_mapOrdersById(Customer customer); Map<PaymentMethod, List<Order>> p05_getProductsByPaymentMethod(Customer customer); Map<Product, Long> p06_getProductCount(Customer customer); List<Product> p07_getAllOrderedProducts(Customer customer); String p08_getProductsJoined(Customer customer); Long p09_getApproximateTotalOrdersPrice(Customer customer); List<OrderLine> p10_readOrderFromFile(File file);  }
@Test public void p07_getAllOrderedProducts() { Product chair = new Product("Chair"); Product table = new Product("Table"); Order order1 = new Order( new OrderLine(chair, 3)); Order order2 = new Order( new OrderLine(table, 1), new OrderLine(chair, 1)); List<Product> actual = service.p07_getAllOrderedProducts(new Customer(order1, order2)); assertEquals(Arrays.asList(chair, table), actual); }