1 package com.atlassian.plugin.event;
2
3 import junit.framework.TestCase;
4
5 import java.util.List;
6 import java.util.ArrayList;
7
8
9
10
11 @SuppressWarnings ({ "ThrowableResultOfMethodCallIgnored", "ThrowableInstanceNeverThrown" })
12 public class TestNotificationException extends TestCase
13 {
14 public void testSingletonConstructor() throws Exception
15 {
16 Exception cause = new Exception("I don't like it");
17 NotificationException notificationException = new NotificationException(cause);
18
19 assertEquals(cause, notificationException.getCause());
20 assertEquals(1, notificationException.getAllCauses().size());
21 assertEquals(cause, notificationException.getAllCauses().get(0));
22 }
23
24 public void testListConstructor() throws Exception
25 {
26 Exception cause1 = new Exception("I don't like it");
27 Exception cause2 = new Exception("Me neither");
28 final List<Throwable> causes = new ArrayList<Throwable>();
29 causes.add(cause1);
30 causes.add(cause2);
31
32 NotificationException notificationException = new NotificationException(causes);
33
34 assertEquals(cause1, notificationException.getCause());
35 assertEquals(2, notificationException.getAllCauses().size());
36 assertEquals(cause1, notificationException.getAllCauses().get(0));
37 assertEquals(cause2, notificationException.getAllCauses().get(1));
38 }
39
40 public void testListConstructorInvalid() throws Exception
41 {
42 try
43 {
44 new NotificationException((List) null);
45 fail("Expected NullPointerException");
46 }
47 catch (NullPointerException e)
48 {
49
50 }
51
52 try
53 {
54 new NotificationException(new ArrayList<Throwable>());
55 fail("Expected IndexOutOfBoundsException");
56 }
57 catch (IndexOutOfBoundsException e)
58 {
59
60 }
61 }
62 }