Fixed toString Test and added getRoute Test
This commit is contained in:
@@ -268,6 +268,9 @@ public class Route {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public RoutePath getRoutePath(){
|
public RoutePath getRoutePath(){
|
||||||
|
if (getSourceAirport() == null || getDestinationAirport() == null){
|
||||||
|
return new RoutePath();
|
||||||
|
}
|
||||||
if (routePath == null) {
|
if (routePath == null) {
|
||||||
routePath = new RoutePath(
|
routePath = new RoutePath(
|
||||||
new Position(getSourceAirport().getLatitude(), getSourceAirport().getLongitude()),
|
new Position(getSourceAirport().getLatitude(), getSourceAirport().getLongitude()),
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import seng202.group9.Controller.DataException;
|
|||||||
import seng202.group9.Core.Airline;
|
import seng202.group9.Core.Airline;
|
||||||
import seng202.group9.Core.Airport;
|
import seng202.group9.Core.Airport;
|
||||||
import seng202.group9.Core.Route;
|
import seng202.group9.Core.Route;
|
||||||
|
import seng202.group9.Core.RoutePath;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -143,6 +144,25 @@ public class RouteTest{
|
|||||||
route.hasDuplicate(route1);
|
route.hasDuplicate(route1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPath(){
|
||||||
|
//sample entry
|
||||||
|
//BA,1355,SIN,3316,LHR,507,,0,744 777
|
||||||
|
//airline, airline ID (This is not parsed as this will be different
|
||||||
|
//from our database id for this route), source Aiport, source Airport ID (not parsed),
|
||||||
|
//destination airport, destination ID (not parsed), Codeshare, stops, Equipment
|
||||||
|
//should only be a duplicate if every entry is the same
|
||||||
|
Route route = new Route("BA", "SIN", "LHR", "", 0, "744 777");
|
||||||
|
Airport sourceAirport = new Airport(3316,"Changi Intl","Singapore","Singapore","SIN","WSSS",1.350189,103.994433,22);
|
||||||
|
Airport destAirport = new Airport(507,"Heathrow","London","United Kingdom","LHR","EGLL",51.4775,-0.461389,83);
|
||||||
|
assertTrue(route.getRoutePath().getRoute().size() == 0);
|
||||||
|
route.setSourceAirport(sourceAirport);
|
||||||
|
assertTrue(route.getRoutePath().getRoute().size() == 0);
|
||||||
|
route.setDestinationAirport(destAirport);
|
||||||
|
assertTrue(route.getRoutePath().getRoute().size() == 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testToString() {
|
public void testToString() {
|
||||||
//sample entry
|
//sample entry
|
||||||
//BA,1355,SIN,3316,LHR,507,,0,744 777
|
//BA,1355,SIN,3316,LHR,507,,0,744 777
|
||||||
@@ -151,6 +171,6 @@ public class RouteTest{
|
|||||||
//destination airport, destination ID (not parsed), Codeshare, stops, Equipment
|
//destination airport, destination ID (not parsed), Codeshare, stops, Equipment
|
||||||
//should only be a duplicate if every entry is the same
|
//should only be a duplicate if every entry is the same
|
||||||
Route route = new Route("BA", "SIN", "LHR", "", 0, "744 777");
|
Route route = new Route("BA", "SIN", "LHR", "", 0, "744 777");
|
||||||
assertEquals(route.toString(), "BA files from SIN to LHR on a 744 777 stopping 0 amount of times");
|
assertEquals(route.toString(), "BA flies from SIN to LHR on a 744 777 stopping 0 amount of times");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user