Solution { public List<String> fizzBuzz(int n) { return IntStream.rangeClosed(1, n).boxed().map(i -> { boolean isFizz = i % 3 == 0; boolean isBuzz = i % 5 == 0; if (isFizz && isBuzz) { return "FizzBuzz"; } else if (isBuzz) { return "Buzz"; } else if (isFizz) { return "Fizz"; } return i.toString(); }).collect(Collectors.toList()); }  List<String> fizzBuzz(int n);  }
@Test public void fizzFor3() throws Exception { Solution solution = new Solution(); List<String> strings = solution.fizzBuzz(3); assertThat(strings, hasItems("1", "2", "Fizz")); }
@Test public void buzzFor5() throws Exception { Solution solution = new Solution(); List<String> strings = solution.fizzBuzz(5); assertThat(strings, hasItems("1", "2", "Fizz", "4", "Buzz")); }
@Test public void fizzBuzzFor15() throws Exception { Solution solution = new Solution(); List<String> strings = solution.fizzBuzz(15); assertThat(strings, hasItems("1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz")); }