/*
 * Copyright (c) 2005, Rob Gordon.
 */
package org.treesched.schedules;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.treesched.Interval;

import junit.framework.TestCase;

/**
 *
 * @author Rob Gordon.
 */
public class AfterScheduleTest extends TestCase {

    static DateFormat checkFormat = new SimpleDateFormat("dd-MMM-yy HH:mm:ss:SSS");
    static DateFormat inputFormat = new SimpleDateFormat("dd-MMM-yy HH:mm");
    
    public void testAfterInterval() throws ParseException {
        AfterSchedule after = new AfterSchedule();
        IntervalSchedule interval = new IntervalSchedule();
        interval.setInterval("00:10");
        after.addChildSchedule(interval);

        Date from = inputFormat.parse("01-jan-00 12:00");
        Interval next = after.nextDue(from);
        assertEquals("Expected start", 
                checkFormat.parse("01-jan-00 12:10:00:000"),
                next.getFromDate());
        assertEquals("Expected end", 
                checkFormat.parse("01-jan-00 12:10:00:000"),
                next.getToDate());
    }
}
