Package br.com.six2six.fixturefactory.function

Source Code of br.com.six2six.fixturefactory.function.DateTimeFunctionTest

package br.com.six2six.fixturefactory.function;

import static br.com.six2six.fixturefactory.util.DateTimeUtils.toCalendar;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import org.junit.Test;

import br.com.six2six.fixturefactory.function.impl.DateTimeFunction;
import br.com.six2six.fixturefactory.function.impl.DateTimeFunction.DateType;

public class DateTimeFunctionTest {

  private static DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
 
  @Test
  public void afterDate() {
    String source = "2011-04-07";
    Calendar value = new DateTimeFunction(toCalendar(source, format), DateType.AFTER).generateValue();
    assertNotNull("Generated date can not be null", value);
    assertTrue(String.format("Generated date is not after %s", source), value.after(toCalendar(source, format)));
  }

  @Test
  public void beforeDate() {
    String source = "2011-04-07";
    Calendar value = new DateTimeFunction(toCalendar(source, format), DateType.BEFORE).generateValue();
    assertNotNull("Generated date can not be null", value);
    assertTrue(String.format("Generated date is not before %s", source), value.before(toCalendar(source, format)));
  }
  @Test
  public void randomDate() {
    String start = "2011-04-01", end = "2011-04-30";
    Calendar value = new DateTimeFunction(toCalendar(start, format), toCalendar(end, format)).generateValue();
    assertNotNull("Generated date can not be null", value);
    assertTrue(String.format("Generated date is not between %s and %s", start, end), toCalendar(start, format).before(value) && value.before(toCalendar(end, format)));
  }
 
}
TOP

Related Classes of br.com.six2six.fixturefactory.function.DateTimeFunctionTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.