use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.
the class GoSmtpMailSenderTest method shouldSendAMailWhenValidationSucceeds.
@Test
public void shouldSendAMailWhenValidationSucceeds() throws Exception {
FakeMailSession mailSession = FakeMailSession.setupFor(username, password, from, to, subject, body);
GoSmtpMailSender sender = new GoSmtpMailSender(hostName, port, username, password, true, from, to);
ValidationBean bean = sender.send(subject, body, to);
assertThat(bean, is(ValidationBean.valid()));
mailSession.verifyThatConnectionWasMadeTo(hostName, port, username, password);
mailSession.verifyMessageWasSent();
mailSession.verifyTransportWasClosed();
}
use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.
the class GoSmtpMailSenderTest method shouldSetProtocolToSMTPSWhenSMTPSIsEnabled.
@Test
public void shouldSetProtocolToSMTPSWhenSMTPSIsEnabled() throws Exception {
FakeMailSession mailSession = FakeMailSession.setupFor(username, password, from, to, subject, body);
boolean isSMTPSEnabled = true;
GoSmtpMailSender sender = new GoSmtpMailSender(hostName, port, username, password, isSMTPSEnabled, from, to);
ValidationBean bean = sender.send(subject, body, to);
assertThat(bean, is(ValidationBean.valid()));
mailSession.verifyMessageWasSent();
mailSession.verifyProperty(MAIL_TRANSPORT_PROTOCOL_PROPERTY, "smtps");
}
use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.
the class P4MaterialTestBase method shouldValidateCorrectConnection.
@Test
public void shouldValidateCorrectConnection() throws Exception {
P4Material p4Material = p4Fixture.material(VIEW);
p4Material.setPassword("secret");
p4Material.setUseTickets(false);
ValidationBean validation = p4Material.checkConnection(new TestSubprocessExecutionContext());
assertThat(validation.isValid(), is(true));
assertThat(StringUtils.isBlank(validation.getError()), is(true));
}
use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.
the class EmailNotificationListener method onMessage.
public void onMessage(SendEmailMessage message) {
CruiseConfig cruiseConfig = goConfigService.currentCruiseConfig();
if (!cruiseConfig.isMailHostConfigured()) {
return;
}
GoMailSender mailSender = factory.createSender();
ValidationBean validationBean = mailSender.send(message.getSubject(), message.getBody(), message.getTo());
if (!validationBean.isValid()) {
LOGGER.error(validationBean.getError());
}
}
use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.
the class MaterialConnectivityServiceTest method shouldCheckConnections.
@Theory
public void shouldCheckConnections(RequestDataPoints dataPoints) throws Exception {
MaterialConfig config = dataPoints.material.config();
MaterialConnectivityService spy = spy(service);
doReturn(dataPoints.klass).when(spy).getMaterialClass(dataPoints.material);
doReturn(dataPoints.material).when(materialConfigConverter).toMaterial(config);
ValidationBean actual = spy.checkConnection(config, executionContext);
assertThat(actual, is(dataPoints.expectedResult));
}
Aggregations