package com.capgemini.reports.reports.parameters.checker;

import com.capgemini.reports.exceptions.InvalidUserInputException;
import com.capgemini.reports.reports.parameters.EffectivityDate;
import org.junit.Test;

import java.util.Calendar;


public class TcEffectivityCheckerTest {

    /**
     * JUnit test.
     * 
     * @throws InvalidUserInputException should not happen
     */
    @Test
    public void checkSuccess() throws InvalidUserInputException {
        // Check for 'now' : should not throw an exception
        EffectivityDate now = new EffectivityDate();
        new EffectivityChecker(now).check(null); // no need for a session

        // Check for a date in the past: should not throw an exception
        Calendar fiveDaysAgo = Calendar.getInstance();
        fiveDaysAgo.add(Calendar.DAY_OF_MONTH, -5);
        new EffectivityChecker(new EffectivityDate(fiveDaysAgo)).check(null);
    }

    /**
     * JUnit test.
     * 
     * @throws InvalidUserInputException should not happen
     */
    public void checkNullDateNotNow() throws InvalidUserInputException {
        // Give no or null input, still obtain a valid date representing the current date
        new EffectivityChecker(new EffectivityDate()).check(null);
        new EffectivityChecker(new EffectivityDate((String) null)).check(null);
        new EffectivityChecker(new EffectivityDate((Calendar) null)).check(null);
    }

}
