private TestResult test(final DataSource dataSource) { TestResult testResult = new TestResult(false); StringBuilder stringBuilder = new StringBuilder(); try { stringBuilder.append("\n"); stringBuilder.append("Test Successful"); testResult.setTestPassed(true); stringBuilder.append("Test Failed"); testResult.setMessage(stringBuilder.toString()); return testResult;
@Override public TestResult testDataSource(final String uuid) { try { DataSource dataSource = runtimeManager.lookupDataSource(uuid); return test(dataSource); } catch (Exception e) { StringBuilder strBuilder = new StringBuilder(); TestResult testResult = new TestResult(false); strBuilder.append("Reference to datasource ds: " + uuid + " couldn't be obtained "); strBuilder.append("\n"); strBuilder.append("Test Failed"); testResult.setMessage(strBuilder.toString()); return testResult; } }
public void onTestConnectionSuccess(TestResult response) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); if (response.isTestPassed()) { builder.appendEscapedLines( getMessage(DataSourceManagementConstants.DataSourceDefEditor_ConnectionTestSuccessfulMessage) + "\n"); } else { builder.appendEscapedLines( getMessage(DataSourceManagementConstants.DataSourceDefEditor_ConnectionTestFailedMessage) + "\n"); } builder.appendEscapedLines(response.getMessage()); popupsUtil.showInformationPopup(builder.toSafeHtml().asString()); }
private void testConnection(boolean isValid) { TestResult result = new TestResult(isValid); result.setMessage("Message"); when(editorService.testConnection(any(DataSourceDef.class))).thenReturn(result); when(translationService.getTranslation( DataSourceManagementConstants.DataSourceDefEditor_ConnectionTestFailedMessage)).thenReturn(ERROR); when(translationService.getTranslation( DataSourceManagementConstants.DataSourceDefEditor_ConnectionTestSuccessfulMessage)).thenReturn("OK"); editorHelper.onTestConnection(); if (isValid) { verify(popupsUtil, times(1)).showInformationPopup( new SafeHtmlBuilder().appendEscapedLines("OK" + "\n" + "Message").toSafeHtml().asString()); } else { verify(popupsUtil, times(1)).showInformationPopup( new SafeHtmlBuilder().appendEscapedLines(ERROR + "\n" + "Message").toSafeHtml().asString()); } } }
TestResult result = new TestResult(false); result.setMessage("A valid connection url is required"); return result; result.setMessage("A valid user and password are required"); return result; result.setMessage("A valid driver is required"); return result; result.setMessage("Data source driver: " + dataSourceDef.getUuid() + " was not found"); return result; driverDef.getVersion()); } catch (Exception e) { result.setMessage("Connection could not be tested due to the following error: " + e.getMessage()); return result; result.setMessage("Driver artifact: " + driverDef.getGroupId() + ":" + driverDef.getArtifactId() + ":" + driverDef.getVersion() + " was not found"); return result; result.setMessage("It was not possible to open connection"); } else { StringBuilder stringBuilder = new StringBuilder(); result.setTestPassed(true); result.setMessage(stringBuilder.toString());