citrusframework / citrusframework/citrus
Validation callback supresses receive HTTP message actions
- Dominant language
- Java
- Stars
- 485
- Forks
- 155
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 6
Description
**Citrus Version**
2.7.6
**Expected behavior**
In the java DSL, when setting e.g. status, in HttpClientReceiveActionBuilder, the value should be validated once the action is executed, even if a validation callback is added.
**Actual behavior**
When adding a validation callback, values that are validated via the "controlMessage"/MessageValidator mechanism in the ReceiveMessageAction class are skipped.
**Test case sample**
The following testcase should fail as the mocked response is returned with INTERNAL_SERVER_ERROR status, but the test expects OK. However, it will not fail.
```java
@Test
public void testShouldFail() {
reset(httpClient, messageConsumer, configuration);
when(httpClient.createConsumer()).thenReturn(messageConsumer);
when(httpClient.getEndpointConfiguration()).thenReturn(configuration);
when(httpClient.getActor()).thenReturn(null);
when(messageConsumer.receive(any(TestContext.class), anyLong())).thenReturn(new HttpMessage("Hello World!")
.method(HttpMethod.GET)
.uri("/test")
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.version("HTTP/1.1"));
new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {
@Override
public void execute() {
http(action -> action.client(httpClient)
.receive()
.response(HttpStatus.OK)
.version("HTTP/1.1")
.validationCallback(((message, ctx) -> Assert.assertEquals(message.getPayload(String.class), "Hello World!"))));
}
};
}
```
Contributor guide
Assessment
This issue has not been assessed yet.