package com.capgemini.reports.reports.parameters;

import com.capgemini.framework.common.TeamcenterDateFormatter;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Test;

import java.util.Calendar;


@Slf4j
public class TcEffectivityDateTest {


    private static final String DATE_USER_INPUT = "08-12-2014";
    private static final String DATE_USER_INPUT_EMPTY = "";


  @Test
    public void testEffectivityDateWithUserInput() {
        log.info("testEffectivityDateWithUserInputNotEmpty...");
        log.info("User Input: " + DATE_USER_INPUT);
        String formattedDate = TeamcenterDateFormatter.translateDateFormatForRequest(DATE_USER_INPUT);
        Calendar userInputDate = TeamcenterDateFormatter.makeTeamcenterCalendar(DATE_USER_INPUT);

        EffectivityDate effectivityDate = new EffectivityDate(userInputDate);

        Assert.assertFalse(effectivityDate.isNow());
        Assert.assertNotNull(effectivityDate.getDateTime());

        log.info("Expected object Calendar = {}", effectivityDate.getDateTime());
        log.info("Expected isNow = {}", effectivityDate.isNow());
        Assert.assertEquals(formattedDate, effectivityDate.getFormattedDateForTcRequest());

    }


  @Test
    public void testEffectivityDateWithoutUserInput() {
        log.info("testEffectivityDateWithUserInputNotEmpty...");
        log.info("User Input: " + DATE_USER_INPUT);

        EffectivityDate effectivityDate = new EffectivityDate();

        Assert.assertTrue(effectivityDate.isNow());
        Assert.assertNull(effectivityDate.getDateTime());

        log.info("Expected object Calendar = {}", effectivityDate.getDateTime());
        log.info("Expected isNow = {}", effectivityDate.isNow());
    }


  @Test
    public void testEffectivityDateWithEmptyUserInput() {
        log.info("testEffectivityDateWITHOUTUserInputNotEmpty...");
        log.info("USER INPUT {" + DATE_USER_INPUT_EMPTY + "} EMPTY");

        EffectivityDate effectivityDate = new EffectivityDate(DATE_USER_INPUT_EMPTY);

        Assert.assertTrue(effectivityDate.isNow());
        Assert.assertNull(effectivityDate.getDateTime());

        log.info("Expected object Calendar TODAY = {}", effectivityDate.getDateTime());
        log.info("Expected isNow = {}", effectivityDate.isNow());
    }


  @Test
    public void testIsNowTRUE() {
        log.info("testIsNowTRUE ....");
        EffectivityDate effectivityDate = new EffectivityDate();
        Assert.assertTrue(effectivityDate.isNow());
        log.info("Expected isNow = {}", effectivityDate.isNow());
    }

}
