Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ private RequestExecutor buildRequestExecutor() {
case HttpMethod.POST:
case HttpMethod.PUT:
case HttpMethod.PATCH:
return new WithBodyRequestExecutor(
httpMethod, redirect, auth, definition.application(), body);
return body != null
? new WithBodyRequestExecutor(
httpMethod, redirect, auth, definition.application(), body)
: new WithoutBodyRequestExecutor(httpMethod, redirect, auth);
case HttpMethod.DELETE:
case HttpMethod.HEAD:
case HttpMethod.OPTIONS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,27 @@ void callHttpPost_should_return_created_firstName() throws Exception {
});
}

@Test
void callHttpPost_without_body_should_not_throw() throws Exception {
mockServer.enqueue(new MockResponse(204, Headers.of(), ""));

assertDoesNotThrow(
() ->
appl.workflowDefinition(
readWorkflowFromClasspath("workflows-samples/call-http-post-no-body.yaml"))
.instance(Map.of())
.start()
.join());

RecordedRequest recordedRequest = mockServer.takeRequest();
SoftAssertions.assertSoftly(
softly -> {
softly.assertThat(recordedRequest.getMethod()).isEqualTo("POST");
softly.assertThat(recordedRequest.getUrl()).asString().contains("/api/v1/authors");
softly.assertThat(recordedRequest.getBodySize()).isEqualTo(0);
});
}
Comment thread
fjtirado marked this conversation as resolved.

@Test
void testCallHttpDelete() throws IOException, InterruptedException {
mockServer.enqueue(new MockResponse(204, Headers.of(), ""));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
document:
dsl: 1.0.0-alpha1
namespace: test
name: call-http-post-no-body
version: 1.0.0
do:
- postAuthors:
call: http
with:
method: post
endpoint:
uri: http://localhost:9876/api/v1/authors
Loading