@Test
public void testWordCount() {

  flink.interpret("val text = env.fromElements(\"To be or not to be\")", context);
  flink.interpret("val counts = text.flatMap { _.toLowerCase.split(\" \") }.map { (_, 1) }.groupBy(0).sum(1)", context);
  InterpreterResult result = flink.interpret("counts.print()", context);
  assertEquals(Code.SUCCESS, result.code());
  String[] expectedCounts = {"(to,2)", "(be,2)", "(or,1)", "(not,1)"};
  Arrays.sort(expectedCounts);
  String[] counts = result.message().split("\n");
  Arrays.sort(counts);
  assertArrayEquals(expectedCounts, counts);
}