@Test
 public void testDiscountWithBreadOffer() {
   Offer breadOffer = new BreadOffer();
   PriceCalculator priceCalculator = new PriceCalculatorImpl(new BreadOffer());
   double discount =
       priceCalculator
           .getDiscounts(basket)
           .entrySet()
           .stream()
           .collect(Collectors.summingDouble(Entry::getValue));
   assertEquals(breadOffer.getDiscount(basket), discount, PRICE_TOLERANCE);
 }
  public static void main(String[] args) {

    long total = colaboradores.stream().filter(c -> c.getSalario() > 5000).count();

    System.out.println("total : " + total);

    System.out.println("Nomes dos ricos\n");
    colaboradores
        .stream()
        .filter(c -> c.getSalario() > 5000)
        .map(c -> c.getNome())
        .forEach(System.out::println);

    System.out.println("\nCpf dos ricos\n");

    List<String> cpfs =
        colaboradores
            .stream()
            .filter(c -> c.getSalario() > 5000)
            .map(c -> c.getCpf())
            .collect(Collectors.toList());

    cpfs.forEach(System.out::println);

    System.out.println("\nRicos completos\n");

    List<Colaborador> ricos =
        colaboradores.stream().filter(c -> c.getSalario() > 5000).collect(Collectors.toList());

    ricos.forEach(System.out::println);

    System.out.println("\nCpf dos ricos\n");

    double totalSalarios =
        colaboradores
            .stream()
            .filter(c -> c.getSalario() > 5000)
            .collect(Collectors.summingDouble(Colaborador::getSalario));

    System.out.println("\nTotal dos salários " + totalSalarios);

    long totalId =
        colaboradores
            .stream()
            .filter(c -> c.getSalario() > 5000)
            .collect(Collectors.summingLong(Colaborador::getId));

    System.out.println("\nTotal dos ids " + totalId);

    System.out.println("\nExibindo por ordem alfabética os nomes\n");

    colaboradores
        .stream()
        .filter(c -> c.getSalario() > 5000)
        .map(c -> c.getNome().toUpperCase())
        .sorted()
        .forEach(System.out::println);

    colaboradores
        .stream()
        .filter(c -> c.getSalario() > 5000)
        .map(c -> c.getNome().toUpperCase())
        .sorted(Comparator.comparing(String::toUpperCase))
        .forEach(System.out::println);

    System.out.println("\nExibindo por ordem alfabética inversa os nomes\n");

    colaboradores
        .stream()
        .filter(c -> c.getSalario() > 5000)
        .sorted(Comparator.comparing(Colaborador::getNome).reversed())
        .map(c -> c.getNome().toUpperCase())
        .forEach(System.out::println);
  }
 /**
  * Returns the sum of elements if the int-<code>mapper</code> provided is applied on every
  * element.
  */
 public default double sum(ToDoubleFunction<? super T> mapper) {
   return stream().collect(Collectors.summingDouble(mapper));
 }