|
13 | 13 | */ |
14 | 14 | package feign.template; |
15 | 15 |
|
16 | | -import static org.hamcrest.CoreMatchers.equalTo; |
17 | | -import static org.junit.Assert.assertEquals; |
18 | | -import static org.junit.Assert.assertThat; |
| 16 | +import org.junit.Test; |
19 | 17 | import java.util.ArrayList; |
20 | 18 | import java.util.Arrays; |
21 | 19 | import java.util.Collections; |
22 | | -import java.util.Map; |
23 | | -import org.junit.Rule; |
24 | | -import org.junit.Test; |
25 | | -import org.junit.rules.ExpectedException; |
| 20 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 21 | +import static org.hamcrest.Matchers.equalTo; |
| 22 | +import static org.junit.Assert.assertEquals; |
| 23 | +import static org.junit.Assert.assertThrows; |
26 | 24 |
|
27 | 25 | public class HeaderTemplateTest { |
28 | 26 |
|
29 | | - @Rule |
30 | | - public ExpectedException exception = ExpectedException.none(); |
31 | | - |
32 | | - @Test(expected = IllegalArgumentException.class) |
| 27 | + @Test |
33 | 28 | public void it_should_throw_exception_when_name_is_null() { |
34 | | - HeaderTemplate.create(null, Collections.singletonList("test")); |
35 | | - exception.expectMessage("name is required."); |
| 29 | + IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, |
| 30 | + () -> HeaderTemplate.create(null, Collections.singletonList("test"))); |
| 31 | + assertEquals("name is required.", exception.getMessage()); |
36 | 32 | } |
37 | 33 |
|
38 | | - @Test(expected = IllegalArgumentException.class) |
| 34 | + @Test |
39 | 35 | public void it_should_throw_exception_when_name_is_empty() { |
40 | | - HeaderTemplate.create("", Collections.singletonList("test")); |
41 | | - exception.expectMessage("name is required."); |
| 36 | + IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, |
| 37 | + () -> HeaderTemplate.create("", Collections.singletonList("test"))); |
| 38 | + assertEquals("name is required.", exception.getMessage()); |
42 | 39 | } |
43 | 40 |
|
44 | | - @Test(expected = IllegalArgumentException.class) |
| 41 | + @Test |
45 | 42 | public void it_should_throw_exception_when_value_is_null() { |
46 | | - HeaderTemplate.create("test", null); |
47 | | - exception.expectMessage("values are required"); |
| 43 | + IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, |
| 44 | + () -> HeaderTemplate.create("test", null)); |
| 45 | + assertEquals("values are required", exception.getMessage()); |
48 | 46 | } |
49 | 47 |
|
50 | 48 | @Test |
@@ -111,9 +109,8 @@ public void append_should_preserve_order() { |
111 | 109 | public void it_should_support_http_date() { |
112 | 110 | HeaderTemplate headerTemplate = |
113 | 111 | HeaderTemplate.create("Expires", Collections.singletonList("{expires}")); |
114 | | - assertEquals( |
| 112 | + assertEquals("Wed, 4 Jul 2001 12:08:56 -0700", |
115 | 113 | headerTemplate.expand( |
116 | | - Collections.singletonMap("expires", "Wed, 4 Jul 2001 12:08:56 -0700")), |
117 | | - "Wed, 4 Jul 2001 12:08:56 -0700"); |
| 114 | + Collections.singletonMap("expires", "Wed, 4 Jul 2001 12:08:56 -0700"))); |
118 | 115 | } |
119 | 116 | } |
0 commit comments