2 changed files with 94 additions and 0 deletions
@ -0,0 +1,75 @@ |
|||||||
|
package org.leolo.nrdatad.model; |
||||||
|
|
||||||
|
import org.json.JSONObject; |
||||||
|
|
||||||
|
public class Tiploc { |
||||||
|
private String tiplocCode; |
||||||
|
private String nalco; |
||||||
|
private String stanox; |
||||||
|
private String description; |
||||||
|
private String tpsDescription; |
||||||
|
private String crsCode; |
||||||
|
|
||||||
|
public String getTiplocCode() { |
||||||
|
return tiplocCode; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTiplocCode(String tiplocCode) { |
||||||
|
this.tiplocCode = tiplocCode; |
||||||
|
} |
||||||
|
|
||||||
|
public String getNalco() { |
||||||
|
return nalco; |
||||||
|
} |
||||||
|
|
||||||
|
public void setNalco(String nalco) { |
||||||
|
this.nalco = nalco; |
||||||
|
} |
||||||
|
|
||||||
|
public String getStanox() { |
||||||
|
return stanox; |
||||||
|
} |
||||||
|
|
||||||
|
public void setStanox(String stanox) { |
||||||
|
this.stanox = stanox; |
||||||
|
} |
||||||
|
|
||||||
|
public String getDescription() { |
||||||
|
return description; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDescription(String description) { |
||||||
|
this.description = description; |
||||||
|
} |
||||||
|
|
||||||
|
public String getTpsDescription() { |
||||||
|
return tpsDescription; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTpsDescription(String tpsDescription) { |
||||||
|
this.tpsDescription = tpsDescription; |
||||||
|
} |
||||||
|
|
||||||
|
public String getCrsCode() { |
||||||
|
return crsCode; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCrsCode(String crsCode) { |
||||||
|
this.crsCode = crsCode; |
||||||
|
} |
||||||
|
|
||||||
|
public static Tiploc parseJSON(String json){ |
||||||
|
return parseJSON(new JSONObject(json)); |
||||||
|
} |
||||||
|
|
||||||
|
public static Tiploc parseJSON(JSONObject obj){ |
||||||
|
Tiploc tiploc = new Tiploc(); |
||||||
|
tiploc.tpsDescription = obj.optString("tps_description"); |
||||||
|
tiploc.crsCode = obj.optString("crs_code"); |
||||||
|
tiploc.description = obj.optString("description"); |
||||||
|
tiploc.stanox = obj.optString("stanox"); |
||||||
|
tiploc.tiplocCode = obj.optString("tiploc_code"); |
||||||
|
tiploc.nalco = obj.optString("nalco"); |
||||||
|
return tiploc; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package org.leolo.nrdatad.model; |
||||||
|
|
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
import static org.junit.Assert.*; |
||||||
|
|
||||||
|
public class TiplocTest { |
||||||
|
@Test public void basicTest(){ |
||||||
|
String json = "{\"tps_description\":\"ABERDEEN\",\"crs_code\":\"ABD\",\"description\":\"ABERDEEN\"," + |
||||||
|
"\"stanox\":\"02071\",\"tiploc_code\":\"ABRDEEN\",\"transaction_type\":\"Create\",\"nalco\":\"897600\"}"; |
||||||
|
Tiploc tiploc = Tiploc.parseJSON(json); |
||||||
|
assertEquals("ABERDEEN", tiploc.getTpsDescription()); |
||||||
|
assertEquals("ABD", tiploc.getCrsCode()); |
||||||
|
assertEquals("ABERDEEN", tiploc.getDescription()); |
||||||
|
assertEquals("02071", tiploc.getStanox()); |
||||||
|
assertEquals("ABRDEEN", tiploc.getTiplocCode()); |
||||||
|
assertEquals("897600", tiploc.getNalco()); |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue