@Test public void shouldHandleNullHttpRequest() { exception.expect(IllegalArgumentException.class); exception.expectMessage(containsString("verify(RequestDefinition, VerificationTimes) requires a non null RequestDefinition object")); mockServerClient.verify((RequestDefinition) null, VerificationTimes.exactly(2)); }
public MockServerClient verify(RequestDefinition... requestDefinitions) throws AssertionError { if (requestDefinitions == null || requestDefinitions.length == 0 || requestDefinitions[0] == null) { throw new IllegalArgumentException("verify(RequestDefinition...) requires a non-null non-empty array of RequestDefinition objects"); } VerificationSequence verificationSequence = new VerificationSequence().withRequests(requestDefinitions); String result = sendRequest( request() .withMethod("PUT") .withContentType(APPLICATION_JSON_UTF_8) .withPath(calculatePath("verifySequence")) .withBody(verificationSequenceSerializer.serialize(verificationSequence), StandardCharsets.UTF_8) ).getBodyAsString(); if (result != null && !result.isEmpty()) { throw new AssertionError(result); } return clientClass.cast(this); }
MockServerClient implements Stoppable { public MockServerClient verify(RequestDefinition... requestDefinitions) throws AssertionError { if (requestDefinitions == null || requestDefinitions.length == 0 || requestDefinitions[0] == null) { throw new IllegalArgumentException("verify(RequestDefinition...) requires a non-null non-empty array of RequestDefinition objects"); } VerificationSequence verificationSequence = new VerificationSequence().withRequests(requestDefinitions); String result = sendRequest( request() .withMethod("PUT") .withContentType(APPLICATION_JSON_UTF_8) .withPath(calculatePath("verifySequence")) .withBody(verificationSequenceSerializer.serialize(verificationSequence), StandardCharsets.UTF_8) ).getBodyAsString(); if (result != null && !result.isEmpty()) { throw new AssertionError(result); } return clientClass.cast(this); } }
MockServerClient implements Stoppable { public MockServerClient verify(RequestDefinition... requestDefinitions) throws AssertionError { if (requestDefinitions == null || requestDefinitions.length == 0 || requestDefinitions[0] == null) { throw new IllegalArgumentException("verify(RequestDefinition...) requires a non-null non-empty array of RequestDefinition objects"); } VerificationSequence verificationSequence = new VerificationSequence().withRequests(requestDefinitions); String result = sendRequest( request() .withMethod("PUT") .withContentType(APPLICATION_JSON_UTF_8) .withPath(calculatePath("verifySequence")) .withBody(verificationSequenceSerializer.serialize(verificationSequence), StandardCharsets.UTF_8) ).getBodyAsString(); if (result != null && !result.isEmpty()) { throw new AssertionError(result); } return clientClass.cast(this); } MockServerClient(CompletableFuture<Integer> portFuture);  MockServerClient(String host, int port);  MockServerClient(String host, int port, String contextPath); }
MockServerClient implements Stoppable { public MockServerClient verify(RequestDefinition... requestDefinitions) throws AssertionError { if (requestDefinitions == null || requestDefinitions.length == 0 || requestDefinitions[0] == null) { throw new IllegalArgumentException("verify(RequestDefinition...) requires a non-null non-empty array of RequestDefinition objects"); } VerificationSequence verificationSequence = new VerificationSequence().withRequests(requestDefinitions); String result = sendRequest( request() .withMethod("PUT") .withContentType(APPLICATION_JSON_UTF_8) .withPath(calculatePath("verifySequence")) .withBody(verificationSequenceSerializer.serialize(verificationSequence), StandardCharsets.UTF_8) ).getBodyAsString(); if (result != null && !result.isEmpty()) { throw new AssertionError(result); } return clientClass.cast(this); } MockServerClient(CompletableFuture<Integer> portFuture);  MockServerClient(String host, int port);  MockServerClient(String host, int port, String contextPath); MockServerClient setRequestOverride(HttpRequest requestOverride); boolean isSecure(); MockServerClient withSecure(boolean secure); InetSocketAddress remoteAddress(); String contextPath(); Integer getPort(); MockServerClient openUI(); MockServerClient openUI(TimeUnit timeUnit, long pause); @Deprecated @SuppressWarnings({"DeprecatedIsStillUsed", "RedundantSuppression"}) boolean isRunning(); @Deprecated boolean isRunning(int attempts, long timeout, TimeUnit timeUnit); boolean hasStopped(); boolean hasStopped(int attempts, long timeout, TimeUnit timeUnit); boolean hasStarted(); boolean hasStarted(int attempts, long timeout, TimeUnit timeUnit); List<Integer> bind(Integer... ports); Future<MockServerClient> stopAsync(); void stop(); Future<MockServerClient> stop(boolean ignoreFailure); @Override void close(); MockServerClient reset(); MockServerClient clear(RequestDefinition requestDefinition); MockServerClient clear(ExpectationId expectationId); MockServerClient clear(RequestDefinition requestDefinition, ClearType type); MockServerClient clear(ExpectationId expectationId, ClearType type); MockServerClient verify(RequestDefinition... requestDefinitions); MockServerClient verify(ExpectationId... expectationIds); @SuppressWarnings("DuplicatedCode") MockServerClient verify(RequestDefinition requestDefinition, VerificationTimes times); @SuppressWarnings("DuplicatedCode") MockServerClient verify(ExpectationId expectationId, VerificationTimes times); @SuppressWarnings({"DuplicatedCode", "UnusedReturnValue"}) MockServerClient verifyZeroInteractions(); RequestDefinition[] retrieveRecordedRequests(RequestDefinition requestDefinition); String retrieveRecordedRequests(RequestDefinition requestDefinition, Format format); LogEventRequestAndResponse[] retrieveRecordedRequestsAndResponses(RequestDefinition requestDefinition); String retrieveRecordedRequestsAndResponses(RequestDefinition requestDefinition, Format format); Expectation[] retrieveRecordedExpectations(RequestDefinition requestDefinition); String retrieveRecordedExpectations(RequestDefinition requestDefinition, Format format); String retrieveLogMessages(RequestDefinition requestDefinition); String[] retrieveLogMessagesArray(RequestDefinition requestDefinition); ForwardChainExpectation when(RequestDefinition requestDefinition); ForwardChainExpectation when(RequestDefinition requestDefinition, Times times); ForwardChainExpectation when(RequestDefinition requestDefinition, Times times, TimeToLive timeToLive); ForwardChainExpectation when(RequestDefinition requestDefinition, Times times, TimeToLive timeToLive, Integer priority); Expectation[] upsert(OpenAPIExpectation... openAPIExpectations); Expectation[] upsert(Expectation... expectations); @Deprecated Expectation[] sendExpectation(Expectation... expectations); Expectation[] retrieveActiveExpectations(RequestDefinition requestDefinition); String retrieveActiveExpectations(RequestDefinition requestDefinition, Format format); }
MockServerClient implements Stoppable { public MockServerClient verify(RequestDefinition... requestDefinitions) throws AssertionError { if (requestDefinitions == null || requestDefinitions.length == 0 || requestDefinitions[0] == null) { throw new IllegalArgumentException("verify(RequestDefinition...) requires a non-null non-empty array of RequestDefinition objects"); } VerificationSequence verificationSequence = new VerificationSequence().withRequests(requestDefinitions); String result = sendRequest( request() .withMethod("PUT") .withContentType(APPLICATION_JSON_UTF_8) .withPath(calculatePath("verifySequence")) .withBody(verificationSequenceSerializer.serialize(verificationSequence), StandardCharsets.UTF_8) ).getBodyAsString(); if (result != null && !result.isEmpty()) { throw new AssertionError(result); } return clientClass.cast(this); } MockServerClient(CompletableFuture<Integer> portFuture);  MockServerClient(String host, int port);  MockServerClient(String host, int port, String contextPath); MockServerClient setRequestOverride(HttpRequest requestOverride); boolean isSecure(); MockServerClient withSecure(boolean secure); InetSocketAddress remoteAddress(); String contextPath(); Integer getPort(); MockServerClient openUI(); MockServerClient openUI(TimeUnit timeUnit, long pause); @Deprecated @SuppressWarnings({"DeprecatedIsStillUsed", "RedundantSuppression"}) boolean isRunning(); @Deprecated boolean isRunning(int attempts, long timeout, TimeUnit timeUnit); boolean hasStopped(); boolean hasStopped(int attempts, long timeout, TimeUnit timeUnit); boolean hasStarted(); boolean hasStarted(int attempts, long timeout, TimeUnit timeUnit); List<Integer> bind(Integer... ports); Future<MockServerClient> stopAsync(); void stop(); Future<MockServerClient> stop(boolean ignoreFailure); @Override void close(); MockServerClient reset(); MockServerClient clear(RequestDefinition requestDefinition); MockServerClient clear(ExpectationId expectationId); MockServerClient clear(RequestDefinition requestDefinition, ClearType type); MockServerClient clear(ExpectationId expectationId, ClearType type); MockServerClient verify(RequestDefinition... requestDefinitions); MockServerClient verify(ExpectationId... expectationIds); @SuppressWarnings("DuplicatedCode") MockServerClient verify(RequestDefinition requestDefinition, VerificationTimes times); @SuppressWarnings("DuplicatedCode") MockServerClient verify(ExpectationId expectationId, VerificationTimes times); @SuppressWarnings({"DuplicatedCode", "UnusedReturnValue"}) MockServerClient verifyZeroInteractions(); RequestDefinition[] retrieveRecordedRequests(RequestDefinition requestDefinition); String retrieveRecordedRequests(RequestDefinition requestDefinition, Format format); LogEventRequestAndResponse[] retrieveRecordedRequestsAndResponses(RequestDefinition requestDefinition); String retrieveRecordedRequestsAndResponses(RequestDefinition requestDefinition, Format format); Expectation[] retrieveRecordedExpectations(RequestDefinition requestDefinition); String retrieveRecordedExpectations(RequestDefinition requestDefinition, Format format); String retrieveLogMessages(RequestDefinition requestDefinition); String[] retrieveLogMessagesArray(RequestDefinition requestDefinition); ForwardChainExpectation when(RequestDefinition requestDefinition); ForwardChainExpectation when(RequestDefinition requestDefinition, Times times); ForwardChainExpectation when(RequestDefinition requestDefinition, Times times, TimeToLive timeToLive); ForwardChainExpectation when(RequestDefinition requestDefinition, Times times, TimeToLive timeToLive, Integer priority); Expectation[] upsert(OpenAPIExpectation... openAPIExpectations); Expectation[] upsert(Expectation... expectations); @Deprecated Expectation[] sendExpectation(Expectation... expectations); Expectation[] retrieveActiveExpectations(RequestDefinition requestDefinition); String retrieveActiveExpectations(RequestDefinition requestDefinition, Format format);  }