package tmcsim.simulationmanager; import java.util.Vector; import static junit.framework.Assert.assertEquals; import junit.framework.TestCase; import org.uispec4j.*; import tmcsim.cadmodels.*; import tmcsim.client.cadclientgui.data.IncidentEvent; /** * * @author jdalbey */ public class IncidentHistoryPanelTest extends TestCase { public IncidentHistoryPanelTest(String testName) { super(testName); } @Override protected void setUp() throws Exception { super.setUp(); } /** * Test of updateIncidentHistory method, of class IncidentHistoryPanel. */ public void testUpdateIncidentHistory() { System.out.println("updateIncidentHistory"); IncidentHistoryPanel ihPanel = new IncidentHistoryPanel(); Panel inciPanel = new Panel(ihPanel); TextBox txtType = inciPanel.getTextBox("incTypeTF"); TextBox txtLoc = inciPanel.getTextBox("incLocTF"); // verify fields initially empty assertEquals("", txtType.getText()); assertEquals("", txtLoc.getText()); // Build an Incident to put in the log Vector dummy = new Vector(); IncidentInquiryHeader hdr = new IncidentInquiryHeader(); hdr.type = "1179"; hdr.fullLocation = "Computer Science Bldg"; IncidentInquiryModel_obj mo = new IncidentInquiryModel_obj(); mo.setHeader(hdr); IncidentInquiryDetails det = new IncidentInquiryDetails("1", "Happy Programmer", false); mo.addDetail(det); IncidentEvent event = new IncidentEvent(10, mo, "", 4, dummy, dummy); ihPanel.updateIncidentHistory(event); // After adding an event, verify fixed fields assertEquals("1179", txtType.getText()); assertEquals("Computer Science Bldg", txtLoc.getText()); // Verify first row of log history table Table evtLog = inciPanel.getTable("LogHistory"); // System.out.println(evtLog.toString()); assertEquals(1, evtLog.getJTable().getRowCount()); assertEquals("Script", evtLog.getContentAt(0, 0)); assertEquals("Happy Programmer", evtLog.getContentAt(0, 2)); } }