@Before public void setup() { name = "name"; description = "description"; severity = RuntimeTestEntrySeverity.DEBUG; payload = mock( RuntimeTestActionPayload.class ); runtimeTestAction = new RuntimeTestActionImpl( name, description, severity, payload ); }
@Before public void setup() { runtimeTestActionHandler = mock( RuntimeTestActionHandler.class ); defaultHandler = mock( RuntimeTestActionHandler.class ); runtimeTestActionService = new RuntimeTestActionServiceImpl( Arrays.asList( runtimeTestActionHandler ), defaultHandler ); runtimeTestAction = mock( RuntimeTestAction.class ); }
private static RuntimeTestAction createDefaultAction( MessageGetterFactory messageGetterFactory, RuntimeTestEntrySeverity severity, DocAnchor docAnchor ) { if ( severity == null || severity.ordinal() >= RuntimeTestEntrySeverity.WARNING.ordinal() ) { MessageGetter messageGetter = messageGetterFactory.create( PKG ); String docUrl = Const.getDocUrl( messageGetter.getMessage( RUNTIME_TEST_RESULT_ENTRY_WITH_DEFAULT_SHIM_HELP_SHELL_DOC ) ); if ( docAnchor != null ) { docUrl += messageGetter.getMessage( docAnchor.getAnchorTextKey() ); } return new RuntimeTestActionImpl( messageGetter.getMessage( RUNTIME_TEST_RESULT_ENTRY_WITH_DEFAULT_SHIM_HELP_TROUBLESHOOTING_GUIDE ), docUrl, severity, new HelpUrlPayload( messageGetterFactory, messageGetter.getMessage( RUNTIME_TEST_RESULT_ENTRY_WITH_DEFAULT_SHIM_HELP_SHELL_DOC_TITLE ), messageGetter.getMessage( RUNTIME_TEST_RESULT_ENTRY_WITH_DEFAULT_SHIM_HELP_SHELL_DOC_HEADER ), docUrl ) ); } return null; }
@Test public void testGetHeader() { assertEquals( header, helpUrlPayload.getHeader() ); }
@Test public void testGetTitle() { assertEquals( title, helpUrlPayload.getTitle() ); }
@Test public void testGetUrl() { assertEquals( url, helpUrlPayload.getUrl() ); }
@Before public void setup() { TestMessageGetterFactory messageGetterFactory = new TestMessageGetterFactory(); messageGetter = messageGetterFactory.create( HelpUrlPayload.class ); title = "title"; header = "header"; url = "url"; helpUrlPayload = new HelpUrlPayload( messageGetterFactory, title, header, url ); }
@Test public void testHandleNormal() { when( runtimeTestActionHandler.canHandle( runtimeTestAction ) ).thenReturn( true ); runtimeTestActionService.handle( runtimeTestAction ); verify( runtimeTestActionHandler ).handle( runtimeTestAction ); verifyNoMoreInteractions( defaultHandler ); } }
@Test public void testHandleDebugSeverity() { handleSetup( RuntimeTestEntrySeverity.DEBUG ); verify( logger ).debug( messageGetter .getMessage( LoggingRuntimeTestActionHandlerImpl.LOGGING_RUNTIME_TEST_ACTION_HANDLER_IMPL, actionName, actionDescription, runtimeTestActionPayload.toString() ) ); }
@Test public void testGetPayload() { assertEquals( payload, runtimeTestAction.getPayload() ); } }
private void handleSetup( RuntimeTestEntrySeverity severity ) { when( runtimeTestAction.getSeverity() ).thenReturn( severity ); when( runtimeTestAction.getName() ).thenReturn( actionName ); when( runtimeTestAction.getDescription() ).thenReturn( actionDescription ); when( runtimeTestAction.getPayload() ).thenReturn( runtimeTestActionPayload ); loggingRuntimeTestActionHandler.handle( runtimeTestAction ); }
@Test public void testGetSeverity() { assertEquals( severity, runtimeTestAction.getSeverity() ); }
@Test public void testGetName() { assertEquals( name, runtimeTestAction.getName() ); }
@Before public void setup() { TestMessageGetterFactory messageGetterFactory = new TestMessageGetterFactory(); messageGetter = messageGetterFactory.create( LoggingRuntimeTestActionHandlerImpl.class ); logger = mock( Logger.class ); loggingRuntimeTestActionHandler = new LoggingRuntimeTestActionHandlerImpl( messageGetterFactory, logger ); runtimeTestAction = mock( RuntimeTestAction.class ); actionName = "actionName"; actionDescription = "actionDescription"; runtimeTestActionPayload = mock( RuntimeTestActionPayload.class ); }
@Test public void testGetDescription() { assertEquals( description, runtimeTestAction.getDescription() ); }
@Test public void testCanHandle() { // Should work with least specific payload as it always returns true when( runtimeTestAction.getPayload() ).thenReturn( mock( RuntimeTestActionPayload.class ) ); assertTrue( loggingRuntimeTestActionHandler.canHandle( runtimeTestAction ) ); }
@Test public void testGetMessage() { assertEquals( messageGetter.getMessage( HelpUrlPayload.HELP_URL_PAYLOAD_MESSAGE, url ), helpUrlPayload.getMessage() ); } }
@Test public void testHandleDefault() { when( runtimeTestActionHandler.canHandle( runtimeTestAction ) ).thenReturn( false ); runtimeTestActionService.handle( runtimeTestAction ); verify( runtimeTestActionHandler, never() ).handle( runtimeTestAction ); verify( defaultHandler ).handle( runtimeTestAction ); verifyNoMoreInteractions( defaultHandler ); }
@Test public void testHandleWarningSeverity() { handleSetup( RuntimeTestEntrySeverity.WARNING ); verify( logger ).warn( messageGetter .getMessage( LoggingRuntimeTestActionHandlerImpl.LOGGING_RUNTIME_TEST_ACTION_HANDLER_IMPL, actionName, actionDescription, runtimeTestActionPayload.toString() ) ); }