Added Testables to AppTest

main
YaFedImYaEatIm 9 years ago
parent 0de6bfafe5
commit ef3a3fc240

Binary file not shown.

@ -25,9 +25,9 @@ public class App extends Application
private ArrayList<Dataset> datasets = new ArrayList<Dataset>(); private ArrayList<Dataset> datasets = new ArrayList<Dataset>();
private Dataset currentDataset = null; private Dataset currentDataset = null;
private Stage primaryStage = null; private Stage primaryStage = null;
private VBox mainContainer; private VBox mainContainer = null;
private Session session; private Session session = null;
private MenuController menuController; private MenuController menuController = null;
public static void main( String[] args ) public static void main( String[] args )
{ {
@ -65,60 +65,11 @@ public class App extends Application
//testing out dataset //testing out dataset
try { try {
currentDataset = new Dataset("test's", Dataset.getExisting); currentDataset = new Dataset("test's", Dataset.getExisting);
datasets.add(currentDataset);
}catch (DataException e){ }catch (DataException e){
e.printStackTrace(); 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 //after all loading then load the previous session
try{ try{
FileInputStream fileIn = new FileInputStream("res/session.ser"); FileInputStream fileIn = new FileInputStream("res/session.ser");
@ -189,8 +140,25 @@ public class App extends Application
return currentDataset; 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){ public void deleteDataset(Dataset dataset){
dataset.deleteDataset(); dataset.deleteDataset();
datasets.remove(dataset); 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{ public void addAirport(Airport airportToAdd) throws DataException{
if (airportToAdd.getIATA_FFA().length() != 0 && airportToAdd.getIATA_FFA().length() != 3){ if (airportToAdd.getIATA_FFA().length() != 0 && airportToAdd.getIATA_FFA().length() != 3){
throw new DataException("IATA/FFA either empty or 3 letters"); throw new DataException("IATA/FFA either empty or 3 letters");
@ -907,6 +911,7 @@ public class Dataset {
ResultSet airportIDRes= stmt.executeQuery(airportIDQuery); ResultSet airportIDRes= stmt.executeQuery(airportIDQuery);
int airportID = 0; int airportID = 0;
while (airportIDRes.next()){ while (airportIDRes.next()){
airportID = Integer.parseInt(airportIDRes.getString("seq")); airportID = Integer.parseInt(airportIDRes.getString("seq"));
} }
airportToAdd.setID(airportID); airportToAdd.setID(airportID);

@ -1,38 +1,32 @@
package seng202.group9; package seng202.group9;
import junit.framework.Test; import org.junit.Test;
import junit.framework.TestCase; import seng202.group9.Controller.App;
import junit.framework.TestSuite; import seng202.group9.Controller.DataException;
import static org.junit.Assert.*;
/** /**
* Unit test for simple App. * Unit test for simple App.
*/ */
public class AppTest public class AppTest {
extends TestCase @Test
{ public void testApp(){
/** App app = new App();
* Create the test case assertTrue(app.getMenuController() == null);
* assertTrue(app.getPrimaryStage() == null);
* @param testName name of the test case try {
*/ app.createDataset("FORUNITTESTINGDATASET");
public AppTest( String testName ) } catch (DataException e) {
{ e.printStackTrace();
super( testName ); }
} assertEquals(app.getCurrentDataset().getName(), "FORUNITTESTINGDATASET");
/** app.deleteDataset(app.getCurrentDataset());
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/** for (int i = 0; i < app.getDatasets().size(); i++){
* Rigourous Test :-) assertTrue(!app.getDatasets().get(i).getName().equals("FORUNITTESTINGDATASET"));
*/ }
public void testApp() //more to come as the program upgrades for for as of now this is the limit.
{
assertTrue( true );
} }
} }

Loading…
Cancel
Save