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