Parsers, Core Files and Dataset Controllers
This commit is contained in:
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import seng202.group9.Controller.DataException;
|
||||
import seng202.group9.Core.Airline;
|
||||
import seng202.group9.Core.Route;
|
||||
|
||||
@@ -45,8 +46,12 @@ public class AirlineTest extends TestCase {
|
||||
Airline allNipponAirways = new Airline(324, "All Nippon Airways", "ANA All Nippon Airways",
|
||||
"NH", "ANA", "ALL NIPPON", "Japan", "Y");
|
||||
//check constructor
|
||||
assertTrue(allNipponAirways.getID() == 324); //test id
|
||||
assertTrue(allNipponAirways.getName() == "All Nippon Airways");//test name
|
||||
try {
|
||||
assertTrue(allNipponAirways.getID() == 324); //test id
|
||||
} catch (DataException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertTrue(allNipponAirways.getName() == "All Nippon Airways");//test name
|
||||
assertTrue(allNipponAirways.getAlias() == "ANA All Nippon Airways");// test alias
|
||||
assertTrue(allNipponAirways.getIATA() == "NH");// test iata
|
||||
assertTrue(allNipponAirways.getICAO() == "ANA");// test icao
|
||||
@@ -55,9 +60,13 @@ public class AirlineTest extends TestCase {
|
||||
assertTrue(allNipponAirways.getActive() == "Y");// get active
|
||||
//check set
|
||||
allNipponAirways.setID(322);//ID
|
||||
assertTrue(allNipponAirways.getID() == 322);
|
||||
|
||||
allNipponAirways.setName("All Nike Airways");//Name
|
||||
try {
|
||||
assertTrue(allNipponAirways.getID() == 322);
|
||||
} catch (DataException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
allNipponAirways.setName("All Nike Airways");//Name
|
||||
assertTrue(allNipponAirways.getName() == "All Nike Airways");
|
||||
|
||||
allNipponAirways.setAlias("ANA All Nike Airways");//Alias
|
||||
|
||||
@@ -7,6 +7,9 @@ import org.junit.rules.ExpectedException;
|
||||
|
||||
import seng202.group9.Controller.DataException;
|
||||
import seng202.group9.Core.Airport;
|
||||
import seng202.group9.Core.Route;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Unit test for Airport
|
||||
@@ -21,7 +24,7 @@ public class AirportUnitTest {
|
||||
public void airportGetterAndSetterTest() {
|
||||
//507,"Heathrow","London","United Kingdom","LHR","EGLL",51.4775,-0.461389,83,0,"E","Europe/London"
|
||||
//ID, Name, City, Country, IATA/FFA, ICAO, Latitude, Longitude, Altitude, Timezone, DST, Tz Data
|
||||
Airport heathrow = new Airport(507, "Heathrow", "London", "LHR", "EGLL", 51.4775, -0.41389, 83);
|
||||
Airport heathrow = new Airport(507, "Heathrow", "London", "United Kingdom", "LHR", "EGLL", 51.4775, -0.41389, 83);
|
||||
/////////////////
|
||||
//check getters//
|
||||
/////////////////
|
||||
@@ -64,11 +67,61 @@ public class AirportUnitTest {
|
||||
heathrow.setAltitude(0);//test set altitude
|
||||
assertTrue(heathrow.getAltitude() == 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void checkRoutesFnc(){
|
||||
//507,"Heathrow","London","United Kingdom","LHR","EGLL",51.4775,-0.461389,83,0,"E","Europe/London"
|
||||
//ID, Name, City, Country, IATA/FFA, ICAO, Latitude, Longitude, Altitude, Timezone, DST, Tz Data
|
||||
Airport heathrow = new Airport(507, "Heathrow", "London", "United Kingdom", "LHR", "EGLL", 51.4775, -0.41389, 83);
|
||||
//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
|
||||
Route route1 = new Route("BA1", "SIN1", "LHR1", "", 0, "744 777");
|
||||
Route route2 = new Route("BA2", "SIN2", "LHR2", "", 0, "744 777");
|
||||
Route route3 = new Route("BA3", "SIN3", "LHR3", "", 0, "744 777");
|
||||
|
||||
ArrayList<Route> routes = new ArrayList<Route>();
|
||||
routes.add(route1);
|
||||
routes.add(route2);
|
||||
routes.add(route3);
|
||||
|
||||
//first check addArrivalRoutes;
|
||||
heathrow.addArrivalRoutes(route1);
|
||||
heathrow.addArrivalRoutes(routes);
|
||||
|
||||
assertEquals(heathrow.getArrivalRoutes().get(0).arrivesAt(), "LHR1");
|
||||
assertEquals(heathrow.getArrivalRoutes().get(1).arrivesAt(), "LHR1");
|
||||
assertEquals(heathrow.getArrivalRoutes().get(2).arrivesAt(), "LHR2");
|
||||
assertEquals(heathrow.getArrivalRoutes().get(3).arrivesAt(), "LHR3");
|
||||
|
||||
//check add departrue routes;
|
||||
heathrow.addDepartureRoutes(route1);
|
||||
heathrow.addDepartureRoutes(routes);
|
||||
|
||||
assertEquals(heathrow.getDepartureRoutes().get(0).departsFrom(), "SIN1");
|
||||
assertEquals(heathrow.getDepartureRoutes().get(1).departsFrom(), "SIN1");
|
||||
assertEquals(heathrow.getDepartureRoutes().get(2).departsFrom(), "SIN2");
|
||||
assertEquals(heathrow.getDepartureRoutes().get(3).departsFrom(), "SIN3");
|
||||
|
||||
//check set
|
||||
heathrow.setArrivalRoutes(routes);
|
||||
heathrow.setDepartureRoutes(routes);
|
||||
//Arrival check
|
||||
assertEquals(heathrow.getArrivalRoutes().get(0).arrivesAt(), "LHR1");
|
||||
assertEquals(heathrow.getArrivalRoutes().get(1).arrivesAt(), "LHR2");
|
||||
assertEquals(heathrow.getArrivalRoutes().get(2).arrivesAt(), "LHR3");
|
||||
//departure check
|
||||
assertEquals(heathrow.getDepartureRoutes().get(0).departsFrom(), "SIN1");
|
||||
assertEquals(heathrow.getDepartureRoutes().get(1).departsFrom(), "SIN2");
|
||||
assertEquals(heathrow.getDepartureRoutes().get(2).departsFrom(), "SIN3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkIDException(){
|
||||
//507,"Heathrow","London","United Kingdom","LHR","EGLL",51.4775,-0.461389,83,0,"E","Europe/London"
|
||||
//ID, Name, City, Country, IATA/FFA, ICAO, Latitude, Longitude, Altitude, Timezone, DST, Tz Data
|
||||
Airport heathrow = new Airport("Heathrow", "London", "LHR", "EGLL", 51.4775, -0.41389, 83);
|
||||
Airport heathrow = new Airport("Heathrow", "London", "United Kingdom", "LHR", "EGLL", 51.4775, -0.41389, 83);
|
||||
thrown.expect(DataException.class);
|
||||
thrown.expectMessage("ID not set.");
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user