Skip to content

Commit 7041453

Browse files
committed
Issue #66 - Add test for default order() method
1 parent 09855ab commit 7041453

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

src/test/java/ch/powerunit/extensions/exceptions/ExceptionMapperTest.java

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -191,29 +191,27 @@ public void testForOrderedOneElementV1() {
191191
new IllegalArgumentException("test"))
192192
.is(both(exceptionMessage("testme1")).and(instanceOf(WrappedException.class)));
193193
}
194-
194+
195195
@Test
196196
public void testForOrderedOneElementV2Default() {
197-
assertThatFunction(
198-
ExceptionMapper.forOrderedExceptions(List.of(new ExceptionMapper() {
199-
200-
@Override
201-
public RuntimeException apply(Exception t) {
202-
return new WrappedException("testme1");
203-
}
204-
205-
@Override
206-
public Class<? extends Exception> targetException() {
207-
return Exception.class;
208-
}
209-
210-
})),
211-
new IllegalArgumentException("test"))
212-
.is(both(exceptionMessage("testme1")).and(instanceOf(WrappedException.class)));
197+
assertThatFunction(ExceptionMapper.forOrderedExceptions(List.of(new ExceptionMapper() {
198+
199+
@Override
200+
public RuntimeException apply(Exception t) {
201+
return new WrappedException("testme1");
202+
}
203+
204+
@Override
205+
public Class<? extends Exception> targetException() {
206+
return Exception.class;
207+
}
208+
209+
})), new IllegalArgumentException("test"))
210+
.is(both(exceptionMessage("testme1")).and(instanceOf(WrappedException.class)));
213211
}
214212

215213
@Test
216-
public void testForOrderedTwoElement() {
214+
public void testForOrderedTwoElementV1() {
217215
assertThatFunction(ExceptionMapper.forOrderedExceptions(
218216
List.of(ExceptionMapper.forException(RuntimeException.class, e -> new WrappedException("testme1"), 2),
219217
ExceptionMapper.forException(IllegalArgumentException.class,
@@ -222,6 +220,25 @@ public void testForOrderedTwoElement() {
222220
.is(both(exceptionMessage("testme2")).and(instanceOf(WrappedException.class)));
223221
}
224222

223+
@Test
224+
public void testForOrderedTwoElementV2Default() {
225+
assertThatFunction(ExceptionMapper.forOrderedExceptions(List.of(new ExceptionMapper() {
226+
227+
@Override
228+
public RuntimeException apply(Exception t) {
229+
return new WrappedException("testme1");
230+
}
231+
232+
@Override
233+
public Class<? extends Exception> targetException() {
234+
return Exception.class;
235+
}
236+
237+
}, ExceptionMapper.forException(IllegalArgumentException.class, e -> new WrappedException("testme2"), -1))),
238+
new IllegalArgumentException("test"))
239+
.is(both(exceptionMessage("testme2")).and(instanceOf(WrappedException.class)));
240+
}
241+
225242
@Test
226243
public void testJaxbException() {
227244
ExceptionMapper.jaxbExceptionMapper().apply(new JAXBException("msg"));

0 commit comments

Comments
 (0)