ViewCustomizer { public StartingPosition getStartingPosition() { final String requestedAction = consumeRequest.getAction(); switch (requestedAction) { case "head": return StartingPosition.newHeadPosition(); case "tail": return StartingPosition.newTailPosition(); case "timestamp": return StartingPosition.newPositionFromTimestamp(consumeRequest.getTimestamp()); case "offsets": default: return StartingPosition.newResumeFromExistingState(); } } ViewCustomizer(final View view, final ConsumeRequest consumeRequest); View overrideViewSettings(); List<FilterDefinition> getFilterDefinitions(); StartingPosition getStartingPosition();  }
@Test public void testStartingPositionTail() { final ConsumeRequest consumeRequest = new ConsumeRequest(); consumeRequest.setAction("tail"); final ViewCustomizer viewCustomizer = new ViewCustomizer(new View(), consumeRequest); final StartingPosition startingPosition = viewCustomizer.getStartingPosition(); assertNotNull(startingPosition); assertTrue(startingPosition.isStartFromTail()); assertFalse(startingPosition.isStartFromOffsets()); assertFalse(startingPosition.isStartFromTimestamp()); assertFalse(startingPosition.isStartFromHead()); }
@Test public void testStartingPositionHead() { final ConsumeRequest consumeRequest = new ConsumeRequest(); consumeRequest.setAction("head"); final ViewCustomizer viewCustomizer = new ViewCustomizer(new View(), consumeRequest); final StartingPosition startingPosition = viewCustomizer.getStartingPosition(); assertNotNull(startingPosition); assertFalse(startingPosition.isStartFromTail()); assertFalse(startingPosition.isStartFromOffsets()); assertFalse(startingPosition.isStartFromTimestamp()); assertTrue(startingPosition.isStartFromHead()); }
@Test public void testStartingPositionTimestamp() { final long timestamp = 2432323L; final ConsumeRequest consumeRequest = new ConsumeRequest(); consumeRequest.setAction("timestamp"); consumeRequest.setTimestamp(timestamp); final ViewCustomizer viewCustomizer = new ViewCustomizer(new View(), consumeRequest); final StartingPosition startingPosition = viewCustomizer.getStartingPosition(); assertNotNull(startingPosition); assertFalse(startingPosition.isStartFromTail()); assertFalse(startingPosition.isStartFromOffsets()); assertTrue(startingPosition.isStartFromTimestamp()); assertFalse(startingPosition.isStartFromHead()); assertEquals("Has expected timestamp", timestamp, startingPosition.getTimestamp()); }