Search in sources :

Example 1 with Message

use of com.consol.citrus.message.Message in project citrus-samples by christophd.

the class TodoListIT method testMessageStoreValidationCallback.

@Test
@CitrusTest
public void testMessageStoreValidationCallback() {
    http().client(todoClient).send().post("/api/todolist").name("todoRequest").messageType(MessageType.JSON).contentType(ContentType.APPLICATION_JSON.getMimeType()).payload("{\"id\":\"citrus:randomUUID()\",\"title\":\"citrus:concat('todo_',citrus:randomNumber(4))\",\"description\":\"ToDo Description\",\"done\":false}");
    echo("citrus:message(todoRequest)");
    http().client(todoClient).receive().response(HttpStatus.OK).messageType(MessageType.PLAINTEXT).payload("citrus:jsonPath(citrus:message(todoRequest.payload()), '$.id')");
    http().client(todoClient).send().get("/api/todo/citrus:jsonPath(citrus:message(todoRequest.payload()), '$.id')").accept(ContentType.APPLICATION_JSON.getMimeType());
    http().client(todoClient).receive().response(HttpStatus.OK).name("todoResponse").messageType(MessageType.JSON).validationCallback((message, context) -> {
        Message todoRequest = context.getMessageStore().getMessage("todoRequest");
        Assert.assertEquals(message.getPayload(), todoRequest.getPayload());
    });
}
Also used : Message(com.consol.citrus.message.Message) CitrusTest(com.consol.citrus.annotations.CitrusTest) Test(org.testng.annotations.Test) CitrusTest(com.consol.citrus.annotations.CitrusTest)

Aggregations

CitrusTest (com.consol.citrus.annotations.CitrusTest)1 Message (com.consol.citrus.message.Message)1 Test (org.testng.annotations.Test)1