use of com.consol.citrus.context.TestContext in project citrus-samples by christophd.
the class TodoListIT method testObjectMarshalling.
@Test
@CitrusTest
public void testObjectMarshalling() {
final UUID uuid = UUID.randomUUID();
variable("todoId", uuid.toString());
variable("todoName", "citrus:concat('todo_', citrus:randomNumber(4))");
variable("todoDescription", "Description: ${todoName}");
http().client(todoClient).send().post("/api/todolist").contentType(ContentType.APPLICATION_XML.getMimeType()).payload(new TodoEntry(uuid, "${todoName}", "${todoDescription}"), marshaller);
http().client(todoClient).receive().response(HttpStatus.OK).messageType(MessageType.PLAINTEXT).payload("${todoId}");
http().client(todoClient).send().get("/api/todo/${todoId}").accept(ContentType.APPLICATION_XML.getMimeType());
http().client(todoClient).receive().response(HttpStatus.OK).validationCallback(new XmlMarshallingValidationCallback<TodoEntry>(marshaller) {
@Override
public void validate(TodoEntry todoEntry, Map<String, Object> headers, TestContext context) {
Assert.assertNotNull(todoEntry);
Assert.assertEquals(todoEntry.getId(), uuid);
}
});
}
use of com.consol.citrus.context.TestContext in project fabric8-maven-plugin by fabric8io.
the class Verify method createTestContext.
public static TestContext createTestContext() {
TestContext context = new TestContext();
context.getValidationMatcherRegistry().getValidationMatcherLibraries().add(new ValidationMatcherConfig().getValidationMatcherLibrary());
return context;
}
use of com.consol.citrus.context.TestContext in project citrus-samples by christophd.
the class PlaceOrdersHttpIT method placeCaramelCookieOrder.
@CitrusTest
public void placeCaramelCookieOrder() {
variable("orderId", Functions.randomNumber(10L, null));
http().client(bakeryClient).send().post("/order").contentType(ContentType.APPLICATION_JSON.getMimeType()).payload("{ \"order\": { \"type\": \"caramel\", \"id\": ${orderId}, \"amount\": 1}}");
repeatOnError().until(new IteratingConditionExpression() {
@Override
public boolean evaluate(int index, TestContext context) {
return index > 20;
}
}).autoSleep(100L).actions(http().client(reportingClient).send().get("/reporting/order").queryParam("id", "${orderId}"), http().client(reportingClient).receive().response(HttpStatus.OK).messageType(MessageType.JSON).payload("{\"status\": true}"));
http().client(bakeryClient).receive().response(HttpStatus.OK).messageType(MessageType.PLAINTEXT);
}
use of com.consol.citrus.context.TestContext in project citrus-samples by christophd.
the class PlaceOrdersHttpIT method placeBlueberryCookieOrder.
@CitrusTest
public void placeBlueberryCookieOrder() {
variable("orderId", Functions.randomNumber(10L, null));
http().client(bakeryClient).send().post("/order").contentType(ContentType.APPLICATION_JSON.getMimeType()).payload("{ \"order\": { \"type\": \"blueberry\", \"id\": ${orderId}, \"amount\": 1}}");
repeatOnError().until(new IteratingConditionExpression() {
@Override
public boolean evaluate(int index, TestContext context) {
return index > 20;
}
}).autoSleep(100L).actions(http().client(reportingClient).send().get("/reporting/order").queryParam("id", "${orderId}"), http().client(reportingClient).receive().response(HttpStatus.OK).messageType(MessageType.JSON).payload("{\"status\": true}"));
http().client(bakeryClient).receive().response(HttpStatus.OK).messageType(MessageType.PLAINTEXT);
}
Aggregations