-
Notifications
You must be signed in to change notification settings - Fork 0
/
WarehouseTesting.java
77 lines (63 loc) · 2.37 KB
/
WarehouseTesting.java
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
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.*;
/**
* The test class WarehouseTesting.
*
* @author (your name)
* @version (a version number or a date)
*/
public class WarehouseTesting
{
@Test
public void testWarehouseCompareTo(){
City c1 = new City("Boston");
City c2 = new City("Newton");
Warehouse w1 = new Warehouse("Boston");
Warehouse w2 = new Warehouse("Newton");
c1.setWarehouse(w1);
c2.setWarehouse(w2);
assert(w1.compareTo(w2)<0);
}
@Test
public void testWarehouseAddCargo(){
City c1 = new City("Boston");
Warehouse w1 = new Warehouse("Boston");
c1.setWarehouse(w1);
w1.addCargo(new Cargo(10, "CJ", 1));
w1.addCargo(new Cargo(20, "Silverman", 2));
w1.addCargo(new Cargo(30, "Addison", 3));
w1.addCargo(new Cargo(40, "Butka", 4));
w1.addCargo(new Cargo(50, "Goldwait", 5));
Object [] theAns = w1.incomingCargoToArray();
String [] truAns = new String[5];
truAns[0] = (new Cargo(10, "CJ", 1)).toString();
truAns[1] = (new Cargo(20, "Silverman", 2)).toString();
truAns[2] = (new Cargo(30, "Addison", 3)).toString();
truAns[3] = (new Cargo(40, "Butka", 4)).toString();
truAns[4] = (new Cargo(50, "Goldwait", 5)).toString();
assertArrayEquals(theAns, truAns);
}
@Test
public void testWarehouseSortCargo(){
City c1 = new City("Boston");
Warehouse w1 = new Warehouse("Boston");
c1.setWarehouse(w1);
w1.addCargo(new Cargo(50, "CJ", 1));
w1.addCargo(new Cargo(30, "Silverman", 2));
w1.addCargo(new Cargo(20, "Addison", 3));
w1.addCargo(new Cargo(40, "Butka", 4));
w1.addCargo(new Cargo(10, "Goldwait", 5));
w1.cargoSort();
Object [] theAns = w1.incomingCargoToArray();
String [] truAns = new String[5];
truAns[0] = (new Cargo(10, "Goldwait", 5)).toString();
truAns[1] = (new Cargo(20, "Addison", 3)).toString();
truAns[2] = (new Cargo(30, "Silverman", 2)).toString();
truAns[3] = (new Cargo(40, "Butka", 4)).toString();
truAns[4] = (new Cargo(50, "CJ", 1)).toString();
assertArrayEquals(theAns, truAns);
}
}