@Override public ValidationBean checkConnection(GitMaterial material, SubprocessExecutionContext executionContext) { return ValidationBean.valid(); } }
@Override public ValidationBean validate(String value) { if (StringUtils.isBlank(value)){ return ValidationBean.notValid(errorMessage); } else { return ValidationBean.valid(); } } }
public ValidationBean validate(String port) { try { if (Integer.valueOf(port) <= 0 || Integer.valueOf(port) > 65535) { return ValidationBean.notValid(ERROR_MESSAGE); } } catch (NumberFormatException e) { return ValidationBean.notValid(ERROR_MESSAGE); } return ValidationBean.valid(); } }
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(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); } }
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); } } }
@Test public void shouldCheckConnection() { TestSubprocessExecutionContext execCtx = new TestSubprocessExecutionContext(); TfsCommand tfsCommand = mock(TfsCommand.class); doNothing().when(tfsCommand).checkConnection(); TfsMaterial spy = spy(tfsMaterialFirstCollectionFirstProject); doReturn(tfsCommand).when(spy).tfs(execCtx); assertThat(spy.checkConnection(execCtx), is(valid())); verify(tfsCommand, times(1)).checkConnection(); }
public ValidationBean send(String subject, String body, String to) { Transport transport = null; try { LOGGER.debug("Sending email [{}] to [{}]", subject, to); Properties props = mailProperties(); MailSession session = MailSession.getInstance().createWith(props, username, password); transport = session.getTransport(); transport.connect(host, port, nullIfEmpty(username), nullIfEmpty(password)); MimeMessage msg = session.createMessage(from, to, subject, body); transport.sendMessage(msg, msg.getRecipients(TO)); return ValidationBean.valid(); } catch (Exception e) { LOGGER.error("Sending failed for email [{}] to [{}]", subject, to, e); return ValidationBean.notValid(ERROR_MESSAGE); } finally { if (transport != null) { try { transport.close(); } catch (MessagingException e) { LOGGER.error("Failed to close transport", e); } } } }
@Test public void shouldCheckValidationForEmailAddress() throws Exception { assertThat(validate("some@here.com"), Matchers.is(ValidationBean.valid())); }
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); } } }