Added Testables to AppTest
This commit is contained in:
@@ -25,9 +25,9 @@ public class App extends Application
|
||||
private ArrayList<Dataset> datasets = new ArrayList<Dataset>();
|
||||
private Dataset currentDataset = null;
|
||||
private Stage primaryStage = null;
|
||||
private VBox mainContainer;
|
||||
private Session session;
|
||||
private MenuController menuController;
|
||||
private VBox mainContainer = null;
|
||||
private Session session = null;
|
||||
private MenuController menuController = null;
|
||||
|
||||
public static void main( String[] args )
|
||||
{
|
||||
@@ -65,60 +65,11 @@ public class App extends Application
|
||||
//testing out dataset
|
||||
try {
|
||||
currentDataset = new Dataset("test's", Dataset.getExisting);
|
||||
datasets.add(currentDataset);
|
||||
}catch (DataException e){
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
AirlineFilter filter = new AirlineFilter(currentDataset.getAirlines());
|
||||
filter.filterName("NZ");
|
||||
filter.filterAlias("flight");
|
||||
filter.printFilter();
|
||||
|
||||
//testout single route adding
|
||||
try {
|
||||
currentDataset.addRoute("D2", "MAC", "WIN", "Y", "0", "NOW");
|
||||
}catch (DataException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
//testout single airport adding
|
||||
try {
|
||||
currentDataset.addAirport("Windows 10", "PC", "Windows", "WIN", "WIND", "0.0", "0.0", "0.0", "0.0", "U", "PC/Windows");
|
||||
}catch (DataException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
//testout single airline adding
|
||||
try {
|
||||
currentDataset.addAirline("Dota2", "Valve", "D2", "DOT", "Defence of the Ancients", "Steam", "Y");
|
||||
}catch (DataException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
//testing out airport parser
|
||||
try {
|
||||
System.out.println(currentDataset.importAirport("res/Samples/Airports.txt"));
|
||||
} catch (DataException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//testing out airline parser
|
||||
try{
|
||||
System.out.println(currentDataset.importAirline("res/Samples/Airlines.txt"));
|
||||
} catch (DataException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
//testing out route parser
|
||||
try {
|
||||
System.out.println(currentDataset.importRoute("res/Samples/Routes.txt"));
|
||||
} catch (DataException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//testing out flight parser
|
||||
try {
|
||||
System.out.println(currentDataset.importFlight("res/Samples/NZCH-WSSS.csv"));
|
||||
} catch (DataException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
//after all loading then load the previous session
|
||||
try{
|
||||
FileInputStream fileIn = new FileInputStream("res/session.ser");
|
||||
@@ -189,8 +140,25 @@ public class App extends Application
|
||||
return currentDataset;
|
||||
}
|
||||
|
||||
public void createDataset(String datasetName) throws DataException{
|
||||
Dataset newDataset = new Dataset(datasetName, Dataset.createNew);
|
||||
datasets.add(newDataset);
|
||||
currentDataset = newDataset;
|
||||
}
|
||||
|
||||
public ArrayList<Dataset> getDatasets() {
|
||||
return datasets;
|
||||
}
|
||||
|
||||
public void deleteDataset(Dataset dataset){
|
||||
dataset.deleteDataset();
|
||||
datasets.remove(dataset);
|
||||
if (dataset == currentDataset){
|
||||
if (datasets.size() > 0){
|
||||
currentDataset = datasets.get(0);
|
||||
}else{
|
||||
currentDataset = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -873,6 +873,10 @@ public class Dataset {
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public 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");
|
||||
@@ -907,6 +911,7 @@ public class Dataset {
|
||||
ResultSet airportIDRes= stmt.executeQuery(airportIDQuery);
|
||||
int airportID = 0;
|
||||
while (airportIDRes.next()){
|
||||
|
||||
airportID = Integer.parseInt(airportIDRes.getString("seq"));
|
||||
}
|
||||
airportToAdd.setID(airportID);
|
||||
|
||||
@@ -1,38 +1,32 @@
|
||||
package seng202.group9;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.Test;
|
||||
import seng202.group9.Controller.App;
|
||||
import seng202.group9.Controller.DataException;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
public class AppTest {
|
||||
@Test
|
||||
public void testApp(){
|
||||
App app = new App();
|
||||
assertTrue(app.getMenuController() == null);
|
||||
assertTrue(app.getPrimaryStage() == null);
|
||||
try {
|
||||
app.createDataset("FORUNITTESTINGDATASET");
|
||||
} catch (DataException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals(app.getCurrentDataset().getName(), "FORUNITTESTINGDATASET");
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
app.deleteDataset(app.getCurrentDataset());
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
for (int i = 0; i < app.getDatasets().size(); i++){
|
||||
assertTrue(!app.getDatasets().get(i).getName().equals("FORUNITTESTINGDATASET"));
|
||||
}
|
||||
//more to come as the program upgrades for for as of now this is the limit.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user