|
@@ -22,6 +22,7 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.logger;
|
24
|
24
|
|
|
25
|
+import com.dmdirc.DMDircMBassador;
|
25
|
26
|
import com.dmdirc.util.ClientInfo;
|
26
|
27
|
|
27
|
28
|
import com.google.common.collect.Lists;
|
|
@@ -41,42 +42,44 @@ import static org.junit.Assert.assertTrue;
|
41
|
42
|
public class ProgramErrorTest {
|
42
|
43
|
|
43
|
44
|
@Mock private ErrorManager errorManager;
|
|
45
|
+ @Mock private DMDircMBassador eventBus;
|
44
|
46
|
@Mock private ClientInfo clientInfo;
|
45
|
47
|
|
46
|
48
|
@Test(expected = NullPointerException.class)
|
47
|
49
|
public void testConstructorNullErrorLevel() {
|
48
|
|
- new ProgramError(null, "moo", null, Lists.newArrayList(), null, new Date(), errorManager);
|
|
50
|
+ new ProgramError(null, "moo", null, Lists.newArrayList(), null, new Date(), errorManager,
|
|
51
|
+ eventBus);
|
49
|
52
|
}
|
50
|
53
|
|
51
|
54
|
@Test(expected = NullPointerException.class)
|
52
|
55
|
public void testConstructorNullMessage() {
|
53
|
56
|
new ProgramError(ErrorLevel.HIGH, null, null, Lists.newArrayList(), null, new Date(),
|
54
|
|
- errorManager);
|
|
57
|
+ errorManager, eventBus);
|
55
|
58
|
}
|
56
|
59
|
|
57
|
60
|
@Test(expected = IllegalArgumentException.class)
|
58
|
61
|
public void testConstructorEmptyMessage() {
|
59
|
62
|
new ProgramError(ErrorLevel.HIGH, "", null, Lists.newArrayList(), null, new Date(),
|
60
|
|
- errorManager);
|
|
63
|
+ errorManager, eventBus);
|
61
|
64
|
}
|
62
|
65
|
|
63
|
66
|
@Test(expected = NullPointerException.class)
|
64
|
67
|
public void testConstructorNullDate() {
|
65
|
68
|
new ProgramError(ErrorLevel.HIGH, "moo", null, Lists.newArrayList(), null, null,
|
66
|
|
- errorManager);
|
|
69
|
+ errorManager, eventBus);
|
67
|
70
|
}
|
68
|
71
|
|
69
|
72
|
@Test
|
70
|
73
|
public void testConstructorGood() {
|
71
|
74
|
new ProgramError(ErrorLevel.HIGH, "moo", new UnsupportedOperationException(),
|
72
|
|
- Lists.newArrayList(), null, new Date(), errorManager);
|
|
75
|
+ Lists.newArrayList(), null, new Date(), errorManager, eventBus);
|
73
|
76
|
}
|
74
|
77
|
|
75
|
78
|
@Test
|
76
|
79
|
public void testGetLevel() {
|
77
|
80
|
final ProgramError pe = new ProgramError(ErrorLevel.HIGH, "moo",
|
78
|
81
|
new UnsupportedOperationException(), Lists.newArrayList(), null, new Date(),
|
79
|
|
- errorManager);
|
|
82
|
+ errorManager, eventBus);
|
80
|
83
|
assertEquals(ErrorLevel.HIGH, pe.getLevel());
|
81
|
84
|
}
|
82
|
85
|
|
|
@@ -84,7 +87,7 @@ public class ProgramErrorTest {
|
84
|
87
|
public void testGetMessage() {
|
85
|
88
|
final ProgramError pe = new ProgramError(ErrorLevel.HIGH, "moo",
|
86
|
89
|
new UnsupportedOperationException(), Lists.newArrayList(), null, new Date(),
|
87
|
|
- errorManager);
|
|
90
|
+ errorManager, eventBus);
|
88
|
91
|
assertEquals("moo", pe.getMessage());
|
89
|
92
|
}
|
90
|
93
|
|
|
@@ -93,7 +96,7 @@ public class ProgramErrorTest {
|
93
|
96
|
final Date date = new Date();
|
94
|
97
|
final ProgramError pe = new ProgramError(ErrorLevel.HIGH, "moo",
|
95
|
98
|
new UnsupportedOperationException(), Lists.newArrayList(), null, date,
|
96
|
|
- errorManager);
|
|
99
|
+ errorManager, eventBus);
|
97
|
100
|
assertEquals(date, pe.getDate());
|
98
|
101
|
}
|
99
|
102
|
|
|
@@ -101,7 +104,7 @@ public class ProgramErrorTest {
|
101
|
104
|
public void testReportStatus() {
|
102
|
105
|
final ProgramError pe = new ProgramError(ErrorLevel.HIGH, "moo",
|
103
|
106
|
new UnsupportedOperationException(), Lists.newArrayList(), null, new Date(),
|
104
|
|
- errorManager);
|
|
107
|
+ errorManager, eventBus);
|
105
|
108
|
assertEquals(ErrorReportStatus.WAITING, pe.getReportStatus());
|
106
|
109
|
pe.setReportStatus(null);
|
107
|
110
|
assertEquals(ErrorReportStatus.WAITING, pe.getReportStatus());
|
|
@@ -115,7 +118,7 @@ public class ProgramErrorTest {
|
115
|
118
|
public void testToString() {
|
116
|
119
|
final ProgramError pe = new ProgramError(ErrorLevel.HIGH, "moo",
|
117
|
120
|
new UnsupportedOperationException(), Lists.newArrayList(), null, new Date(),
|
118
|
|
- errorManager);
|
|
121
|
+ errorManager, eventBus);
|
119
|
122
|
assertTrue(pe.toString().contains("moo"));
|
120
|
123
|
}
|
121
|
124
|
|
|
@@ -123,15 +126,15 @@ public class ProgramErrorTest {
|
123
|
126
|
public void testEquals() {
|
124
|
127
|
final Exception ex = new UnsupportedOperationException();
|
125
|
128
|
final ProgramError pe1 = new ProgramError(ErrorLevel.LOW, "moo",
|
126
|
|
- ex, Lists.newArrayList(), null, new Date(), errorManager);
|
|
129
|
+ ex, Lists.newArrayList(), null, new Date(), errorManager, eventBus);
|
127
|
130
|
final ProgramError pe2 = new ProgramError(ErrorLevel.LOW, "moo",
|
128
|
|
- ex, Lists.newArrayList(), null, new Date(), errorManager);
|
|
131
|
+ ex, Lists.newArrayList(), null, new Date(), errorManager, eventBus);
|
129
|
132
|
final ProgramError pe3 = new ProgramError(ErrorLevel.MEDIUM, "moo",
|
130
|
|
- ex, Lists.newArrayList(), null, new Date(), errorManager);
|
|
133
|
+ ex, Lists.newArrayList(), null, new Date(), errorManager, eventBus);
|
131
|
134
|
final ProgramError pe4 = new ProgramError(ErrorLevel.LOW, "bar",
|
132
|
|
- ex, Lists.newArrayList(), null, new Date(), errorManager);
|
|
135
|
+ ex, Lists.newArrayList(), null, new Date(), errorManager, eventBus);
|
133
|
136
|
final ProgramError pe5 = new ProgramError(ErrorLevel.LOW, "moo",
|
134
|
|
- null, Lists.newArrayList(), "Hello", new Date(), errorManager);
|
|
137
|
+ null, Lists.newArrayList(), "Hello", new Date(), errorManager, eventBus);
|
135
|
138
|
|
136
|
139
|
assertFalse(pe1.equals(null)); // NOPMD
|
137
|
140
|
assertFalse(pe1.equals("moo"));
|