@Test
public void testRoll() throws Exception {

  System.setProperty("config.file", "src/test/resources/test.conf");
  ConfigFactory.invalidateCaches();
  final Config config = ConfigFactory.load();
  final String sessionId = "test";
  String[] labels = new String[0];
  RollingTextBlock textBlock = new RollingTextBlock(true, null, sessionId);
  textBlock = textBlock.roll("One ");
  List<Annotation<String>> annotations = new ArrayList<>();
  annotations.add(new Annotation<String>(0, "One".length(), "1", labels));
  textBlock.addAnnotations(annotations);
  textBlock = textBlock.roll("Two ");
  annotations = new ArrayList<>();
  annotations.add(new Annotation<String>("One ".length(), "One Two".length(), "2", labels));
  textBlock.addAnnotations(annotations);
  textBlock = textBlock.roll("Three ");
  annotations = new ArrayList<>();
  annotations.add(new Annotation<String>("One Two ".length(), "One Two Three".length(), "3", labels));
  textBlock.addAnnotations(annotations);
  textBlock = textBlock.roll("Four ");
  annotations = new ArrayList<>();
  annotations.add(new Annotation<String>("One Two Three ".length(), "One Two Three Four".length(), "4", labels));
  textBlock.addAnnotations(annotations);
  textBlock = textBlock.roll("Five");
  assertEquals("Two Three Four Five", textBlock.getText());
  annotations = textBlock.getAnnotations(String.class);
  System.out.println(annotations.toString());
  assertEquals(3, annotations.size());
  int i = 0;
  // ensure annotations have been moved closer to start, since block 1 has
  // now been flushed
  for (Annotation<String> annotation : annotations) {
    if (i == 0) {
      assertEquals("2", annotation.getData());
      assertEquals(0, annotation.getStart());
      assertEquals("Two".length(), annotation.getEnd());
    } else if (i == 1) {
      assertEquals("3", annotation.getData());
      assertEquals("Two ".length(), annotation.getStart());
      assertEquals("Two Three".length(), annotation.getEnd());
    } else if (i == 2) {
      assertEquals("4", annotation.getData());
      assertEquals("Two Three ".length(), annotation.getStart());
      assertEquals("Two Three Four".length(), annotation.getEnd());
    }
    i++;
  }
}