-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActivityTest.java
92 lines (77 loc) · 2.42 KB
/
ActivityTest.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
/**
* @author Caleb Martin
*/
import static org.junit.jupiter.api.Assertions.*;
import java.util.UUID;
import org.junit.*;
import java.util.ArrayList;
public class ActivityTest
{
private Activity testActivity;
private Activity nullActivity;
private Activity blankActivity;
private Activity badActivity;
@Before
public void everyTimeSetup()
{
testActivity = new Activity(Type.CREATIVE, "Testing", "1:00 PM");
nullActivity = new Activity(null, null, null);
blankActivity = new Activity(Type.CREATIVE, "", "");
badActivity = new Activity(Type.CREATIVE, "Testing", "InvalidTimeString");
}
@Test
public void testPackingListSetup()
{
//PackingList should be instantiated at object creation for ease of adding items
assertNotNull(testActivity.getPackingList());
}
@Test
public void testAddToPackingList()
{
ArrayList<String> newPackingList = new ArrayList<String>();
testActivity.setPackingList(newPackingList);
testActivity.addToPackingList("Code");
newPackingList = testActivity.getPackingList();
assertEquals("Code", newPackingList.get(0));
}
@Test
public void testToString()
{
assertEquals("Testing\n1:00 PM\nnull\n", testActivity.toString());
}
@Test
public void testConstructNullType()
{
assertTrue(nullActivity == null || nullActivity.getType() != null);
}
@Test
public void testConstructNullName()
{
assertTrue(nullActivity == null || nullActivity.getName() != null);
}
@Test
public void testConstructBlankName()
{
assertTrue(blankActivity == null || blankActivity.getName() != "");
}
@Test
public void testConstructNullTime()
{
assertTrue(nullActivity == null || nullActivity.getTime() != null);
}
@Test
public void testConstructBlankTime()
{
assertTrue(blankActivity == null || blankActivity.getTime() != "");
}
@Test
public void testConstructGoodTime() //This is meant to demonstrate that the regex can correctly identify valid times
{
assertTrue(testActivity == null || testActivity.getTime().matches("((1[0-2])|[1-9]):[0-5][0-9]\s((AM)|(PM))"));
}
@Test
public void testConstructBadTime()
{
assertTrue(badActivity == null || badActivity.getTime().matches("((1[0-2])|[1-9]):[0-5][0-9]\s((AM)|(PM))"));
}
}