|
|
|
|
@ -2,12 +2,15 @@ package org.leolo.nrdatad;
|
|
|
|
|
import org.json.JSONObject; |
|
|
|
|
import org.junit.Test; |
|
|
|
|
import org.leolo.nrdatad.model.Corpus; |
|
|
|
|
import org.leolo.nrdatad.model.Smart; |
|
|
|
|
import org.leolo.nrdatad.model.SmartEvent; |
|
|
|
|
import org.leolo.nrdatad.model.SmartStepType; |
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.*; |
|
|
|
|
public class ReferenceDataParserTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testNormalCase1(){ |
|
|
|
|
public void testCorpusNormalCase1(){ |
|
|
|
|
String json = "{\"NLC\":\"535500\",\"STANOX\":\"87701\",\"TIPLOC\":\"ECROYDN\",\"3ALPHA\":\"ECR\",\"UIC\":\"53550\",\"NLCDESC\":\"EAST CROYDON\",\"NLCDESC16\":\"\"}"; |
|
|
|
|
Corpus corpus = Corpus.parseJSON(json); |
|
|
|
|
assertEquals("535500", corpus.getNlcCode()); |
|
|
|
|
@ -16,8 +19,10 @@ public class ReferenceDataParserTest {
|
|
|
|
|
assertEquals("ECR", corpus.getCrsCode()); |
|
|
|
|
assertEquals("53550", corpus.getUicCode()); |
|
|
|
|
assertEquals("EAST CROYDON", corpus.getLongDescription()); |
|
|
|
|
}@Test |
|
|
|
|
public void testNormalCase2(){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testCorpusNormalCase2(){ |
|
|
|
|
String json = "{\"NLC\":\"535500\",\"STANOX\":\"87701\",\"TIPLOC\":\"ECROYDN\",\"3ALPHA\":\"ECR\",\"UIC\":\"53550\",\"NLCDESC\":\"EAST CROYDON\",\"NLCDESC16\":\"\"}"; |
|
|
|
|
Corpus corpus = Corpus.parseJSON(new JSONObject(json)); |
|
|
|
|
assertEquals("535500", corpus.getNlcCode()); |
|
|
|
|
@ -27,5 +32,25 @@ public class ReferenceDataParserTest {
|
|
|
|
|
assertEquals("53550", corpus.getUicCode()); |
|
|
|
|
assertEquals("EAST CROYDON", corpus.getLongDescription()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testSmartNormalCase1(){ |
|
|
|
|
String json = "{\"STEPTYPE\":\"B\",\"FROMBERTH\":\"7910\",\"TOBERTH\":\"7904\",\"STANOX\":\"01125\",\"EVENT\":\"A\",\"PLATFORM\":\"1\"," + |
|
|
|
|
"\"TOLINE\":\"\",\"BERTHOFFSET\":\"+59\",\"ROUTE\":\"\",\"FROMLINE\":\"\",\"TD\":\"IH\",\"COMMENT\":\"02/12/2018\",\"STANME\":\"NAIRN\"}"; |
|
|
|
|
Smart smart = Smart.parseJSON(json); |
|
|
|
|
assertEquals(SmartStepType.BETWEEN, smart.getStepType()); |
|
|
|
|
assertEquals("7910", smart.getFromBerth()); |
|
|
|
|
assertEquals("7904", smart.getToBerth()); |
|
|
|
|
assertEquals("01125", smart.getStanox()); |
|
|
|
|
assertEquals(SmartEvent.ARRIVE_UP, smart.getEvent()); |
|
|
|
|
assertEquals("1", smart.getPlatform()); |
|
|
|
|
assertEquals("", smart.getToLine()); |
|
|
|
|
assertEquals(59, smart.getBerthOffset()); |
|
|
|
|
assertEquals("", smart.getRoute()); |
|
|
|
|
assertEquals("", smart.getFromLine()); |
|
|
|
|
assertEquals("IH", smart.getTd()); |
|
|
|
|
assertEquals("01/12/2018", smart.getComment()); |
|
|
|
|
assertEquals("NAIRN", smart.getStationName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|