package edu.northwestern.bioinformatics.studycalendar.web.schedule;

import edu.northwestern.bioinformatics.studycalendar.service.StudyService;
import edu.northwestern.bioinformatics.studycalendar.testing.StudyCalendarTestCase;
import gov.nih.nci.cabig.ctms.lang.DateTools;
import gov.nih.nci.cabig.ctms.lang.NowFactory;
import static org.easymock.EasyMock.expect;

import java.util.Calendar;

public class ScheduleReconsentCommandTest extends StudyCalendarTestCase {
    private ScheduleReconsentCommand command;
    private StudyService studyService;
    private NowFactory nowFactory;

    protected void setUp() throws Exception {
        super.setUp();
        studyService = registerMockFor(StudyService.class);
        nowFactory = registerMockFor(NowFactory.class);
        command = new ScheduleReconsentCommand(studyService, nowFactory);
    }

    public void testValidate() throws Exception {
        command.setStartDate(DateTools.createTimestamp(2005, Calendar.AUGUST, 3));

        expect(nowFactory.getNow()).andReturn(DateTools.createDate(2007, Calendar.AUGUST, 3)).times(2);
        replayMocks();
        command.validate(null);
        verifyMocks();
        assertSameDay("Expected Date different than actual", DateTools.createDate(2007, Calendar.AUGUST, 3), command.getStartDate());
    }
}

@@ -357,16 +357,115 @@
 .expect;
+%0Aimport org.springframework.validation.Errors;%0Aimport org.springframework.validation.BindException;
 %0A%0Aimport
@@ -989,32 +989,104 @@
 ows Exception %7B%0A
+        BindException errors = new BindException(command, %22startDate%22);%0A
         command.
@@ -1152,17 +1152,16 @@
 T, 3));%0A
-%0A
         
@@ -1249,17 +1249,8 @@
  3))
-.times(2)
 ;%0A  
@@ -1262,32 +1262,33 @@
  replayMocks();%0A
+%0A
         command.
@@ -1300,12 +1300,14 @@
 ate(
-null
+errors
 );%0A 
@@ -1324,24 +1324,25 @@
 ifyMocks();%0A
+%0A
         asse
@@ -1347,122 +1347,74 @@
 sert
-SameDay(%22Expected Date different than actual%22, DateTools.createDate(2007, Calendar.AUGUST, 3), command.getStartDat
+Equals(%22There should be one error: %22, 1, errors.getAllErrors().siz
 e())

Fix broken test.. was testing the old way of validation of the reconsent command.