Skip to content

Commit ed1bcb9

Browse files
committed
improved tests to add delay field
1 parent 58400a1 commit ed1bcb9

File tree

2 files changed

+60
-55
lines changed

2 files changed

+60
-55
lines changed

mockserver-core/src/test/java/org/mockserver/serialization/ExpectationWithForwardSerializerTest.java

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
import org.junit.rules.ExpectedException;
99
import org.mockito.InjectMocks;
1010
import org.mockito.Mock;
11-
import org.mockserver.serialization.model.*;
1211
import org.mockserver.logging.MockServerLogger;
1312
import org.mockserver.matchers.TimeToLive;
1413
import org.mockserver.matchers.Times;
1514
import org.mockserver.mock.Expectation;
1615
import org.mockserver.model.*;
16+
import org.mockserver.serialization.model.*;
1717
import org.mockserver.validator.jsonschema.JsonSchemaExpectationValidator;
1818

1919
import java.io.IOException;
@@ -40,53 +40,55 @@
4040
public class ExpectationWithForwardSerializerTest {
4141

4242
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")
7948
)
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))
8788
)
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)));
9092

9193
@Rule
9294
public ExpectedException thrown = ExpectedException.none();
@@ -186,10 +188,10 @@ public void shouldDeserializeArrayWithError() throws IOException {
186188
// then
187189
thrown.expect(IllegalArgumentException.class);
188190
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+
"]");
193195

194196
// when
195197
expectationSerializer.deserializeArray("requestBytes");

mockserver-core/src/test/java/org/mockserver/serialization/ExpectationWithOverrideForwardedRequestSerializerTest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
import org.junit.rules.ExpectedException;
99
import org.mockito.InjectMocks;
1010
import org.mockito.Mock;
11-
import org.mockserver.serialization.model.*;
1211
import org.mockserver.logging.MockServerLogger;
1312
import org.mockserver.matchers.TimeToLive;
1413
import org.mockserver.matchers.Times;
1514
import org.mockserver.mock.Expectation;
1615
import org.mockserver.model.*;
16+
import org.mockserver.serialization.model.*;
1717
import org.mockserver.validator.jsonschema.JsonSchemaExpectationValidator;
1818

1919
import java.io.IOException;
@@ -51,10 +51,12 @@ public class ExpectationWithOverrideForwardedRequestSerializerTest {
5151
Times.once(),
5252
TimeToLive.exactly(TimeUnit.HOURS, 2l))
5353
.thenForward(
54-
new HttpOverrideForwardedRequest().withHttpRequest(
55-
request("some_overridden_path")
56-
.withBody("some_overridden_body")
57-
)
54+
new HttpOverrideForwardedRequest()
55+
.withHttpRequest(
56+
request("some_overridden_path")
57+
.withBody("some_overridden_body")
58+
)
59+
.withDelay(new Delay(TimeUnit.SECONDS, 10))
5860
);
5961
private final ExpectationDTO fullExpectationDTO = new ExpectationDTO()
6062
.setHttpRequest(
@@ -79,6 +81,7 @@ public class ExpectationWithOverrideForwardedRequestSerializerTest {
7981
request("some_overridden_path")
8082
.withBody("some_overridden_body")
8183
)
84+
.withDelay(new Delay(TimeUnit.SECONDS, 10))
8285
)
8386
)
8487
.setTimes(new org.mockserver.serialization.model.TimesDTO(Times.once()))

0 commit comments

Comments
 (0)