@Before public void setup() { runtimeTestActionHandler = mock( RuntimeTestActionHandler.class ); defaultHandler = mock( RuntimeTestActionHandler.class ); runtimeTestActionService = new RuntimeTestActionServiceImpl( Arrays.asList( runtimeTestActionHandler ), defaultHandler ); runtimeTestAction = mock( RuntimeTestAction.class ); }
@Test public void testHandleNormal() { when( runtimeTestActionHandler.canHandle( runtimeTestAction ) ).thenReturn( true ); runtimeTestActionService.handle( runtimeTestAction ); verify( runtimeTestActionHandler ).handle( runtimeTestAction ); verifyNoMoreInteractions( defaultHandler ); } }
@Test public void testHandleDefault() { when( runtimeTestActionHandler.canHandle( runtimeTestAction ) ).thenReturn( false ); runtimeTestActionService.handle( runtimeTestAction ); verify( runtimeTestActionHandler, never() ).handle( runtimeTestAction ); verify( defaultHandler ).handle( runtimeTestAction ); verifyNoMoreInteractions( defaultHandler ); }