-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToDoTest.java
104 lines (83 loc) · 2.68 KB
/
ToDoTest.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
import de.swtproject.doit.core.DatabaseManager;
import de.swtproject.doit.core.IntervalType;
import de.swtproject.doit.core.Priority;
import de.swtproject.doit.core.ToDo;
import org.json.JSONObject;
import org.junit.After;
import org.junit.Test;
import java.sql.SQLException;
import java.util.Date;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class ToDoTest {
private ToDo todo;
@org.junit.Before
public void beforeEach() throws SQLException {
todo = ToDo.create("task");
DatabaseManager.storeToDo(todo);
}
@After
public void after() throws SQLException {
DatabaseManager.phoenix();
}
@org.junit.Test
public void titleTest() {
todo.setTitle("test");
assertEquals("test", todo.getTitle());
}
@org.junit.Test
public void descriptionTest() {
todo.setDescription("test");
assertEquals("test", todo.getDescription());
}
@org.junit.Test
public void intervalTest() {
todo.setInterval(IntervalType.DAILY);
assertEquals(IntervalType.DAILY, todo.getInterval());
}
@org.junit.Test
public void startDateTest() {
Date d = new Date();
todo.setStart(d);
assertEquals(d, todo.getStart());
}
@org.junit.Test
public void deadlineTest() {
Date d = new Date();
todo.setDeadline(d);
assertEquals(d, todo.getDeadline());
}
@org.junit.Test
public void notifyPointTest() {
Date d = new Date();
todo.setNotifyPoint(d);
assertEquals(d, todo.getNotifyPoint());
}
@Test
public void priorityTest() {
ToDo task = ToDo.create("Test");
assertEquals(Priority.DEFAULT.name, task.getPriority().name);
task.setPriority(Priority.URGENT);
assertEquals(Priority.URGENT.name, task.getPriority().name);
}
@org.junit.Test
public void finishTest() throws SQLException {
assertTrue(todo.finish());
}
@org.junit.Test
public void deleteTest() throws SQLException {
assertTrue(todo.delete());
}
@org.junit.Test
public void toStringTest() {
assertEquals("task", todo.toString());
}
@org.junit.Test
public void serializeTest() {
JSONObject ds = todo.serialize();
assertEquals( todo.getTitle(), (String) ds.get("title") );
if (ds.has("description")) assertEquals( todo.getDescription(), (String) ds.get("description"));
if (ds.has("interval")) assertEquals( todo.getInterval().toString(), (String) ds.get("interval"));
if (ds.has("priority")) assertEquals( todo.getPriority().toString(), (String) ds.get("priority"));
}
}