-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataLoaderTest.java
126 lines (105 loc) · 3.72 KB
/
DataLoaderTest.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
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
//@author Logan Praylow
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
public class DataLoaderTest {
private UserList users = UserList.getInstance();
private ArrayList<User> userList = users.getUserList();
//user array tester
@BeforeEach
public void setupUser() {
userList.clear();
userList.add(new User("jb","1234","Josh","bailey","[email protected]",1));
userList.add(new User("msue","2468","Mary","sue","[email protected]",2));
DataWriter.saveUsers();
}
@AfterEach
public void tearDownUser() {
UserList.getInstance().getUserList().clear();
DataWriter.saveUsers();
}
@Test
public void testGetUsersSize() {
userList = DataLoader.GetUsers();
assertEquals(2, userList.size());
}
@Test
public void testGetUsersSizeZero() {
UserList.getInstance().getUserList().clear();
DataWriter.saveUsers();
assertEquals(0, userList.size());
}
@Test
public void testGetUserFirstUserName() {
userList = DataLoader.GetUsers();
assertEquals("jb", userList.get(0).getUserName());
}
//project array tester
private ProjectList projects = ProjectList.getInstance();
private ArrayList<Project> projectList = projects.getProjectList();
@BeforeEach
public void setupPro() {
projectList.clear();
projectList.add(new Project("Project 1", "Description 1", "Author 1"));
projectList.add(new Project("Project 2", "Description 2", "Author 2"));
DataWriter.saveProjects();
}
@AfterEach
public void tearDownPro() {
ProjectList.getInstance().getProjectList().clear();
DataWriter.saveProjects();
}
@Test
public void testGetProjectsSize() {
projectList = DataLoader.GetProjects();
assertEquals(2, projectList.size());
}
@Test
public void testGetProjectsSizeZero() {
ProjectList.getInstance().getProjectList().clear();
DataWriter.saveProjects();
assertEquals(0, projectList.size());
}
@Test
public void testGetProjectName() {
projectList = DataLoader.GetProjects();
assertEquals("Project 1", projectList.get(0).getProjectName());
}
//task array tester
private TaskList tasks = TaskList.getInstance();
private ArrayList<Task> taskList = tasks.geTasksList();
@BeforeEach
public void setupTask() {
taskList.clear();
ArrayList<Comment> task1Comments = new ArrayList<>();
ArrayList<Comment> task2Comments = new ArrayList<>();
task1Comments.add(new Comment("User1", "Comment 1", "2023-11-07"));
task1Comments.add(new Comment("User2", "Comment 2", "2023-11-07"));
taskList.add(new Task("Task 1", "Description 1", 1, Category.BUG, task1Comments, true, 1, "Red"));
taskList.add(new Task("Task 2", "Description 2", 2, Category.BUG, task2Comments, false, 2, "Green"));
DataWriter.saveTasks();
}
@AfterEach
public void tearDownTask() {
TaskList.getInstance().geTasksList().clear();
DataWriter.saveTasks();
}
@Test
public void testGetTasksSize() {
taskList = DataLoader.GetTask();
assertEquals(2, taskList.size());
}
@Test
public void testGetTasksSizeZero() {
TaskList.getInstance().geTasksList().clear();
DataWriter.saveTasks();
assertEquals(0, taskList.size());
}
@Test
public void testGetTaskName() {
taskList = DataLoader.GetTask();
assertEquals("Task 1", taskList.get(0).getTaskName());
}
}