use of au.com.dius.pact.core.model.annotations.Pact in project pact-jvm by DiUS.
the class TodoXmlTest method projects.
// body: <?xml version="1.0" encoding="UTF-8"?>
// <projects foo="bar">
// <project id="1" name="Project 1" due="2016-02-11T09:46:56.023Z">
// <tasks>
// <task id="1" name="Do the laundry" done="true"/>
// <task id="2" name="Do the dishes" done="false"/>
// <task id="3" name="Do the backyard" done="false"/>
// <task id="4" name="Do nothing" done="false"/>
// </tasks>
// </project>
// <project/>
// </projects>
@Pact(provider = "TodoProvider", consumer = "TodoConsumer")
public RequestResponsePact projects(PactDslWithProvider builder) {
return builder.given("i have a list of projects").uponReceiving("a request for projects in XML").path("/projects").query("from=today").headers(mapOf("Accept", "application/xml")).willRespondWith().headers(mapOf("Content-Type", "application/xml")).status(200).body(new PactXmlBuilder("projects", "http://some.namespace/and/more/stuff").build(root -> {
root.setAttributes(mapOf("id", "1234"));
root.eachLike("project", 2, mapOf("id", integer(), "type", "activity", "name", string("Project 1"), "due", timestamp("yyyy-MM-dd'T'HH:mm:ss.SSSX", "2016-02-11T09:46:56.023Z")), project -> {
project.appendElement("tasks", Collections.emptyMap(), task -> {
task.eachLike("task", 5, mapOf("id", integer(), "name", string("Task 1"), "done", bool(true)));
});
});
})).toPact();
}
use of au.com.dius.pact.core.model.annotations.Pact in project pact-jvm by DiUS.
the class AsyncMessageTest method createPact2.
@Pact(provider = "MessageProvider", consumer = "test_consumer_v3")
MessagePact createPact2(MessagePactBuilder builder) {
PactDslJsonBody body = new PactDslJsonBody();
body.stringValue("testParam1", "value3");
body.stringValue("testParam2", "value4");
Map<String, String> metadata = new HashMap<String, String>();
metadata.put("Content-Type", "application/json");
return builder.given("SomeProviderState2").expectsToReceive("a test message").withMetadata(metadata).withContent(body).toPact();
}
use of au.com.dius.pact.core.model.annotations.Pact in project pact-jvm by DiUS.
the class AsyncMessageTest method createPact.
@Pact(consumer = "test_consumer_v3")
MessagePact createPact(MessagePactBuilder builder) {
PactDslJsonBody body = new PactDslJsonBody();
body.stringValue("testParam1", "value1");
body.stringValue("testParam2", "value2");
Map<String, Object> metadata = new HashMap<>();
metadata.put("destination", Matchers.regexp("\\w+\\d+", "X001"));
return builder.given("SomeProviderState").expectsToReceive("a test message").withMetadata(metadata).withContent(body).toPact();
}
use of au.com.dius.pact.core.model.annotations.Pact in project pact-jvm by DiUS.
the class Issue1176Test method validCredentials.
@Pact(provider = "config-service", consumer = "test-integration")
public RequestResponsePact validCredentials(PactDslWithProvider builder) {
Map<String, String> headers = Collections.singletonMap("Content-Type", ContentType.TEXT.toString());
RequestResponsePact pact = builder.uponReceiving("valid configuration").path(CONFIG_URL).method("GET").headers(headers).body("text").willRespondWith().status(200).body("{\"data\":\"\", \"status\":\"success\"}").toPact();
return pact;
}
use of au.com.dius.pact.core.model.annotations.Pact in project pact-jvm by DiUS.
the class ExampleMessageConsumerTest method createPact.
@Pact(provider = "test_provider", consumer = "test_consumer_v3")
public MessagePact createPact(MessagePactBuilder builder) {
PactDslJsonBody body = new PactDslJsonBody();
body.stringValue("testParam1", "value1");
body.stringValue("testParam2", "value2");
Map<String, String> metadata = new HashMap<String, String>();
metadata.put("contentType", "application/json");
return builder.given("SomeProviderState").expectsToReceive("a test message").withMetadata(metadata).withContent(body).toPact();
}
Aggregations