Search in sources :

Example 16 with ValidationBean

use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.

the class LengthValidatorTest method shouldReturnValidWhenEmptyInput.

@Test
public void shouldReturnValidWhenEmptyInput() {
    LengthValidator lengthValidator = new LengthValidator(2);
    ValidationBean validationBean = lengthValidator.validate("");
    assertThat(validationBean.isValid(), is(true));
}
Also used : ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Example 17 with ValidationBean

use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.

the class PipelineGroupValidatorTest method shouldRejectWhiteSpace.

@Test
public void shouldRejectWhiteSpace() {
    ValidationBean validationBean = Validator.PIPELINEGROUP.validate("pipeline GroupName");
    assertThat(validationBean.isValid(), is(false));
    assertThat(validationBean.getError(), Is.is(PipelineGroupValidator.ERRORR_MESSAGE));
}
Also used : ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Example 18 with ValidationBean

use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.

the class PresenceValidatorTest method shouldNotRenderErrorWhenStringIsNotBlank.

@Test
public void shouldNotRenderErrorWhenStringIsNotBlank() throws Exception {
    ValidationBean validation = new PresenceValidator("String must be non-blank").validate("foo");
    assertThat(validation.isValid(), is(true));
}
Also used : ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Example 19 with ValidationBean

use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.

the class BackgroundEmailSenderTest method shouldReturnNotValidIfSendingTimesout.

@Test
public void shouldReturnNotValidIfSendingTimesout() {
    BackgroundMailSender background = new BackgroundMailSender(neverReturns, 1);
    ValidationBean validationBean = background.send("Subject", "body", "to@someone");
    assertThat(validationBean.isValid(), is(false));
    assertThat(validationBean.getError(), containsString("Failed to send an email. Please check the GoCD server logs for any extra information that might be present."));
}
Also used : ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Example 20 with ValidationBean

use of com.thoughtworks.go.domain.materials.ValidationBean in project gocd by gocd.

the class GoSmtpMailSenderTest method shouldNotSendTestEmailToSmtpServerIfTlsConfiguredIncorrect.

@Test
public void shouldNotSendTestEmailToSmtpServerIfTlsConfiguredIncorrect() {
    GoSmtpMailSender sender = new GoSmtpMailSender(hostName, 25, username, password, true, from, to);
    ValidationBean bean = sender.send(subject, body, to);
    assertThat(bean, is(not(ValidationBean.valid())));
}
Also used : ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Aggregations

ValidationBean (com.thoughtworks.go.domain.materials.ValidationBean)25 Test (org.junit.Test)22 TestSubprocessExecutionContext (com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext)2 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)1 GoMailSender (com.thoughtworks.go.config.GoMailSender)1 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)1 Expectations (org.jmock.Expectations)1 Theory (org.junit.experimental.theories.Theory)1