1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.lang3;
18
19 import static org.junit.jupiter.api.Assertions.assertEquals;
20 import static org.junit.jupiter.api.Assertions.assertNotNull;
21 import static org.junit.jupiter.api.Assertions.assertNull;
22
23 import org.junit.jupiter.api.Test;
24
25
26
27
28 public class NotImplementedExceptionTest extends AbstractLangTest {
29
30 private void assertCorrect(final String assertMessage, final NotImplementedException nie, final String message, final Throwable nested, final String code) {
31 assertNotNull(nie, assertMessage + ": target is null");
32 assertEquals(message, nie.getMessage(), assertMessage + ": Message not equal");
33 assertEquals(nested, nie.getCause(), assertMessage + ": Nested throwable not equal");
34 assertEquals(code, nie.getCode(), assertMessage + ": Code not equal");
35 }
36
37 @Test
38 public void testConstructors() {
39 final Throwable nested = new RuntimeException();
40 final String message = "Not Implemented";
41 final String code = "CODE";
42
43 NotImplementedException nie = new NotImplementedException(message);
44 assertCorrect("Issue in (String)", nie, message, null, null);
45 nie = new NotImplementedException(nested);
46 assertCorrect("Issue in (Throwable)", nie, nested.toString(), nested, null);
47 nie = new NotImplementedException(message, nested);
48 assertCorrect("Issue in (String, Throwable)", nie, message, nested, null);
49 nie = new NotImplementedException(message, code);
50 assertCorrect("Issue in (String, String)", nie, message, null, code);
51 nie = new NotImplementedException(nested, code);
52 assertCorrect("Issue in (Throwable, String)", nie, nested.toString(), nested, code);
53 nie = new NotImplementedException(message, nested, code);
54 assertCorrect("Issue in (String, Throwable, String)", nie, message, nested, code);
55
56 assertNull(new NotImplementedException().getCode());
57 }
58 }