ViewCustomizer { public View overrideViewSettings() { overrideResultPerPartition(); overridePartitions(); return view; } ViewCustomizer(final View view, final ConsumeRequest consumeRequest); View overrideViewSettings(); List<FilterDefinition> getFilterDefinitions(); StartingPosition getStartingPosition();  }
@Test public void testOverrideView() { final View view = new View(); view.setPartitions(""); view.setTopic("MyTopic"); view.setResultsPerPartition(10); final ConsumeRequest consumeRequest = new ConsumeRequest(); consumeRequest.setPartitions("2,3"); consumeRequest.setResultsPerPartition(100); final ViewCustomizer viewCustomizer = new ViewCustomizer(view, consumeRequest); viewCustomizer.overrideViewSettings(); assertEquals("Should have 100 results per partition", 100, (int) view.getResultsPerPartition()); assertEquals("should have partitions 2 and 3", "2,3", view.getPartitions()); assertEquals("should have partitions 2 and 3", 2, view.getPartitionsAsSet().size()); assertTrue("should have partitions 2 and 3", view.getPartitionsAsSet().contains(2)); assertTrue("should have partitions 2 and 3", view.getPartitionsAsSet().contains(3)); }
@Test public void testOverrideViewWithHasRestrictedPartitions() { final View view = new View(); view.setPartitions("2,3,4"); final ConsumeRequest consumeRequest = new ConsumeRequest(); consumeRequest.setPartitions("2,3"); final ViewCustomizer viewCustomizer = new ViewCustomizer(view, consumeRequest); viewCustomizer.overrideViewSettings(); assertEquals("should have partitions 2 and 3", "2,3", view.getPartitions()); assertEquals("should have partitions 2 and 3", 2, view.getPartitionsAsSet().size()); assertTrue("should have partitions 2 and 3", view.getPartitionsAsSet().contains(2)); assertTrue("should have partitions 2 and 3", view.getPartitionsAsSet().contains(3)); }
@Test public void testOverrideViewWithHasRestrictedPartitionsIllegalOptionIgnored() { final View view = new View(); view.setPartitions("2,3,4"); final ConsumeRequest consumeRequest = new ConsumeRequest(); consumeRequest.setPartitions("2,3,10"); final ViewCustomizer viewCustomizer = new ViewCustomizer(view, consumeRequest); viewCustomizer.overrideViewSettings(); assertEquals("should have partitions 2 and 3", "2,3", view.getPartitions()); assertEquals("should have partitions 2 and 3", 2, view.getPartitionsAsSet().size()); assertTrue("should have partitions 2 and 3", view.getPartitionsAsSet().contains(2)); assertTrue("should have partitions 2 and 3", view.getPartitionsAsSet().contains(3)); }