Skip to content

Commit 28bcdf4

Browse files
committed
Adding eid runtime ex test for coverage
1 parent 671c5db commit 28bcdf4

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package pl.wavesoftware.eid.exceptions;
2+
3+
import org.hamcrest.CoreMatchers;
4+
import org.junit.Rule;
5+
import org.junit.Test;
6+
import org.junit.rules.ExpectedException;
7+
8+
import javax.xml.bind.JAXBException;
9+
import java.util.UnknownFormatConversionException;
10+
11+
import static org.hamcrest.Matchers.containsString;
12+
import static org.hamcrest.Matchers.is;
13+
import static org.junit.internal.matchers.ThrowableMessageMatcher.hasMessage;
14+
15+
/**
16+
* @author Krzysztof Suszyński <[email protected]>
17+
* @since 2015-10-07
18+
*/
19+
@SuppressWarnings("ConstantConditions")
20+
public class EidRuntimeExceptionTest {
21+
22+
@Rule
23+
public ExpectedException thrown = ExpectedException.none();
24+
25+
@Test
26+
public void testGetMessage() {
27+
// then
28+
thrown.expect(EidRuntimeException.class);
29+
thrown.expectCause(CoreMatchers.<Throwable>instanceOf(JAXBException.class));
30+
thrown.expectCause(hasMessage(is((String) null)));
31+
thrown.expectMessage(containsString("20151007:212217"));
32+
thrown.expectMessage(containsString("javax.xml.bind.JAXBException\n - with linked exception:\n" +
33+
"[java.util.UnknownFormatConversionException: Conversion = 'Invalid for unit test']"));
34+
35+
// given
36+
String message = null;
37+
Throwable original = new UnknownFormatConversionException("Invalid for unit test");
38+
JAXBException cause = new JAXBException(message);
39+
cause.setLinkedException(original);
40+
throw new EidRuntimeException("20151007:212217", cause);
41+
}
42+
43+
}

0 commit comments

Comments
 (0)