|
1 | 1 | package org.juv25d.http; |
2 | 2 |
|
| 3 | +import org.junit.jupiter.api.BeforeEach; |
3 | 4 | import org.junit.jupiter.api.Test; |
4 | 5 |
|
5 | | -import static org.assertj.core.api.Assertions.assertThat; |
6 | | -import static org.assertj.core.api.Assertions.assertThatCode; |
| 6 | +import static org.junit.jupiter.api.Assertions.*; |
7 | 7 |
|
8 | | -class HttpResponseTest { |
| 8 | +public class HttpResponseTest { |
| 9 | + |
| 10 | + private HttpResponse response; |
| 11 | + |
| 12 | + @BeforeEach |
| 13 | + void setUp() { |
| 14 | + response = new HttpResponse(); |
| 15 | + } |
| 16 | + |
| 17 | + @Test |
| 18 | + void shouldReturnDefaultStatusCode() { |
| 19 | + assertEquals(200, response.statusCode()); |
| 20 | + } |
9 | 21 |
|
10 | 22 | @Test |
11 | | - void defaultConstructor_hasSafeDefaults_andSetHeaderDoesNotThrow() { |
12 | | - HttpResponse response = new HttpResponse(); |
| 23 | + void shouldReturnDefaultText() { |
| 24 | + assertEquals("OK", response.statusText()); |
| 25 | + } |
13 | 26 |
|
14 | | - assertThat(response.statusCode()).isEqualTo(200); |
15 | | - assertThat(response.statusText()).isEqualTo("OK"); |
16 | | - assertThat(response.headers()).isNotNull(); |
17 | | - assertThat(response.body()).isNotNull(); |
18 | | - assertThat(response.body()).isEmpty(); |
| 27 | + @Test |
| 28 | + void shouldThrowExceptionWhenStatusTextIsNull() { |
| 29 | + assertThrows(NullPointerException.class, () -> response.setStatusText(null)); |
| 30 | + } |
19 | 31 |
|
20 | | - assertThatCode(() -> response.setHeader("Content-Type", "text/plain")) |
21 | | - .doesNotThrowAnyException(); |
| 32 | + @Test |
| 33 | + void shouldHaveEmptyHeaderByDefault() { |
| 34 | + assertTrue(response.headers().isEmpty()); |
| 35 | + } |
22 | 36 |
|
23 | | - assertThat(response.headers()).containsEntry("Content-Type", "text/plain"); |
| 37 | + @Test |
| 38 | + void shouldHaveEmptyBodyByDefault() { |
| 39 | + assertArrayEquals(new byte[0], response.body()); |
24 | 40 | } |
25 | 41 | } |
0 commit comments