I have a (Quarkus) integration test like this:
@QuarkusTest
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class MyTest extends CamelQuarkusTestSupport {
@EndpointInject("mock:my-mock")
MockEndpoint myMockEndpoint;
@Override
protected void doAfterConstruct() throws Exception {
adviceWith(context, "my-route", route -> route.weaveById("my-endpoint")
.replace()
.to("mock:my-mock"));
}
@Test
void myTest() throws Exception {
myMockEndpoint.expectedMessageCount(1);
// How to assert (multiple) parts of received body?
// Do testing...
myMockEndpoint.assertIsSatisfied();
}
}
I know I can assert the entire body with:
myMockEndpoint.expectedBodiesReceived("Entire body");
Now if the (XML) payload is actually bigger, I wonder how I can assert multiple parts of it? Something like:
myMockEndpoint.expectedBodyReceived() // returns AssertionClause
.body() // returns MockValueBuilder
.contains("Some part") // returns Predicate
.contains("Another part"); // not possible
However, chaining as above is not possible. Also, if I only have a single contains
and end the expression/statement aferwards, the assertion is not taken into account. The test always passed, no matter what is passed to contains
.
So, how can I assert multiple parts of the received body with Apache Camel’s MockEndpoint
?