-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackendDeveloperTests.java
More file actions
167 lines (134 loc) · 5.12 KB
/
BackendDeveloperTests.java
File metadata and controls
167 lines (134 loc) · 5.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.testfx.framework.junit5.ApplicationTest;
import javafx.scene.control.Label;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
public class BackendDeveloperTests extends ApplicationTest {
*/
/**
* Tests the loadGraphData() method using a try block and getListOfAllLocations()
*//*
@Test
public void test1() {
GraphADT<String, Double> testGraph = new DijkstraGraph();
BackendInterface backend = new Backend(testGraph);
// Tests if IOException is thrown for an invalid file name
try {
backend.loadGraphData("fake.dot");
Assertions.fail();
} catch(IOException e) { }
// Tests if a valid file name doesn't throw an exception
try {
backend.loadGraphData("campus.dot");
} catch(IOException e) {
System.out.println(e.getMessage());
Assertions.fail();
}
// Tests if the list is empty and probes a couple of locations to see if the data was correctly loaded
List<String> testLocations = backend.getListOfAllLocations();
Assertions.assertTrue(!testLocations.isEmpty() && testLocations.contains("Memorial Union") &&
testLocations.contains("Atmospheric, Oceanic and Space Sciences"));
}
*/
/**
* Tests the findShortestPath() method
*//*
@Test
public void test2() {
GraphADT<String, Double> testGraph = new DijkstraGraph();
BackendInterface backend = new Backend(testGraph);
try {
backend.loadGraphData("campus.dot");
} catch(IOException e) {
System.out.println(e.getMessage());
Assertions.fail();
}
List<String> actualPath = Arrays.asList("Union South", "Computer Sciences and Statistics", "Meiklejohn House", "Chemistry Building");
List<String> testPath = backend.findShortestPath("Union South", "Chemistry Building");
Assertions.assertTrue(testPath.equals(actualPath));
}
*/
/**
* Test the getTravelTimesOnPath() method
*//*
@Test
public void test3() {
GraphADT<String, Double> testGraph = new DijkstraGraph();
BackendInterface backend = new Backend(testGraph);
try {
backend.loadGraphData("campus.dot");
} catch(IOException e) {
System.out.println(e.getMessage());
Assertions.fail();
}
List<Double> actualTimes = Arrays.asList(176.0, 164.20000000000002, 128.9);
List<Double> testTimes = backend.getTravelTimesOnPath("Union South", "Chemistry Building");
Assertions.assertTrue(testTimes.equals(actualTimes));
}
*/
/**
* Tests the getMostDistantLocation() method
*//*
@Test
public void test4() {
GraphADT<String, Double> testGraph = new DijkstraGraph();
BackendInterface backend = new Backend(testGraph);
try {
backend.loadGraphData("campus.dot");
} catch(IOException e) {
System.out.println(e.getMessage());
Assertions.fail();
}
String actualLocation = "Smith Residence Hall";
String testLocation = backend.getMostDistantLocation("Union South");
Assertions.assertTrue(testLocation.equals(actualLocation));
}
*/
/**
* This method launches the JavaFX application that you would like to test
* BeforeEach of your @Test methods are run.
*//*
@BeforeEach
public void setup() throws Exception {
Frontend.setBackend(new Backend(new DijkstraGraph()));
ApplicationTest.launch(Frontend.class);
}
*/
/**
* Tests that the shortest path without checking the include walking distance
* checkbox returns what we would expect with working backend
*//*
@Test
public void testIntegration1() {
Label resultsLabel = lookup("#resultsLabel").query();
clickOn("#srcTextBox");
write("Union South");
clickOn("#dstTextBox");
write("Chemistry Building");
clickOn("#searchButton");
Assertions.assertTrue(resultsLabel.getText().contains(("Results List:")));
Assertions.assertTrue(resultsLabel.getText().contains(("Union South")));
Assertions.assertTrue(resultsLabel.getText().contains(("Computer Sciences and Statistics")));
Assertions.assertTrue(resultsLabel.getText().contains(("Meiklejohn House")));
Assertions.assertTrue(resultsLabel.getText().contains(("Chemistry Building")));
}
*/
/**
* Tests the furthest from labels, button and output to make
* sure it is what we expect for certain inputs with working backend
*//*
@Test
public void testIntegration2() {
Label furthestFrom = lookup("#furthestFromLabel").query();
clickOn("#locTextBox");
write("Union South");
clickOn("#furthestFromButton");
Assertions.assertTrue(furthestFrom.getText().contains("Smith Residence Hall"));
Assertions.assertTrue(furthestFrom.getText().contains("Approximate Total Time: 29min 53sec"));
}
}
*/