public ValidationBean handleException(Exception e, String gitVersionConsoleOut) { ValidationBean defaultResponse = ValidationBean.notValid(e.getMessage()); try { if (!isVersionOnedotSixOrHigher(gitVersionConsoleOut)) { return ValidationBean.notValid(ERR_GIT_OLD_VERSION + gitVersionConsoleOut); } else { return defaultResponse; } } catch (Exception ex) { return defaultResponse; } }
private ValidationBean execute(Runnable action) { Thread thread = new Thread(action); thread.start(); try { thread.join(timeout); if (thread.isAlive()) { thread.interrupt(); return ValidationBean.notValid(ERROR_MESSAGE); } return validation; } catch (InterruptedException e) { LOGGER.error("Timed out when sending an email. Please check email configuration."); return ValidationBean.notValid(ERROR_MESSAGE); } }
@Override public ValidationBean validate(String value) { if (StringUtils.isBlank(value)){ return ValidationBean.notValid(errorMessage); } else { return ValidationBean.valid(); } } }
ValidationBean handleException(Exception e, String hgVersionConsoleOut) { ValidationBean defaultResponse = ValidationBean.notValid( "Repository " + url.forDisplay() + " not found!" + " : \n" + e.getMessage()); try { boolean olderThanHg10 = !isVersionOnedotZeorOrHigher(hgVersionConsoleOut); if (olderThanHg10) { return ValidationBean.notValid(ERROR_OLD_VERSION + hgVersionConsoleOut); } else { return defaultResponse; } } catch (Exception e1) { LOGGER.debug("Problem validating HG", e); return defaultResponse; } }
public ValidationBean validate(String pipelineGroupName) { if (StringUtils.isEmpty(pipelineGroupName)) { return ValidationBean.valid(); } boolean valid = pipelineGroupName.matches(NAME_PATTERN); return valid ? ValidationBean.valid() : ValidationBean.notValid(ERRORR_MESSAGE); } }
public ValidationBean validate(String value) { if (StringUtils.isEmpty(value)) { return ValidationBean.valid(); } if (value.length() <= length) { return ValidationBean.valid(); } else { return ValidationBean.notValid(errorMessage); } } }
public ValidationBean validate(String address) { if(StringUtils.isBlank(address)){ return ValidationBean.valid(); } if (address.matches(".*@" + HostnameValidator.HOSTNAME_PATTERN)) { return ValidationBean.valid(); } return ValidationBean.notValid(EMAIL_ERROR_MESSAGE); } }
public ValidationBean validate(String hostname) { if (hostname.matches(HOSTNAME_PATTERN)) { return ValidationBean.valid(); } if (hostname.matches(IPV6_ADDRESS_PATTERN)) { return ValidationBean.valid(); } return ValidationBean.notValid(errorMessage); } }
public ValidationBean checkConnection(final SubprocessExecutionContext execCtx) { try { tfs(execCtx).checkConnection(); return ValidationBean.valid(); } catch (Exception e) { LOGGER.error("[TFS] Error during check connection", e); return ValidationBean.notValid(e.getMessage()); } }
public ValidationBean checkConnection() { CommandLine command = buildSvnLogCommandForLatestOne(); try { executeCommand(command); return ValidationBean.valid(); } catch (Exception e) { try { version(); LOG.error("failed to connect to {}", getUrlForDisplay(), e); return ValidationBean.notValid("svn: Malformed URL " + getUrlForDisplay() + " : \n" + e.getMessage()); } catch (Exception exp) { return ValidationBean.notValid(ERR_SVN_NOT_FOUND); } } }
public ValidationBean checkConnection(final SubprocessExecutionContext execCtx) { File baseDir = new TempFiles().createUniqueFolder("for-p4"); try { getP4(baseDir).checkConnection(); return ValidationBean.valid(); } catch (Exception e) { return ValidationBean.notValid("Unable to connect to server " + serverAndPort + " : \n" + e.getMessage()); } finally{ FileUtils.deleteQuietly(baseDir); } }
/** * This is a straight test of what is already there. * We are NOT sure that this is the correct behaviour. * We think it was there for SVNKIT and can now be removed. */ @Test public void shouldStripOutExceptionText() { assertThat( ValidationBean.notValid(new Exception("SVNKITException: The actual message")).getError(), is("The actual message") ); }
@Test public void shouldBeInvalidIfMessageIsNotEmpty() { assertThat(ValidationBean.notValid("With a message").isValid(), is(false)); }
public ValidationBean checkConnection(final SubprocessExecutionContext execCtx) { HgCommand hgCommand = new HgCommand(null, null, null, null, secrets()); try { hgCommand.checkConnection(url); return ValidationBean.valid(); } catch (Exception e) { String message = null; try { message = hgCommand.version(); return handleException(e, message); } catch (Exception ex) { return ValidationBean.notValid(ERR_NO_HG_INSTALLED); } } }
public ValidationBean checkConnection(final SubprocessExecutionContext execCtx) { GitCommand gitCommand = new GitCommand(null, null, null, false, null, secrets()); try { gitCommand.checkConnection(url, branch, execCtx.getDefaultEnvironmentVariables()); return ValidationBean.valid(); } catch (Exception e) { try { return handleException(e, gitCommand.version(execCtx.getDefaultEnvironmentVariables())); } catch (Exception notInstallGitException) { return ValidationBean.notValid(ERR_GIT_NOT_FOUND); } } }
@Test public void shouldBeAbleToSerializeToJson() { ValidationBean bean = ValidationBean.notValid("ErrorMessage"); String output = render(bean); assertThatJson(output).isEqualTo("{ \"isValid\": \"false\",\"error\": \"ErrorMessage\" }"); } }