|
1 | 1 | import static org.assertj.core.api.Assertions.assertThat; |
2 | | -import static org.junit.Assert.assertThrows; |
| 2 | +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
3 | 3 |
|
4 | 4 | import org.junit.Ignore; |
5 | 5 | import org.junit.Test; |
@@ -38,49 +38,33 @@ public void testDistanceInLongDifferentStrands() { |
38 | 38 | @Ignore("Remove to run test") |
39 | 39 | @Test |
40 | 40 | public void testValidatesFirstStrandNotLonger() { |
41 | | - IllegalArgumentException expected = |
42 | | - assertThrows( |
43 | | - IllegalArgumentException.class, |
44 | | - () -> new Hamming("AATG", "AAA")); |
45 | | - |
46 | | - assertThat(expected) |
47 | | - .hasMessage("leftStrand and rightStrand must be of equal length."); |
| 41 | + assertThatExceptionOfType(IllegalArgumentException.class) |
| 42 | + .isThrownBy(() -> new Hamming("AATG", "AAA")) |
| 43 | + .withMessage("leftStrand and rightStrand must be of equal length."); |
48 | 44 | } |
49 | 45 |
|
50 | 46 | @Ignore("Remove to run test") |
51 | 47 | @Test |
52 | 48 | public void testValidatesSecondStrandNotLonger() { |
53 | | - IllegalArgumentException expected = |
54 | | - assertThrows( |
55 | | - IllegalArgumentException.class, |
56 | | - () -> new Hamming("ATA", "AGTG")); |
57 | | - |
58 | | - assertThat(expected) |
59 | | - .hasMessage("leftStrand and rightStrand must be of equal length."); |
| 49 | + assertThatExceptionOfType(IllegalArgumentException.class) |
| 50 | + .isThrownBy(() -> new Hamming("ATA", "AGTG")) |
| 51 | + .withMessage("leftStrand and rightStrand must be of equal length."); |
60 | 52 | } |
61 | 53 |
|
62 | 54 | @Ignore("Remove to run test") |
63 | 55 | @Test |
64 | 56 | public void testDisallowLeftEmptyStrand() { |
65 | | - IllegalArgumentException expected = |
66 | | - assertThrows( |
67 | | - IllegalArgumentException.class, |
68 | | - () -> new Hamming("", "G")); |
69 | | - |
70 | | - assertThat(expected) |
71 | | - .hasMessage("left strand must not be empty."); |
| 57 | + assertThatExceptionOfType(IllegalArgumentException.class) |
| 58 | + .isThrownBy(() -> new Hamming("", "G")) |
| 59 | + .withMessage("left strand must not be empty."); |
72 | 60 | } |
73 | 61 |
|
74 | 62 | @Ignore("Remove to run test") |
75 | 63 | @Test |
76 | 64 | public void testDisallowRightEmptyStrand() { |
77 | | - IllegalArgumentException expected = |
78 | | - assertThrows( |
79 | | - IllegalArgumentException.class, |
80 | | - () -> new Hamming("G", "")); |
81 | | - |
82 | | - assertThat(expected) |
83 | | - .hasMessage("right strand must not be empty."); |
| 65 | + assertThatExceptionOfType(IllegalArgumentException.class) |
| 66 | + .isThrownBy(() -> new Hamming("G", "")) |
| 67 | + .withMessage("right strand must not be empty."); |
84 | 68 | } |
85 | 69 |
|
86 | 70 | } |
0 commit comments