■ ■ ■ ■ ■ ■
common/src/test/java/com/google/tsunami/common/net/http/HttpResponseTest.java
| skipped 20 lines |
21 | 21 | | import static org.junit.Assert.assertThrows; |
22 | 22 | | import static org.junit.Assert.assertTrue; |
23 | 23 | | |
24 | | - | import com.google.gson.JsonSyntaxException; |
25 | 24 | | import com.google.protobuf.ByteString; |
26 | 25 | | import okhttp3.HttpUrl; |
27 | 26 | | import org.junit.Test; |
| skipped 41 lines |
69 | 68 | | } |
70 | 69 | | |
71 | 70 | | @Test |
72 | | - | public void bodyJson_whenNonJsonResponseBody_throwsJsonSyntaxException() { |
| 71 | + | public void bodyJson_whenNonJsonResponseBody_returnsEmptyOptional() { |
73 | 72 | | HttpResponse httpResponse = |
74 | 73 | | HttpResponse.builder() |
75 | 74 | | .setStatus(HttpStatus.OK) |
| skipped 2 lines |
78 | 77 | | .setResponseUrl(TEST_URL) |
79 | 78 | | .build(); |
80 | 79 | | |
81 | | - | assertThrows(JsonSyntaxException.class, httpResponse::bodyJson); |
| 80 | + | assertThat(httpResponse.bodyJson()).isEmpty(); |
82 | 81 | | } |
83 | 82 | | |
84 | 83 | | @Test |
| skipped 24 lines |
109 | 108 | | } |
110 | 109 | | |
111 | 110 | | @Test |
112 | | - | public void jsonFieldEqualsToValue_whenNonJsonResponseBody_throwsJsonSyntaxException() { |
| 111 | + | public void jsonFieldEqualsToValue_whenNonJsonResponseBody_returnsEmptyOptional() { |
113 | 112 | | HttpResponse httpResponse = |
114 | 113 | | HttpResponse.builder() |
115 | 114 | | .setStatus(HttpStatus.OK) |
| skipped 2 lines |
118 | 117 | | .setResponseUrl(TEST_URL) |
119 | 118 | | .build(); |
120 | 119 | | |
121 | | - | assertThrows( |
122 | | - | JsonSyntaxException.class, () -> httpResponse.jsonFieldEqualsToValue("field", "value")); |
| 120 | + | assertThat(httpResponse.bodyJson()).isEmpty(); |
123 | 121 | | } |
124 | 122 | | |
125 | 123 | | @Test |
| skipped 25 lines |