package nl.fontys.sofa.limo.validation;

import org.junit.Test;
import static org.junit.Assert.*;

public class BeanValidatorTest {
    
    @Test
    public void testAssertTrueFalse() {
        BooleanBean bean = new BooleanBean();
        bean.trueValue = true;
        bean.falseValue = false;
         try {
            BeanValidator.validate(bean);
        } catch (ValidationException ex) {
            fail("BooleanBean should be valid.");
        }
        bean.trueValue = false;
        bean.falseValue = false;
        try {
            BeanValidator.validate(bean);
            fail("BooleanBean should be invalid.");
        } catch (ValidationException ex) {
            // good
        }
        bean.trueValue = true;
        bean.falseValue = true;
        try {
            BeanValidator.validate(bean);
            fail("BooleanBean should be invalid.");
        } catch (ValidationException ex) {
            // good
        }
    }
    
    @Test
    public void testDecimalMinMax() {
        DecimalBean bean = new DecimalBean();
        bean.minValue = 2;
        bean.maxValue = 5;
        try {
            BeanValidator.validate(bean);
        } catch (ValidationException ex) {
            fail("DecimalBean should be valid.");
        }
        bean.minValue = 0;
        bean.maxValue = 5;
        try {
            BeanValidator.validate(bean);
            fail("DecimalBean should be invalid.");
        } catch (ValidationException ex) {
            // good
        }
        bean.minValue = 1;
        bean.maxValue = 11;
        try {
            BeanValidator.validate(bean);
            fail("DecimalBean should be invalid.");
        } catch (ValidationException ex) {
            // good
        }
    }
    
    @Test
    public void testDigits() {
        
    }
    
    @Test
    public void testPastFuture() {
    
    }
    
    @Test
    public void testMinMax() {
    
    }
    
    @Test
    public void testNullNotNull() {
    
    }
    
    @Test
    public void testPattern() {
    
    }
    
    @Test
    public void testSize() {
    
    }
}

@@ -34,16 +34,93 @@
 ation;%0A%0A
+import java.sql.Date;%0Aimport java.time.LocalDate;%0Aimport java.util.Calendar;%0A
 import o
@@ -1851,84 +1851,1460 @@
 test
-Digits() %7B%0A        %0A    %7D%0A    %0A    @Test%0A    public void testPastFuture() %7B%0A
+PastFuture() %7B%0A        Calendar cal = Calendar.getInstance();%0A        DateBean bean = new DateBean();%0A        %0A        cal.setTime(Date.valueOf(LocalDate.now()));%0A        cal.add(Calendar.DATE, -30);%0A        bean.pastDate = cal.getTime();%0A        cal.setTime(Date.valueOf(LocalDate.now()));%0A        cal.add(Calendar.DATE, 30);%0A        bean.futureDate = cal.getTime();%0A        try %7B%0A            BeanValidator.validate(bean);%0A        %7D catch (ValidationException ex) %7B%0A            fail(%22DateBean should be valid.%22);%0A        %7D%0A        cal.setTime(Date.valueOf(LocalDate.now()));%0A        cal.add(Calendar.DATE, 30);%0A        bean.pastDate = cal.getTime();%0A        cal.setTime(Date.valueOf(LocalDate.now()));%0A        cal.add(Calendar.DATE, 30);%0A        bean.futureDate = cal.getTime();%0A         try %7B%0A            BeanValidator.validate(bean);%0A            fail(%22DateBean should be invalid.%22);%0A        %7D catch (ValidationException ex) %7B%0A            // good%0A        %7D%0A        cal.setTime(Date.valueOf(LocalDate.now()));%0A        cal.add(Calendar.DATE, -30);%0A        bean.pastDate = cal.getTime();%0A        cal.setTime(Date.valueOf(LocalDate.now()));%0A        cal.add(Calendar.DATE, -30);%0A        bean.futureDate = cal.getTime();%0A         try %7B%0A            BeanValidator.validate(bean);%0A            fail(%22DateBean should be invalid.%22);%0A        %7D catch (ValidationException ex) %7B%0A            // good%0A        %7D%0A    %7D%0A    %0A    @Test%0A    public void testDigits() %7B%0A    
     

implement test for 'Past' and 'Future' date validation