package uk.ac.ebi.quickgo.client.presets.read.assignedby;

import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.item.validator.ValidationException;

/**
 * Created 05/09/16
 * @author Edd
 */
public class RawAssignedByPresetValidatorTest {
    private RawAssignedByPresetValidator validator;

    @Before
    public void setUp() {
        this.validator = new RawAssignedByPresetValidator();
    }

    @Test(expected = ValidationException.class)
    public void nullRawPresetIsInvalid() throws Exception {
        validator.process(null);
    }

    @Test(expected = ValidationException.class)
    public void nullNameIsInvalid() throws Exception {
        RawAssignedByPreset value = new RawAssignedByPreset();
        value.name = null;
        validator.process(value);
    }

    @Test(expected = ValidationException.class)
    public void emptyNameIsInvalid() throws Exception {
        RawAssignedByPreset value = new RawAssignedByPreset();
        value.name = "";
        validator.process(value);
    }
}
@@ -170,16 +170,162 @@
 ption;%0A%0A
+import static org.hamcrest.MatcherAssert.assertThat;%0Aimport static org.hamcrest.core.Is.is;%0Aimport static org.hamcrest.core.IsNull.notNullValue;%0A%0A
 /**%0A * C
@@ -1179,10 +1179,310 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void nonEmptyNameIsValid() throws Exception %7B%0A        RawAssignedByPreset value = new RawAssignedByPreset();%0A        value.name = %22valid name%22;%0A%0A        RawAssignedByPreset processedValue = validator.process(value);%0A        assertThat(processedValue, is(notNullValue()));%0A    %7D
 %0A%7D

test for non-null/empty name