TransformStreams { public Map<PaymentMethod, List<Order>> p05_getProductsByPaymentMethod(Customer customer) { return customer.getOrders().stream() .collect(groupingBy(Order::getPaymentMethod)); }  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 p05_getProductsByPaymentMethod() { Order order1 = new Order().setPaymentMethod(PaymentMethod.CARD); Order order2 = new Order().setPaymentMethod(PaymentMethod.CASH_ON_DELIVERY); Order order3 = new Order().setPaymentMethod(PaymentMethod.CARD); Map<PaymentMethod, List<Order>> actual = service.p05_getProductsByPaymentMethod(new Customer(order1, order2, order3)); assertEquals(Arrays.asList(order2), actual.get(PaymentMethod.CASH_ON_DELIVERY)); assertEquals(Arrays.asList(order1, order3), actual.get(PaymentMethod.CARD)); }