-
Notifications
You must be signed in to change notification settings - Fork 0
/
DegreeListTest.java
80 lines (66 loc) · 2.22 KB
/
DegreeListTest.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
78
79
80
import static org.junit.Assert.assertTrue;
import java.util.UUID;
import org.junit.*;
/**
* @author Aarsh Patel
*/
public class DegreeListTest {
// Test the constructor
@Test
public void testDefaultConstructor() {
DegreeList degreeList = DegreeList.getInstance();
assertTrue(degreeList.getAllDegree() != null);
}
// Test the getInstance method
@Test
public void testGetInstanceWithNull() {
DegreeList degreeList = DegreeList.getInstance();
assertTrue(degreeList != null);
}
@Test
public void testGetInstanceNotNull() {
DegreeList degreeList = DegreeList.getInstance();
assertTrue(degreeList == DegreeList.getInstance());
}
@Test
public void testGetInstanceWithEmptyList() {
DegreeList degreeList = DegreeList.getInstance();
degreeList.getAllDegree().clear();
assertTrue(degreeList != null);
}
// Test the getDegree method
@Test
public void testGetDegreeNull() {
DegreeList degreeList = DegreeList.getInstance();
assertTrue(degreeList.getDegree(null) == null);
}
@Test
public void testGetDegreeNotInList() {
DegreeList degreeList = DegreeList.getInstance();
assertTrue(degreeList.getDegree(UUID.randomUUID()) == null);
}
@Test
public void testGetDegreeInList() {
DegreeList degreeList = DegreeList.getInstance();
Degree degree = new Degree("Bachelor of Science", "Computer Science", 120, null, null);
degreeList.addDegree(degree);
assertTrue(degreeList.getDegree(degree.getID()).equals(degree));
}
@Test
public void testGetDegreeInEmptyList() {
DegreeList degreeList = DegreeList.getInstance();
degreeList.getAllDegree().clear();
assertTrue(degreeList.getDegree(UUID.randomUUID()) == null);
}
@Test
public void testWriteDegree() {
DegreeList degreeList = DegreeList.getInstance();
assertTrue(degreeList.writeToFile());
}
@Test // This test logic not right
public void testWriteDegreeEmptyList() {
DegreeList degreeList = DegreeList.getInstance();
degreeList.getAllDegree().clear();
assertTrue(degreeList.writeToFile());
}
}