package gov.nih.nci.cabig.caaers.web.ae;

import gov.nih.nci.cabig.caaers.service.EvaluationService;
import gov.nih.nci.cabig.caaers.service.ReportSubmittability;
import gov.nih.nci.cabig.caaers.domain.report.Report;
import gov.nih.nci.cabig.caaers.domain.Fixtures;
import static org.easymock.classextension.EasyMock.*;

import java.util.Map;

/**
 * @author Rhett Sutphin
 */
public class ViewReportTabTest extends AeTabTestCase {
    private EvaluationService evaluationService;
    private Report report17;
    private Report report23;

    @Override
    protected void setUp() throws Exception {
        evaluationService = registerMockFor(EvaluationService.class);

        report17 = Fixtures.setId(17, new Report());
        report23 = Fixtures.setId(23, new Report());

        super.setUp();

        command.getAeReport().addReport(report17);
        command.getAeReport().addReport(report23);
    }

    @Override
    protected AeTab createTab() {
        ViewReportTab tab = new ViewReportTab();
        tab.setEvaluationService(evaluationService);
        return tab;
    }

    @SuppressWarnings({ "unchecked" })
    public void testRefdataIncludesPerReportErrors() throws Exception {
        ReportSubmittability r17Messages = new ReportSubmittability();
        ReportSubmittability r23Messages = new ReportSubmittability();
        r23Messages.addMissingField("Terrible, terrible", "75");

        expect(evaluationService.isSubmittable(report17)).andReturn(r17Messages);
        expect(evaluationService.isSubmittable(report23)).andReturn(r23Messages);

        replayMocks();
        Map<String,Object> refdata = getTab().referenceData(command);
        verifyMocks();

        assertTrue("Report messages map not present", refdata.containsKey("reportMessages"));
        assertTrue("Report messages map not a Map", refdata.get("reportMessages") instanceof Map);
        Map<Integer, ReportSubmittability> actual
            = (Map<Integer, ReportSubmittability>) refdata.get("reportMessages");
        assertEquals("Should be one message collection per report",
            command.getAeReport().getReports().size(), actual.size());
        assertSame(actual.get(17), r17Messages);
        assertSame(actual.get(23), r23Messages);
    }
}

@@ -259,16 +259,95 @@
 xtures;%0A
+import gov.nih.nci.cabig.caaers.domain.expeditedfields.ExpeditedReportSection;%0A
 import s
@@ -1449,16 +1449,55 @@
 ngField(
+ExpeditedReportSection.BASICS_SECTION, 
 %22Terribl

Correct uncompilable test