|
6 | 6 |
|
7 | 7 | package com.offbytwo.jenkins.helper;
|
8 | 8 |
|
9 |
| -import static org.assertj.core.api.Assertions.assertThat; |
10 |
| - |
11 |
| -import org.junit.Rule; |
12 | 9 | import org.junit.Test;
|
13 |
| -import org.junit.rules.ExpectedException; |
14 | 10 |
|
15 |
| -import com.offbytwo.jenkins.helper.Range; |
| 11 | +import static org.assertj.core.api.Assertions.assertThat; |
| 12 | +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; |
16 | 13 |
|
17 | 14 | /**
|
18 | 15 | * <ul>
|
|
23 | 20 | * The same as {0,N}.</li>
|
24 | 21 | * <li>{N}: Just retrieve the N-th element. The same as {N,N+1}.</li>
|
25 | 22 | * </ul>
|
26 |
| - * |
| 23 | + * |
27 | 24 | * @author Karl Heinz Marbaise
|
28 | 25 | */
|
29 | 26 | public class RangeTest {
|
@@ -56,27 +53,24 @@ public void onlyGiven() {
|
56 | 53 | assertThat(r.getRangeString()).isEqualTo(getEscaped("3,4"));
|
57 | 54 | }
|
58 | 55 |
|
59 |
| - @Rule |
60 |
| - public ExpectedException exception = ExpectedException.none(); |
61 |
| - |
62 | 56 | @Test
|
63 | 57 | public void toIsGivenLargerThanFromShouldResultInIllegalArgumentException() {
|
64 |
| - exception.expect(IllegalArgumentException.class); |
65 |
| - exception.expectMessage("to must be greater than from"); |
66 |
| - Range.build().from(5).to(1); |
| 58 | + assertThatIllegalArgumentException() |
| 59 | + .isThrownBy(() -> Range.build().from(5).to(1)) |
| 60 | + .withMessage("to must be greater than from"); |
67 | 61 | }
|
68 | 62 |
|
69 | 63 | @Test
|
70 | 64 | public void fromGivenNegativeValueShouldResultInIllegalArgumentException() {
|
71 |
| - exception.expect(IllegalArgumentException.class); |
72 |
| - exception.expectMessage("from value must be greater or equal null."); |
73 |
| - Range.build().from(-1); |
| 65 | + assertThatIllegalArgumentException() |
| 66 | + .isThrownBy(() -> Range.build().from(-1)) |
| 67 | + .withMessage("from value must be greater or equal null."); |
74 | 68 | }
|
75 | 69 |
|
76 | 70 | @Test
|
77 | 71 | public void fromGivenPositiveToNegativeValueShouldResultInIllegalArgumentException() {
|
78 |
| - exception.expect(IllegalArgumentException.class); |
79 |
| - exception.expectMessage("to must be greater or equal null."); |
80 |
| - Range.build().from(5).to(-1); |
| 72 | + assertThatIllegalArgumentException() |
| 73 | + .isThrownBy(() -> Range.build().from(5).to(-1)) |
| 74 | + .withMessage("to must be greater or equal null."); |
81 | 75 | }
|
82 | 76 | }
|
0 commit comments