Search in sources :

Example 21 with CitrusTest

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);
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) CitrusTest(com.consol.citrus.annotations.CitrusTest) Test(org.testng.annotations.Test) CitrusTest(com.consol.citrus.annotations.CitrusTest)

Example 22 with CitrusTest

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());
    });
}
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)22 Test (org.testng.annotations.Test)12 TestContext (com.consol.citrus.context.TestContext)8 ClassPathResource (org.springframework.core.io.ClassPathResource)7 IteratingConditionExpression (com.consol.citrus.container.IteratingConditionExpression)6 SoapAttachment (com.consol.citrus.ws.message.SoapAttachment)4 JmsEndpoint (com.consol.citrus.jms.endpoint.JmsEndpoint)3 TodoEntry (com.consol.citrus.samples.todolist.model.TodoEntry)2 BinarySoapAttachmentValidator (com.consol.citrus.ws.validation.BinarySoapAttachmentValidator)2 UUID (java.util.UUID)2 IncidentType (org.citrusframework.schema.samples.incidentmanager.v1.IncidentType)2 Message (com.consol.citrus.message.Message)1