1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.smartics.util.lang;
17
18 import static org.hamcrest.CoreMatchers.equalTo;
19 import static org.hamcrest.CoreMatchers.is;
20 import static org.hamcrest.Matchers.containsString;
21 import static org.junit.Assert.assertThat;
22
23 import org.junit.Test;
24 import org.junit.experimental.categories.Category;
25
26 import de.smartics.testdoc.annotations.Uut;
27 import de.smartics.testdoc.categories.type.Construction;
28
29
30
31
32 @Category(Construction.class)
33 public class NullArgumentExceptionTest
34 {
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 @Test
52 @Uut(type = NullArgumentException.class,
53 method = "NullArgumentException(java.lang.String)")
54 public void allowsToSpecifyTheNameOfTheMissingArgument()
55 {
56 final String argumentName = "testArgument";
57 final NullArgumentException uut = new NullArgumentException(argumentName);
58
59 assertThat(uut.getMessage(), containsString(argumentName));
60 }
61
62 @Test
63 @Uut(type = NullArgumentException.class,
64 method = "NullArgumentException(java.lang.String)")
65 public void allowsToLeaveOutTheNameOfTheMissingArgument()
66 {
67 final String argumentName = null;
68 final NullArgumentException uut = new NullArgumentException(argumentName);
69
70 assertThat(uut.getMessage(), is(equalTo("Argument must not be 'null'.")));
71 }
72
73 @Test
74 @Uut(type = NullArgumentException.class, method = "NullArgumentException()")
75 public void providesANoargsConstuctorAlthoughItsUseIsDiscouraged()
76 {
77 final NullArgumentException uut = new NullArgumentException();
78
79 assertThat(uut.getMessage(), is(equalTo("Argument must not be 'null'.")));
80 }
81 }