QuickFixJAutoConfigFailureAnalyzer extends AbstractFailureAnalyzer<QuickFixJBaseException> { @Override protected FailureAnalysis analyze(Throwable rootFailure, QuickFixJBaseException cause) { String descriptionMessage = cause.getMessage(); String actionMessage = cause.getMessage(); String rootCauseMessage = getRootCauseMessage(cause); if (cause instanceof ConfigurationException) { descriptionMessage = "A configuration error has been detected in the QuickFIX/J settings provided: " + rootCauseMessage; actionMessage = "Please configure your QuickFIX/J settings as per the documentation: https: } if (cause instanceof SettingsNotFoundException) { descriptionMessage = "The QuickFIX/J settings file could not be found: " + rootCauseMessage; actionMessage = "Please provide a QuickFIX/J settings file on the property 'config' for the client/server section in your configuration file."; } return new FailureAnalysis(descriptionMessage, actionMessage, cause); }    }
@Test public void shouldAnalyzeConfigurationException() { QuickFixJAutoConfigFailureAnalyzer analyzer = new QuickFixJAutoConfigFailureAnalyzer(); ConfigurationException exception = new ConfigurationException("Error", new RuntimeException("Error message")); FailureAnalysis analyze = analyzer.analyze(null, exception); assertThat(analyze.getAction()).contains("Please configure your QuickFIX/J settings"); assertThat(analyze.getDescription()).contains("A configuration error has been detected in the QuickFIX/J settings provided: Error message"); assertThat(analyze.getCause()).isEqualTo(exception); }
@Test public void shouldAnalyzeSettingsNotFoundException() { QuickFixJAutoConfigFailureAnalyzer analyzer = new QuickFixJAutoConfigFailureAnalyzer(); SettingsNotFoundException exception = new SettingsNotFoundException("Error", new RuntimeException(new RuntimeException("Error message"))); FailureAnalysis analyze = analyzer.analyze(null, exception); assertThat(analyze.getAction()).contains("Please provide a QuickFIX/J settings file"); assertThat(analyze.getDescription()).contains("The QuickFIX/J settings file could not be found: Error message"); assertThat(analyze.getCause()).isEqualTo(exception); }
@Test public void shouldAnalyzeAnyException() { QuickFixJAutoConfigFailureAnalyzer analyzer = new QuickFixJAutoConfigFailureAnalyzer(); QuickFixJBaseException exception = new QuickFixJBaseException("Error message", new RuntimeException()); FailureAnalysis analyze = analyzer.analyze(null, exception); assertThat(analyze.getAction()).contains("Error message"); assertThat(analyze.getDescription()).contains("Error message"); assertThat(analyze.getCause()).isEqualTo(exception); }