|
8 | 8 | import org.junit.rules.ExpectedException;
|
9 | 9 | import org.mockito.InjectMocks;
|
10 | 10 | import org.mockito.Mock;
|
11 |
| -import org.mockserver.serialization.model.*; |
12 | 11 | import org.mockserver.logging.MockServerLogger;
|
13 | 12 | import org.mockserver.matchers.TimeToLive;
|
14 | 13 | import org.mockserver.matchers.Times;
|
15 | 14 | import org.mockserver.mock.Expectation;
|
16 | 15 | import org.mockserver.model.*;
|
| 16 | +import org.mockserver.serialization.model.*; |
17 | 17 | import org.mockserver.validator.jsonschema.JsonSchemaExpectationValidator;
|
18 | 18 |
|
19 | 19 | import java.io.IOException;
|
|
40 | 40 | public class ExpectationWithForwardSerializerTest {
|
41 | 41 |
|
42 | 42 | private final Expectation fullExpectation = new Expectation(
|
43 |
| - new HttpRequest() |
44 |
| - .withMethod("GET") |
45 |
| - .withPath("somePath") |
46 |
| - .withQueryStringParameters( |
47 |
| - param("queryParameterName", "queryParameterValue") |
48 |
| - ) |
49 |
| - .withBody("somebody") |
50 |
| - .withHeaders( |
51 |
| - header("headerName", "headerValue") |
52 |
| - ) |
53 |
| - .withCookies( |
54 |
| - cookie("cookieName", "cookieValue") |
55 |
| - ), |
56 |
| - Times.once(), |
57 |
| - TimeToLive.exactly(TimeUnit.HOURS, 2l)) |
58 |
| - .thenForward( |
59 |
| - forward() |
60 |
| - .withHost("some_host") |
61 |
| - .withPort(9090) |
62 |
| - .withScheme(HttpForward.Scheme.HTTPS) |
63 |
| - ); |
64 |
| - private final ExpectationDTO fullExpectationDTO = new ExpectationDTO() |
65 |
| - .setHttpRequest( |
66 |
| - new HttpRequestDTO() |
67 |
| - .setMethod(string("GET")) |
68 |
| - .setPath(string("somePath")) |
69 |
| - .setQueryStringParameters(new Parameters().withEntries( |
70 |
| - param("queryParameterName", "queryParameterValue") |
71 |
| - )) |
72 |
| - .setBody(BodyDTO.createDTO(exact("somebody"))) |
73 |
| - .setHeaders(new Headers().withEntries( |
74 |
| - header("headerName", "headerValue") |
75 |
| - )) |
76 |
| - .setCookies(new Cookies().withEntries( |
77 |
| - cookie("cookieName", "cookieValue") |
78 |
| - )) |
| 43 | + new HttpRequest() |
| 44 | + .withMethod("GET") |
| 45 | + .withPath("somePath") |
| 46 | + .withQueryStringParameters( |
| 47 | + param("queryParameterName", "queryParameterValue") |
79 | 48 | )
|
80 |
| - .setHttpForward( |
81 |
| - new HttpForwardDTO( |
82 |
| - new HttpForward() |
83 |
| - .withHost("some_host") |
84 |
| - .withPort(9090) |
85 |
| - .withScheme(HttpForward.Scheme.HTTPS) |
86 |
| - ) |
| 49 | + .withBody("somebody") |
| 50 | + .withHeaders( |
| 51 | + header("headerName", "headerValue") |
| 52 | + ) |
| 53 | + .withCookies( |
| 54 | + cookie("cookieName", "cookieValue") |
| 55 | + ), |
| 56 | + Times.once(), |
| 57 | + TimeToLive.exactly(TimeUnit.HOURS, 2l)) |
| 58 | + .thenForward( |
| 59 | + forward() |
| 60 | + .withHost("some_host") |
| 61 | + .withPort(9090) |
| 62 | + .withScheme(HttpForward.Scheme.HTTPS) |
| 63 | + .withDelay(new Delay(TimeUnit.SECONDS, 10)) |
| 64 | + ); |
| 65 | + private final ExpectationDTO fullExpectationDTO = new ExpectationDTO() |
| 66 | + .setHttpRequest( |
| 67 | + new HttpRequestDTO() |
| 68 | + .setMethod(string("GET")) |
| 69 | + .setPath(string("somePath")) |
| 70 | + .setQueryStringParameters(new Parameters().withEntries( |
| 71 | + param("queryParameterName", "queryParameterValue") |
| 72 | + )) |
| 73 | + .setBody(BodyDTO.createDTO(exact("somebody"))) |
| 74 | + .setHeaders(new Headers().withEntries( |
| 75 | + header("headerName", "headerValue") |
| 76 | + )) |
| 77 | + .setCookies(new Cookies().withEntries( |
| 78 | + cookie("cookieName", "cookieValue") |
| 79 | + )) |
| 80 | + ) |
| 81 | + .setHttpForward( |
| 82 | + new HttpForwardDTO( |
| 83 | + new HttpForward() |
| 84 | + .withHost("some_host") |
| 85 | + .withPort(9090) |
| 86 | + .withScheme(HttpForward.Scheme.HTTPS) |
| 87 | + .withDelay(new Delay(TimeUnit.SECONDS, 10)) |
87 | 88 | )
|
88 |
| - .setTimes(new org.mockserver.serialization.model.TimesDTO(Times.once())) |
89 |
| - .setTimeToLive(new TimeToLiveDTO(TimeToLive.exactly(TimeUnit.HOURS, 2l))); |
| 89 | + ) |
| 90 | + .setTimes(new org.mockserver.serialization.model.TimesDTO(Times.once())) |
| 91 | + .setTimeToLive(new TimeToLiveDTO(TimeToLive.exactly(TimeUnit.HOURS, 2l))); |
90 | 92 |
|
91 | 93 | @Rule
|
92 | 94 | public ExpectedException thrown = ExpectedException.none();
|
@@ -186,10 +188,10 @@ public void shouldDeserializeArrayWithError() throws IOException {
|
186 | 188 | // then
|
187 | 189 | thrown.expect(IllegalArgumentException.class);
|
188 | 190 | thrown.expectMessage("" +
|
189 |
| - "[" + NEW_LINE + |
190 |
| - " an error," + NEW_LINE + |
191 |
| - " an error" + NEW_LINE + |
192 |
| - "]"); |
| 191 | + "[" + NEW_LINE + |
| 192 | + " an error," + NEW_LINE + |
| 193 | + " an error" + NEW_LINE + |
| 194 | + "]"); |
193 | 195 |
|
194 | 196 | // when
|
195 | 197 | expectationSerializer.deserializeArray("requestBytes");
|
|
0 commit comments