Dataset UnitTests Made
This commit is contained in:
@@ -709,6 +709,7 @@ public class Dataset {
|
||||
insertFlightPointQuery += "(" + flightPathId +", \""+ flightName +"\", \"" + flightType + "\", "+ flightAltitude + ", " +
|
||||
"" + flightLatitude + ", " + flightLongitude + ")";
|
||||
flightPointsToImport.get(i).setID(nextID);
|
||||
flightPointsToImport.get(i).setIndexID(flightPathId);
|
||||
//add data to dataset array.
|
||||
//this is placed after incase the database messes up
|
||||
flightPathToAdd.addFlightPoint(flightPointsToImport.get(i));
|
||||
@@ -739,11 +740,23 @@ public class Dataset {
|
||||
public void createDataLinks(){
|
||||
//this may be seperated into more sepearate function in the future for time optimisation
|
||||
HashMap<String, Airline> airlineByIATA= new HashMap<String, Airline>();
|
||||
for (Country country: countries){
|
||||
country.setAirlines(new ArrayList<Airline>());
|
||||
country.setCities(new ArrayList<City>());
|
||||
}
|
||||
for (City city: cities){
|
||||
city.setAirports(new ArrayList<Airport>());
|
||||
}
|
||||
//create Airline country link
|
||||
for (Airline airline: airlines){
|
||||
airlineByIATA.put(airline.getIATA(), airline);
|
||||
//System.out.println(airline.getAlias());
|
||||
airline.setRoutes(new ArrayList<Route>());
|
||||
airline.setCountry(countryDictionary.get(airline.getCountryName()));
|
||||
Country country = countryDictionary.get(airline.getCountryName());
|
||||
if (country != null){
|
||||
country.addAirline(airline);
|
||||
}
|
||||
}
|
||||
//create Airport City and Country Link
|
||||
HashMap<String, Airport> airportsByIATA = new HashMap<String, Airport>(); //this is used later for connecting the routes
|
||||
@@ -757,6 +770,8 @@ public class Dataset {
|
||||
//TODO Add City in country (This is extra work).
|
||||
airport.setCity(cityDictionary.get(airport.getCityName()));
|
||||
airport.getCity().addAirport(airport);
|
||||
airport.setDepartureRoutes(new ArrayList<Route>());
|
||||
airport.setArrivalRoutes(new ArrayList<Route>());
|
||||
}
|
||||
//set Airport variables for route
|
||||
for (Route route: routes){
|
||||
@@ -771,6 +786,10 @@ public class Dataset {
|
||||
route.setDestinationAirport(airportsByIATA.get(route.getArrivalAirport()));
|
||||
}
|
||||
route.setAirline(airlineByIATA.get(route.getAirlineName()));
|
||||
Airline airline = airlineByIATA.get(route.getAirlineName());
|
||||
if (airline != null){
|
||||
airline.addRoutes(route);
|
||||
}
|
||||
}
|
||||
System.out.println("Links Made");
|
||||
}
|
||||
@@ -877,7 +896,7 @@ public class Dataset {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void addAirport(Airport airportToAdd) throws DataException{
|
||||
private void addAirport(Airport airportToAdd) throws DataException{
|
||||
if (airportToAdd.getIATA_FFA().length() != 0 && airportToAdd.getIATA_FFA().length() != 3){
|
||||
throw new DataException("IATA/FFA either empty or 3 letters");
|
||||
}
|
||||
@@ -1045,7 +1064,7 @@ public class Dataset {
|
||||
routeToAdd.setID(routeID);
|
||||
routes.add(routeToAdd);
|
||||
//routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip
|
||||
String routeKey = routeToAdd.getAirline() + routeToAdd.getDepartureAirport() + routeToAdd.getArrivalAirport() + routeToAdd.getCode() + routeToAdd.getStops() + routeToAdd.getEquipment();
|
||||
String routeKey = routeToAdd.getAirlineName() + routeToAdd.getDepartureAirport() + routeToAdd.getArrivalAirport() + routeToAdd.getCode() + routeToAdd.getStops() + routeToAdd.getEquipment();
|
||||
routeDictionary.put(routeKey, routeToAdd);
|
||||
stmt.close();
|
||||
c.close();
|
||||
@@ -1105,7 +1124,7 @@ public class Dataset {
|
||||
* @param totDist
|
||||
*/
|
||||
public void addFlightPointToPath(int id, String name, String type, String via, String altitude, String latitude, String longitude,
|
||||
String heading, String legDist, String totDist) throws DataException{
|
||||
String heading, String legDist, String totDist , int index) throws DataException{
|
||||
double altitudeVal = 0.0;
|
||||
double latitudeVal = 0.0;
|
||||
double longitudeVal = 0.0;
|
||||
@@ -1176,9 +1195,24 @@ public class Dataset {
|
||||
|
||||
FlightPoint pointToAdd = new FlightPoint(name, pointID+1, id, type, via, headingVal, altitudeVal, legDistVal,
|
||||
totalDistVal,latitudeVal, longitudeVal);
|
||||
flightPathDictionary.get(id).addFlightPoint(pointToAdd);
|
||||
flightPathDictionary.get(Integer.valueOf(id)).addFlightPoint(pointToAdd, index);
|
||||
}
|
||||
|
||||
public void addFlightPointToPath(FlightPoint point, int index) throws DataException{
|
||||
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()),
|
||||
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()),
|
||||
String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), index);
|
||||
}
|
||||
|
||||
public void addFlightPointToPath(FlightPoint point) throws DataException{
|
||||
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()),
|
||||
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()),
|
||||
String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), -1);
|
||||
}
|
||||
|
||||
public void addFlightPointToPath(int id, String name, String type, String via, String altitude, String latitude, String longitude,
|
||||
String heading, String legDist, String totDist) throws DataException{
|
||||
addFlightPointToPath(id, name, type, via, altitude, latitude, longitude, heading, legDist, totDist, -1);
|
||||
}
|
||||
/**
|
||||
* This is called in conjunction to the App deleteDataset DO NOT CALL UNLESS THROUGH APP.DELETEDATASET
|
||||
@@ -1264,6 +1298,8 @@ public class Dataset {
|
||||
//System.exit(0);
|
||||
}
|
||||
airlines.remove(airline);
|
||||
airlineDictionary.remove(airline.getName());
|
||||
createDataLinks();
|
||||
}
|
||||
|
||||
public void deleteAirline(int index){
|
||||
@@ -1312,6 +1348,8 @@ public class Dataset {
|
||||
String deleteCountry = "DELETE FROM `"+this.name+"_Country` WHERE `Country_Name` = \""+airport.getCountry().getName()+"\"";
|
||||
stmt.execute(deleteCountry);
|
||||
stmt.close();
|
||||
countries.remove(countryDictionary.get(airport.getCountryName()));
|
||||
countryDictionary.remove(airport.getCountryName());
|
||||
}
|
||||
//cehck if number cities that contain airports > 0 else delete the city
|
||||
String countCity = "SELECT COUNT(*) FROM `"+this.name+"_Airport` JOIN `"+this.name+"_City` ON" +
|
||||
@@ -1330,6 +1368,8 @@ public class Dataset {
|
||||
String deleteCity = "DELETE FROM `"+this.name+"_City` WHERE `City_Name` = \""+airport.getCityName()+"\"";
|
||||
stmt.execute(deleteCity);
|
||||
stmt.close();
|
||||
cities.remove(cityDictionary.get(airport.getCityName()));
|
||||
cityDictionary.remove(airport.getCityName());
|
||||
}
|
||||
c.close();
|
||||
} catch ( Exception e ) {
|
||||
@@ -1337,6 +1377,8 @@ public class Dataset {
|
||||
System.exit(0);
|
||||
}
|
||||
airports.remove(airport);
|
||||
airportDictionary.remove(airport.getName());
|
||||
createDataLinks();
|
||||
}
|
||||
|
||||
public void deleteAirport(int index){
|
||||
@@ -1362,6 +1404,10 @@ public class Dataset {
|
||||
System.exit(0);
|
||||
}
|
||||
routes.remove(route);
|
||||
//routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip
|
||||
String key = route.getAirlineName() + route.getDepartureAirport() + route.getArrivalAirport() + route.getCode() + route.getStops() + route.getEquipment();
|
||||
routeDictionary.remove(key);
|
||||
createDataLinks();
|
||||
}
|
||||
|
||||
public void deleteRoute(int index){
|
||||
@@ -1391,6 +1437,11 @@ public class Dataset {
|
||||
System.exit(0);
|
||||
}
|
||||
flightPaths.remove(flightPath);
|
||||
try {
|
||||
flightPathDictionary.remove(flightPath.getID());
|
||||
} catch (DataException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteFlightPath(int index){
|
||||
@@ -1420,7 +1471,7 @@ public class Dataset {
|
||||
}
|
||||
|
||||
public void deleteFlightPoint(int pathIndex, int pointIndex){
|
||||
deleteFlightPoint(flightPaths.get(pathIndex).getFlightPoints().get(pointIndex), flightPaths.get(pathIndex));
|
||||
deleteFlightPoint(flightPathDictionary.get(pathIndex).getFlightPoints().get(pointIndex), flightPathDictionary.get(pathIndex));
|
||||
}
|
||||
|
||||
public ArrayList<Airline> getAirlines() {
|
||||
|
||||
@@ -3,11 +3,14 @@ package seng202.group9.Core;
|
||||
import seng202.group9.Controller.DataException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Country {
|
||||
private String DST, name;
|
||||
private ArrayList<City> cities = new ArrayList<City>();
|
||||
private ArrayList<Airline> airlines = new ArrayList<Airline>();
|
||||
private HashMap<String, Airline> airlineDict = new HashMap<String, Airline>();
|
||||
private HashMap<String, City> cityDict = new HashMap<String, City>();
|
||||
private Position position;
|
||||
|
||||
/**
|
||||
@@ -42,8 +45,10 @@ public class Country {
|
||||
*/
|
||||
public void setAirlines(ArrayList<Airline> airlines) {
|
||||
this.airlines = new ArrayList<Airline>();
|
||||
this.airlineDict = new HashMap<String, Airline>();
|
||||
for (int i = 0; i < airlines.size(); i ++) {
|
||||
this.airlines.add(airlines.get(i));
|
||||
airlineDict.put(airlines.get(i).getName(), airlines.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +81,10 @@ public class Country {
|
||||
* @param airline
|
||||
*/
|
||||
public void addAirline(Airline airline){
|
||||
this.airlines.add(airline);
|
||||
if (!airlineDict.containsKey(airline.getName())) {
|
||||
this.airlines.add(airline);
|
||||
airlineDict.put(airline.getName(), airline);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,6 +103,7 @@ public class Country {
|
||||
*/
|
||||
public void delAirline(Airline airline){
|
||||
airlines.remove(airline);
|
||||
airlineDict.remove(airline.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,6 +112,7 @@ public class Country {
|
||||
*/
|
||||
public void delAirline(int index) throws DataException{
|
||||
if (airlines.size() > index && index >= 0) {
|
||||
airlineDict.remove(airlines.get(index).getName());
|
||||
airlines.remove(index);
|
||||
}else{
|
||||
throw new DataException("Index " + index + " does not exist in list of Airlines in this Country.");
|
||||
@@ -115,8 +125,10 @@ public class Country {
|
||||
*/
|
||||
public void setCities(ArrayList<City> cities){
|
||||
this.cities = new ArrayList<City>();
|
||||
this.cityDict = new HashMap<String, City>();
|
||||
for (int i = 0; i < cities.size(); i++){
|
||||
this.cities.add(cities.get(i));
|
||||
cityDict.put(cities.get(i).getName(), cities.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +137,10 @@ public class Country {
|
||||
* @param city
|
||||
*/
|
||||
public void addCities(City city){
|
||||
this.cities.add(city);
|
||||
if (!cityDict.containsKey(city.getName())) {
|
||||
this.cities.add(city);
|
||||
cityDict.put(city.getName(), city);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -130,10 +130,8 @@ public class FlightPath {
|
||||
* @param index
|
||||
*/
|
||||
public void addFlightPoint(FlightPoint flightPoint, int index){
|
||||
if (index >= flightPoints.size()){
|
||||
if (index >= flightPoints.size() || index < 0){
|
||||
flightPoints.add(flightPoint);
|
||||
}else if (index < 0){
|
||||
flightPoints.add(0, flightPoint);
|
||||
}else {
|
||||
flightPoints.add(index, flightPoint);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
||||
APT,NZCH,0,-43.48664019,172.53368221
|
||||
VOR,CH,400,-43.50411111,172.51463889000001
|
||||
FIX,VANDA,34000,-42.421806,169.34450000000004
|
||||
FIX,UKLAK,34000,-41.4245,166.71119399999998
|
||||
FIX,SULON,34000,-39.858528,163
|
||||
FIX,PLUGA,34000,-35.6075,154.68888900000002
|
||||
FIX,CAWLY,34000,-34.326111,151.95777799999996
|
||||
VOR,SY,34000,-33.94277778,151.18055556000002
|
||||
NDB,KAT,34000,-33.710806,150.299622
|
||||
VOR,PKS,34000,-33.131111,148.23722199999997
|
||||
FIX,VIMAB,34000,-31.515277999999995,145.358611
|
||||
FIX,APOMA,34000,-29.898055999999997,142.681667
|
||||
FIX,POLEV,34000,-26.920277999999996,138.16916700000002
|
||||
FIX,KALUG,34000,-25.900000000000006,136.72500000000002
|
||||
VOR,AS,34000,-23.792889000000002,133.87820299999998
|
||||
FIX,TIMMI,34000,-21.922483,130.65954399999998
|
||||
FIX,TATUK,34000,-19.429444000000004,126.646389
|
||||
VOR,CIN,34000,-17.588888889999993,123.85194444000001
|
||||
FIX,ATMAP,34000,-12,118.255
|
||||
FIX,ILDAM,34000,-10.592113999999995,116.88456400000001
|
||||
VOR,BLI,34000,-8.750583329999998,115.16330556000003
|
||||
FIX,SIPUT,34000,-6.283332999999999,112.58333299999998
|
||||
FIX,SUMBU,34000,-4.7549999999999955,110.82333299999999
|
||||
FIX,SABIL,34000,-4.019069000000002,109.93852800000002
|
||||
FIX,AKULA,34000,-3.119878,108.95092499999998
|
||||
FIX,APAGA,34000,-2.7826749999999976,108.580897
|
||||
FIX,APARI,34000,-2.043471999999994,107.84038299999997
|
||||
FIX,SANOS,34000,-0.7000000000000028,106.316667
|
||||
FIX,AKTOD,34300,-0.4133329999999944,105.99305600000002
|
||||
NDB,TI,8800,0.9197280000000063,104.52616899999998
|
||||
APT,WSSS,0,1.3519171399999976,103.99560303999999
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,210 @@
|
||||
package seng202.group9;/**
|
||||
* Created by Gondr on 19/09/2016.
|
||||
*/
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
import seng202.group9.Controller.App;
|
||||
import seng202.group9.Controller.DataException;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Core.*;
|
||||
|
||||
public class DatasetTest {
|
||||
static App app = new App();
|
||||
|
||||
@Test
|
||||
public void DatasetConstructor(){
|
||||
try {
|
||||
app.createDataset("FORUNITTESTINGONLY");
|
||||
} catch (DataException e) {
|
||||
fail("There seems to be database already by this name");
|
||||
}
|
||||
|
||||
Dataset dataset = app.getCurrentDataset();
|
||||
|
||||
assertEquals(dataset.getName(), "FORUNITTESTINGONLY");
|
||||
|
||||
try {
|
||||
dataset.importAirline("res/Reduced Samples/Airlines.txt");
|
||||
} catch (DataException e) {
|
||||
fail("The sample file is missing");
|
||||
}
|
||||
assertTrue(dataset.getAirlines().size() == dataset.getAirlineDictionary().size());
|
||||
|
||||
try {
|
||||
dataset.importAirport("res/Reduced Samples/Airports.txt");
|
||||
} catch (DataException e) {
|
||||
fail("The sample file is missing");
|
||||
}
|
||||
assertTrue(dataset.getAirports().size() == dataset.getAirportDictionary().size());
|
||||
assertTrue(dataset.getCities().size() == dataset.getCityDictionary().size());
|
||||
assertTrue(dataset.getCountries().size() == dataset.getCountryDictionary().size());
|
||||
|
||||
try {
|
||||
dataset.importRoute("res/Reduced Samples/Routes.txt");
|
||||
} catch (DataException e) {
|
||||
fail("The sample file is missing");
|
||||
}
|
||||
assertTrue(dataset.getRoutes().size() == dataset.getRouteDictionary().size());
|
||||
|
||||
try {
|
||||
dataset.importFlight("res/Reduced Samples/NZCH-WSSS.csv");
|
||||
} catch (DataException e) {
|
||||
fail("The sample file is missing");
|
||||
}
|
||||
assertTrue(dataset.getFlightPaths().size() == dataset.getFlightPathDictionary().size());
|
||||
|
||||
dataset.createDataLinks();
|
||||
|
||||
assertTrue(dataset.getAirlines().size() == dataset.getAirlineDictionary().size());
|
||||
assertTrue(dataset.getAirports().size() == dataset.getAirportDictionary().size());
|
||||
assertTrue(dataset.getCities().size() == dataset.getCityDictionary().size());
|
||||
assertTrue(dataset.getCountries().size() == dataset.getCountryDictionary().size());
|
||||
assertTrue(dataset.getRoutes().size() == dataset.getRouteDictionary().size());
|
||||
assertTrue(dataset.getFlightPaths().size() == dataset.getFlightPathDictionary().size());
|
||||
//make sure that datalinks does not increase the size of the dictionaries etc
|
||||
|
||||
app.deleteDataset(app.getCurrentDataset());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkoutDataLinks() throws DataException {
|
||||
try {
|
||||
app.createDataset("FORUNITTESTINGONLY");
|
||||
} catch (DataException e) {
|
||||
fail("There seems to be database already by this name");
|
||||
}
|
||||
|
||||
Dataset dataset = app.getCurrentDataset();
|
||||
|
||||
Airline allNipponAirways = new Airline(324, "All Nippon Airways", "ANA All Nippon Airways",
|
||||
"NH", "ANA", "ALL NIPPON", "Japan", "Y");
|
||||
dataset.addAirline(allNipponAirways);
|
||||
assertEquals(dataset.getAirlines().get(0), allNipponAirways);
|
||||
dataset.addAirline("British Airways","\\N","BA","BAW","SPEEDBIRD","United Kingdom","Y");
|
||||
|
||||
assertEquals(dataset.getAirlines().get(1).getName(), "British Airways");
|
||||
assertTrue(dataset.getAirlines().get(0).getID() != -1);
|
||||
assertTrue(dataset.getAirlines().get(1).getID() != -1);
|
||||
|
||||
dataset.addAirport("Heathrow","London","United Kingdom","LHR","EGLL","51.4775","-0.461389","83","0","E","Europe/London");
|
||||
dataset.addAirport("Changi Intl","Singapore","Singapore","SIN","WSSS","1.350189","103.994433","22","8","N","Asia/Singapore");
|
||||
dataset.addAirport("Matsumoto","Matsumoto","Japan","MMJ","RJAF","36.166758","137.922669","2182","9","U","Asia/Tokyo");
|
||||
assertTrue(dataset.getAirports().size() == 3);
|
||||
assertTrue(dataset.getCities().size() == 3);
|
||||
assertTrue(dataset.getCountries().size() == 3);
|
||||
|
||||
Route route = new Route("BA", "SIN", "LHR", "", 0, "744 777");
|
||||
dataset.addRoute(route);
|
||||
dataset.addRoute("NH", "SIN", "LHR", "", "0","777");
|
||||
//checked if everything is linked together properly
|
||||
assertTrue(dataset.getAirlines().get(0).getCountry() != null);
|
||||
assertTrue(dataset.getAirlines().get(1).getCountry() != null);
|
||||
|
||||
assertTrue(dataset.getAirlines().get(0).getRoutes().size() == 1);
|
||||
assertTrue(dataset.getAirlines().get(1).getRoutes().size() == 1);
|
||||
|
||||
assertTrue(dataset.getCountryDictionary().get("United Kingdom").getAirlines().size() == 1);
|
||||
assertTrue(dataset.getCountryDictionary().get("Japan").getAirlines().size() == 1);
|
||||
|
||||
assertEquals(dataset.getRoutes().get(0).getSourceAirport(), dataset.getAirportDictionary().get("Changi Intl"));
|
||||
assertEquals(dataset.getRoutes().get(0).getDestinationAirport(), dataset.getAirportDictionary().get("Heathrow"));
|
||||
assertEquals(dataset.getRoutes().get(0).getAirline(), dataset.getAirlineDictionary().get("British Airways"));
|
||||
|
||||
assertEquals(dataset.getRoutes().get(1).getSourceAirport(), dataset.getAirportDictionary().get("Changi Intl"));
|
||||
assertEquals(dataset.getRoutes().get(1).getDestinationAirport(), dataset.getAirportDictionary().get("Heathrow"));
|
||||
assertEquals(dataset.getRoutes().get(1).getAirline(), dataset.getAirlineDictionary().get("All Nippon Airways"));
|
||||
|
||||
//slowly delete everything and check if the links are retained/gone.
|
||||
dataset.deleteRoute(0);
|
||||
assertTrue(dataset.getRoutes().size() == 1);
|
||||
assertTrue(dataset.getRoutes().size() == dataset.getRouteDictionary().size());
|
||||
|
||||
assertTrue(dataset.getAirlines().get(0).getRoutes().size() == 1);
|
||||
assertTrue(dataset.getAirlines().get(1).getRoutes().size() == 0);
|
||||
//add the route back
|
||||
dataset.addRoute(route);
|
||||
|
||||
dataset.deleteAirport(0);
|
||||
|
||||
assertTrue(dataset.getCityDictionary().get("London") == null);
|
||||
assertTrue(dataset.getCountryDictionary().get("United Kingdom") == null);
|
||||
assertTrue(dataset.getRoutes().get(0).getDestinationAirport() == null);
|
||||
assertTrue(dataset.getRoutes().get(1).getDestinationAirport() == null);
|
||||
|
||||
dataset.addAirport("Heathrow","London","United Kingdom","LHR","EGLL","51.4775","-0.461389","83","0","E","Europe/London");
|
||||
|
||||
//check that all changes are now back;
|
||||
assertTrue(dataset.getCityDictionary().get("London") != null);
|
||||
assertTrue(dataset.getCountryDictionary().get("United Kingdom") != null);
|
||||
assertTrue(dataset.getRoutes().get(0).getDestinationAirport() != null);
|
||||
assertTrue(dataset.getRoutes().get(1).getDestinationAirport() != null);
|
||||
|
||||
dataset.deleteAirline(dataset.getAirlines().get(0));
|
||||
|
||||
assertTrue(dataset.getRoutes().get(0).getAirline() == null);
|
||||
assertTrue(dataset.getCountryDictionary().get("Japan").getAirlines().size() == 0);
|
||||
|
||||
//clean database and check whether dictionarys and arrays are empty
|
||||
dataset.deleteAirline(0);
|
||||
dataset.deleteAirport(0);
|
||||
dataset.deleteAirport(0);
|
||||
dataset.deleteAirport(0);
|
||||
dataset.deleteRoute(0);
|
||||
dataset.deleteRoute(0);
|
||||
|
||||
assertTrue(dataset.getAirlines().size() == 0);
|
||||
assertTrue(dataset.getAirports().size() == 0);
|
||||
assertTrue(dataset.getAirlineDictionary().size() == 0);
|
||||
assertTrue(dataset.getAirportDictionary().size() == 0);
|
||||
assertTrue(dataset.getRoutes().size() == 0);
|
||||
assertTrue(dataset.getRouteDictionary().size() == 0);
|
||||
assertTrue(dataset.getCities().size() == 0);
|
||||
assertTrue(dataset.getCityDictionary().size() == 0);
|
||||
assertTrue(dataset.getCountries().size() == 0);
|
||||
assertTrue(dataset.getCountryDictionary().size() == 0);
|
||||
|
||||
app.deleteDataset(app.getCurrentDataset());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flightPathTester() throws DataException {
|
||||
try {
|
||||
app.createDataset("FORUNITTESTINGONLY");
|
||||
} catch (DataException e) {
|
||||
fail("There seems to be database already by this name");
|
||||
}
|
||||
|
||||
Dataset dataset = app.getCurrentDataset();
|
||||
|
||||
try {
|
||||
dataset.importFlight("res/Reduced Samples/NZCH-WSSS.csv");
|
||||
} catch (DataException e) {
|
||||
fail("The sample file is missing");
|
||||
}
|
||||
|
||||
FlightPoint flightPoint = dataset.getFlightPaths().get(0).getFlightPoints().get(6);
|
||||
FlightPoint flightPoint1 = dataset.getFlightPaths().get(0).getFlightPoints().get(5);
|
||||
dataset.deleteFlightPoint(1, 5);
|
||||
assertEquals(dataset.getFlightPaths().get(0).getFlightPoints().get(5), flightPoint);
|
||||
int currentSize = dataset.getFlightPaths().get(0).getFlightPoints().size();
|
||||
dataset.deleteFlightPoint(flightPoint, dataset.getFlightPaths().get(0));
|
||||
assertTrue(dataset.getFlightPaths().get(0).getFlightPoints().size() == currentSize - 1);
|
||||
|
||||
dataset.addFlightPointToPath(flightPoint1, 5);
|
||||
dataset.addFlightPointToPath(flightPoint, 6);
|
||||
assertEquals(dataset.getFlightPaths().get(0).getFlightPoints().get(5).getName(), flightPoint1.getName());
|
||||
assertEquals(dataset.getFlightPaths().get(0).getFlightPoints().get(6).getName(), flightPoint.getName());
|
||||
|
||||
app.deleteDataset(app.getCurrentDataset());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void deleteDataset(){
|
||||
while(app.getCurrentDataset() != null) {
|
||||
app.deleteDataset(app.getCurrentDataset());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class FlightPathTest {
|
||||
flightPath.addFlightPoint(endPoint, -1);
|
||||
flightPath.addFlightPoint(endPoint, 100);
|
||||
|
||||
assertEquals(flightPath.getFlightPoints().get(0), endPoint);
|
||||
assertEquals(flightPath.getFlightPoints().get(4), endPoint);
|
||||
assertEquals(flightPath.getFlightPoints().get(4), endPoint);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user