### Question:
FilterManager { public void addFilter(Filter filter) { filterChain.addFilter(filter); } FilterManager(); void addFilter(Filter filter); String filterRequest(Order order);  }### Answer:
@Test public void testAddFilter() { final Target target = mock(Target.class); final FilterManager filterManager = new FilterManager(); verifyZeroInteractions(target); final Filter filter = mock(Filter.class); when(filter.execute(any(Order.class))).thenReturn("filter"); filterManager.addFilter(filter); final Order order = mock(Order.class); assertEquals("filter", filterManager.filterRequest(order)); verify(filter, times(1)).execute(any(Order.class)); verifyZeroInteractions(target, filter, order); }
@Test public void testAddFilter() { final var target = mock(Target.class); final var filterManager = new FilterManager(); verifyZeroInteractions(target); final var filter = mock(Filter.class); when(filter.execute(any(Order.class))).thenReturn("filter"); filterManager.addFilter(filter); final Order order = mock(Order.class); assertEquals("filter", filterManager.filterRequest(order)); verify(filter, times(1)).execute(any(Order.class)); verifyZeroInteractions(target, filter, order); }
@Test public void testAddFilter() throws Exception { final Target target = mock(Target.class); final FilterManager filterManager = new FilterManager(); verifyZeroInteractions(target); final Filter filter = mock(Filter.class); when(filter.execute(any(Order.class))).thenReturn("filter"); filterManager.addFilter(filter); final Order order = mock(Order.class); assertEquals("filter", filterManager.filterRequest(order)); verify(filter, times(1)).execute(any(Order.class)); verifyZeroInteractions(target, filter, order); }