| 1 | |
|---|
| 2 | package tmcsim.cadsimulator; |
|---|
| 3 | |
|---|
| 4 | import java.rmi.RemoteException; |
|---|
| 5 | import java.util.List; |
|---|
| 6 | import java.util.Vector; |
|---|
| 7 | import junit.framework.TestCase; |
|---|
| 8 | import tmcsim.client.cadclientgui.data.Incident; |
|---|
| 9 | |
|---|
| 10 | /** |
|---|
| 11 | * |
|---|
| 12 | * @author jdalbey |
|---|
| 13 | */ |
|---|
| 14 | public class CoordinatorTest extends TestCase { |
|---|
| 15 | |
|---|
| 16 | public CoordinatorTest(String testName) { |
|---|
| 17 | super(testName); |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | @Override |
|---|
| 21 | protected void setUp() throws Exception { |
|---|
| 22 | super.setUp(); |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | @Override |
|---|
| 26 | protected void tearDown() throws Exception { |
|---|
| 27 | super.tearDown(); |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | public void testWriteToCADLog() throws RemoteException |
|---|
| 31 | { |
|---|
| 32 | System.out.println("testing write to CAD log"); |
|---|
| 33 | Coordinator coord = new Coordinator(null,"",""); |
|---|
| 34 | Vector<Incident> incList = new Vector<Incident>(); |
|---|
| 35 | Incident inci1 = new Incident(201, "Alpha", 10L); |
|---|
| 36 | Incident inci2 = new Incident(209, "Beta", 20L); |
|---|
| 37 | Incident inci3 = new Incident(205, "Charly", 20L); |
|---|
| 38 | Incident inci4 = new Incident(201, "Delta", 20L); |
|---|
| 39 | String[] fields1 = {"date","01:01:01","JHD","?","two"}; |
|---|
| 40 | String[] fields2 = {"date","00:01:01","JHD","?","one"}; |
|---|
| 41 | String[] fields3 = {"date","10:01:01","JHD","?","four"}; |
|---|
| 42 | String[] fields4 = {"date","03:01:01","JHD","?","three"}; |
|---|
| 43 | inci1.addToCommentsNotesTable(fields1); |
|---|
| 44 | inci2.addToCommentsNotesTable(fields2); |
|---|
| 45 | inci3.addToCommentsNotesTable(fields3); |
|---|
| 46 | inci4.addToCommentsNotesTable(fields4); |
|---|
| 47 | incList.add(inci1); |
|---|
| 48 | incList.add(inci2); |
|---|
| 49 | incList.add(inci3); |
|---|
| 50 | incList.add(inci4); |
|---|
| 51 | List<String> result = coord.getSortedComments(incList); |
|---|
| 52 | assertTrue(result != null); |
|---|
| 53 | assertTrue (result.get(0).startsWith("00")); |
|---|
| 54 | assertTrue (result.get(1).startsWith("01")); |
|---|
| 55 | assertTrue (result.get(2).startsWith("03")); |
|---|
| 56 | assertTrue (result.get(3).startsWith("10")); |
|---|
| 57 | } |
|---|
| 58 | public void testBadDataWriteToCADLog() throws RemoteException |
|---|
| 59 | { |
|---|
| 60 | System.out.println("test int conversion in write to CAD log"); |
|---|
| 61 | Coordinator coord = new Coordinator(null,"",""); |
|---|
| 62 | Vector<Incident> incList = new Vector<Incident>(); |
|---|
| 63 | Incident inci1 = new Incident(201, "Alpha", 10L); |
|---|
| 64 | Incident inci2 = new Incident(209, "Bravo", 20L); |
|---|
| 65 | Incident inci3 = new Incident(209, "Charly", 20L); |
|---|
| 66 | String[] fields1 = {"date","01:01:01","JHD","?","two"}; |
|---|
| 67 | String[] fields2 = {"date","99999999209","JHD","?","one"}; |
|---|
| 68 | String[] fields3 = {"date","INVALID","JHD","?","one"}; |
|---|
| 69 | inci1.addToCommentsNotesTable(fields1); |
|---|
| 70 | inci2.addToCommentsNotesTable(fields2); |
|---|
| 71 | inci2.addToCommentsNotesTable(fields3); |
|---|
| 72 | incList.add(inci1); |
|---|
| 73 | incList.add(inci2); |
|---|
| 74 | incList.add(inci3); |
|---|
| 75 | List<String> result = coord.getSortedComments(incList); |
|---|
| 76 | assertTrue(result != null); |
|---|
| 77 | assertTrue (result.get(0).startsWith("INVALID")); |
|---|
| 78 | assertTrue (result.get(1).startsWith("01")); |
|---|
| 79 | assertTrue (result.get(2).startsWith("99")); |
|---|
| 80 | } |
|---|
| 81 | } |
|---|