package com.atlassian.bitbucket.validation;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;


public class OptionalStringValidatorTest {

    private OptionalStringValidator validator;
    
    @Before
    public void createValidator() {
        validator = new OptionalStringValidator();
    }
    
    @Test
    public void testIsValid() throws Exception {
        assertTrue(validator.isValid("value", null));
    }

    @Test
    public void testNullIsValid() throws Exception {
        assertTrue(validator.isValid(null, null));
    }

    @Test
    public void testEmptyIsNotValid() throws Exception {
        assertFalse(validator.isValid("", null));
    }

    @Test
    public void testBlankIsNotValid() throws Exception {
        assertFalse(validator.isValid(" ", null));
    }

}
