use of com.consol.citrus.annotations.CitrusTest in project citrus-samples by christophd.
the class TodoListIT method testMailReportJson.
@Test
@CitrusTest
public void testMailReportJson() {
variable("todoId", "citrus:randomUUID()");
variable("todoName", "citrus:concat('todo_', citrus:randomNumber(4))");
variable("todoDescription", "Description: ${todoName}");
mailServer.getMarshaller().setType(MessageType.JSON.name());
clearTodoList();
http().client(todoClient).send().post("/api/todolist").messageType(MessageType.JSON).contentType(ContentType.APPLICATION_JSON.getMimeType()).payload("{ \"id\": \"${todoId}\", \"title\": \"${todoName}\", \"description\": \"${todoDescription}\"}");
http().client(todoClient).receive().response(HttpStatus.OK).messageType(MessageType.PLAINTEXT).payload("${todoId}");
variable("entryCount", "1");
http().client(todoClient).send().get("/api/reporting/mail");
echo("Receive reporting mail");
receive(mailServer).messageType(MessageType.JSON).payload(new ClassPathResource("templates/mail.json")).header(CitrusMailMessageHeaders.MAIL_SUBJECT, "ToDo report");
send(mailServer).payload(new ClassPathResource("templates/mail-response.json"));
http().client(todoClient).receive().response(HttpStatus.OK);
}
use of com.consol.citrus.annotations.CitrusTest 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());
});
}
Aggregations