Search in sources :

Example 1 with ValidationBean

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

the class P4MaterialTestBase method shouldCheckConnection.

@Test
public void shouldCheckConnection() throws Exception {
    P4Material p4Material = new P4Material("localhost:9876", "p4view");
    p4Material.setPassword("secret");
    p4Material.setUseTickets(false);
    ValidationBean validation = p4Material.checkConnection(new TestSubprocessExecutionContext());
    assertThat(validation.isValid(), is(false));
    assertThat(validation.getError(), containsString("Unable to connect to server localhost:9876"));
    assertThat(validation.getError(), not(containsString("secret")));
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Example 2 with ValidationBean

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

the class PresenceValidatorTest method shouldRenderErrorWhenStringIsBlank.

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

Example 3 with ValidationBean

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

the class LengthValidatorTest method shouldReturnInvalidWhenLengthExceeds.

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

Example 4 with ValidationBean

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

the class PipelineGroupValidatorTest method shouldValidateNormalPipelineGroupName.

@Test
public void shouldValidateNormalPipelineGroupName() {
    ValidationBean validationBean = Validator.PIPELINEGROUP.validate("pipelineGroupName");
    assertThat(validationBean.isValid(), is(true));
}
Also used : ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Example 5 with ValidationBean

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

the class PipelineGroupValidatorTest method shouldRejectEmptyPipelineGroup.

@Test
public void shouldRejectEmptyPipelineGroup() {
    ValidationBean validationBean = Validator.PIPELINEGROUP.validate(null);
    assertThat(validationBean.isValid(), is(true));
}
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