@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; } }
stringBuilder.append("Test Failed"); testResult.setMessage(stringBuilder.toString()); return testResult;
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.setMessage(stringBuilder.toString()); result.setMessage(e.getMessage()); return result;
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()); } } }