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 BlankArgumentExceptionTest
34 {
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 @Test
52 @Uut(type = BlankArgumentException.class, method = "BlankArgumentException(java.lang.String)")
53 public void allowsToSpecifyTheNameOfTheMissingArgument()
54 {
55 final String argumentName = "testArgument";
56 final BlankArgumentException uut = new BlankArgumentException(argumentName);
57
58 assertThat(uut.getMessage(), containsString(argumentName));
59 }
60
61 @Test
62 @Uut(type = BlankArgumentException.class, method = "BlankArgumentException(java.lang.String)")
63 public void allowsToLeaveOutTheNameOfTheMissingArgument()
64 {
65 final String argumentName = null;
66 final BlankArgumentException uut = new BlankArgumentException(argumentName);
67
68 assertThat(uut.getMessage(), is(equalTo("Argument must not be blank.")));
69 }
70
71 @Test
72 @Uut(type = BlankArgumentException.class, method = "BlankArgumentException()")
73 public void providesANoargsConstuctorAlthoughItsUseIsDiscouraged()
74 {
75 final BlankArgumentException uut = new BlankArgumentException();
76
77 assertThat(uut.getMessage(), is(equalTo("Argument must not be blank.")));
78 }
79 }