本文整理汇总了Java中au.com.dius.pact.consumer.dsl.PactDslJsonBody类的典型用法代码示例。如果您正苦于以下问题:Java PactDslJsonBody类的具体用法?Java PactDslJsonBody怎么用?Java PactDslJsonBody使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PactDslJsonBody类属于au.com.dius.pact.consumer.dsl包,在下文中一共展示了PactDslJsonBody类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFragment
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
@Pact(provider = "our_provider", consumer = "our_consumer")
public PactFragment createFragment(PactDslWithProvider builder) throws UnsupportedEncodingException {
PactDslJsonBody body = new PactDslJsonBody()
.stringType("test")
.stringType("valid_date", DateHelper.toString(DATE_TIME))
.eachLike("animals", 3)
.stringType("name", "Doggy")
.stringType("image", "dog")
.closeObject()
.closeArray()
.asBody();
return builder
.given("data count is > 0")
.uponReceiving("a request for json data")
.path("/provider.json")
.method("GET")
.query("valid_date=" + DateHelper.encodeDate(DATE_TIME))
.willRespondWith()
.status(200)
.headers(HEADERS)
.body(body)
.toFragment();
}
示例2: testStringMatcherWithExample
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
@Test
public void testStringMatcherWithExample() throws IOException {
/*
{
"foo": "a0"
}
*/
// Old DSL
final String pactDslJson = new PactDslJsonBody()
.stringMatcher("foo", "[a-z][0-9]", "a0")
.getBody().toString();
// Lambda DSL
final PactDslJsonBody actualPactDsl = new PactDslJsonBody();
final LambdaDslObject object = new LambdaDslObject(actualPactDsl);
object
.stringMatcher("foo", "[a-z][0-9]", "a0");
actualPactDsl.close();
String actualJson = actualPactDsl.getBody().toString();
assertThat(actualJson, is(pactDslJson));
assertThat(actualPactDsl.getMatchers().allMatchingRules().size(), is(1));
final Map matcher = actualPactDsl.getMatchers().allMatchingRules().get(0).toMap();
assertThat(matcher.get("match"), is("regex"));
assertThat(matcher.get("regex"), is("[a-z][0-9]"));
}
示例3: object
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
public LambdaDslObject object(final String name, final Consumer<LambdaDslObject> nestedObject) {
final PactDslJsonBody pactObject = object.object(name);
final LambdaDslObject dslObject = new LambdaDslObject(pactObject);
nestedObject.accept(dslObject);
pactObject.closeObject();
return this;
}
示例4: testStringValue
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
@Test
public void testStringValue() throws IOException {
/*
{
"bar": "Bar",
"foo": "Foo"
}
*/
// Old DSL
final String pactDslJson = new PactDslJsonBody()
.stringValue("foo", "Foo")
.stringValue("bar", "Bar")
.getBody().toString();
// Lambda DSL
final PactDslJsonBody actualPactDsl = new PactDslJsonBody("", "", null);
final LambdaDslObject object = new LambdaDslObject(actualPactDsl);
object
.stringValue("foo", "Foo")
.stringValue("bar", "Bar");
actualPactDsl.close();
String actualJson = actualPactDsl.getBody().toString();
assertThat(actualJson, is(pactDslJson));
assertThat(actualPactDsl.getMatchers().allMatchingRules().isEmpty(), is(true));
}
示例5: testStringMatcher
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
@Test
public void testStringMatcher() throws IOException {
final PactDslJsonBody actualPactDsl = new PactDslJsonBody("", "", null);
final LambdaDslObject object = new LambdaDslObject(actualPactDsl);
object
.stringMatcher("foo", "[a-z][0-9]");
actualPactDsl.close();
String actualJson = actualPactDsl.getBody().toString().replace("\"", "'");
assertThat(actualJson, containsString("{'foo':"));
assertThat(actualPactDsl.getMatchers().allMatchingRules().size(), is(1));
final Map matcher = actualPactDsl.getMatchers().allMatchingRules().get(0).toMap();
assertThat(matcher.get("match"), is("regex"));
assertThat(matcher.get("regex"), is("[a-z][0-9]"));
}
示例6: testStringType
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
@Test
public void testStringType() throws IOException {
final PactDslJsonBody actualPactDsl = new PactDslJsonBody();
final LambdaDslObject object = new LambdaDslObject(actualPactDsl);
object
.stringType("foo");
actualPactDsl.close();
String actualJson = actualPactDsl.getBody().toString().replace("\"", "'");
assertThat(actualJson, containsString("{'foo':"));
assertThat(actualPactDsl.getMatchers().allMatchingRules().size(), is(1));
final Map matcher = actualPactDsl.getMatchers().allMatchingRules().get(0).toMap();
assertThat(matcher.get("match"), is("type"));
}
示例7: testStringTypeWithExample
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
@Test
public void testStringTypeWithExample() throws IOException {
/*
{
"foo": "Foo"
}
*/
// Old DSL
final String pactDslJson = new PactDslJsonBody()
.stringType("foo", "Foo")
.getBody().toString();
// Lambda DSL
final PactDslJsonBody actualPactDsl = new PactDslJsonBody("", "", null);
final LambdaDslObject object = new LambdaDslObject(actualPactDsl);
object
.stringType("foo", "Foo");
actualPactDsl.close();
String actualJson = actualPactDsl.getBody().toString();
assertThat(actualJson, is(pactDslJson));
assertThat(actualPactDsl.getMatchers().allMatchingRules().size(), is(1));
final Map matcher = actualPactDsl.getMatchers().allMatchingRules().get(0).toMap();
assertThat(matcher.get("match"), is("type"));
System.out.println(actualJson);
}
示例8: testStringTypes
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
@Test
public void testStringTypes() throws IOException {
/*
{
"foo": [
{
"bar": "Bar"
}
]
}
*/
// Old DSL
final String pactDslJson = new PactDslJsonBody()
.stringType(new String[]{"foo", "bar"})
.getBody().toString();
// Lambda DSL
final PactDslJsonBody actualPactDsl = new PactDslJsonBody();
final LambdaDslObject object = new LambdaDslObject(actualPactDsl);
object
.stringType(new String[]{"foo", "bar"});
actualPactDsl.close();
String actualJson = actualPactDsl.getBody().toString();
// It can't be equals because the values get generated randomly on each run
//assertThat(actualJson, is(pactDslJson));
assertThat(actualPactDsl.getMatchers().allMatchingRules().size(), is(2));
assertThat(actualJson, containsString("foo"));
assertThat(actualJson, containsString("bar"));
Map matcher = actualPactDsl.getMatchers().allMatchingRules().get(0).toMap();
assertThat(matcher.get("match"), is("type"));
matcher = actualPactDsl.getMatchers().allMatchingRules().get(1).toMap();
assertThat(matcher.get("match"), is("type"));
System.out.println(actualJson);
}
示例9: createFragment
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
@Pact(provider = "Product_Catalogue_Provider", consumer = "Product_Catalogue_Consumer")
public PactFragment createFragment(PactDslWithProvider builder) {
return builder.given("products exist")
.uponReceiving("a request for the product catalogue")
.path("/products")
.method("GET")
.headers(ImmutableMap.of(ACCEPT, HAL_JSON))
.willRespondWith()
.headers(ImmutableMap.of(CONTENT_TYPE, HAL_JSON))
.status(200)
.body(new PactDslJsonBody()
.integerType("page", 1)
.integerType("perPage", 10)
.integerType("totalCount", 1)
.object("_links")
.object("self")
.stringType("href", "/products")
.closeObject()
.closeObject()
.object("_embedded")
.eachLike("items")
.stringType("id", "LRPL")
.stringMatcher("createdOn", "\\d{4}-\\d{1,2}-\\d{1,2}", "2016-2-28")
.stringType("name", "Personal Loan")
.stringType("description", "Low Rate Personal Loan")
.stringType("logo", "/cdn/logos/lrpl.webp")
.object("_links")
.object("self")
.stringType("href", "/products/LRPL")
.stringType("title", "Personal Loan")
.closeObject()
.closeObject()
.closeObject()
.closeArray()
.closeObject())
.toFragment();
}
示例10: tonyStarkCreditScore
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
@Pact(provider = CREDIT_SCORE_SERVICE, consumer = SPECIAL_MEMBERSHIP_SERVICE)
public RequestResponsePact tonyStarkCreditScore(PactDslWithProvider pact) {
return pact.given("There is a [email protected]")
.uponReceiving("A credit score request for [email protected]")
.path("/credit-scores/[email protected]").method("GET")
.willRespondWith()
.status(200)
.body(new PactDslJsonBody().integerType("creditScore", 850))
.headers(singletonMap(CONTENT_TYPE, APPLICATION_JSON))
.toPact();
}
示例11: newMemberTonyStark
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
@Pact(consumer = WELCOME_MEMBER_EMAIL_SERVICE, provider = SPECIAL_MEMBERSHIP_SERVICE)
public MessagePact newMemberTonyStark(MessagePactBuilder builder) {
PactDslJsonBody body = new PactDslJsonBody()
.stringValue("@type", "memberSignedUpEvent")
.stringMatcher("email", "[email protected]+\\..+", "[email protected]");
Map<String, String> metadata = new HashMap<>();
return builder.given("Tony Stark became a new member")
.expectsToReceive("An event notifying Tony Stark's new membership")
.withMetadata(metadata)
.withContent(body)
.toPact();
}
示例12: shouldGetValidatedEidasAuthnResponseFromSamlEngine
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
@Pact(consumer = POLICY_SERVICE, provider = SAML_ENGINE_SERVICE)
public RequestResponsePact shouldGetValidatedEidasAuthnResponseFromSamlEngine(PactDslWithProvider pact) {
return pact
.uponReceiving("A request to validate the Authn Response")
.path(Urls.SamlEngineUrls.TRANSLATE_COUNTRY_AUTHN_RESPONSE_RESOURCE).method("POST")
.headers(singletonMap(CONTENT_TYPE, APPLICATION_JSON))
.body(
new PactDslJsonBody()
.stringValue("samlResponse", samlAuthnResponseContainerDto.getSamlResponse())
.stringValue("principalIPAddressAsSeenByHub", samlAuthnResponseContainerDto.getPrincipalIPAddressAsSeenByHub())
.stringValue("matchingServiceEntityId", TEST_RP_MS)
.object("sessionId")
.stringValue("sessionId", sessionId.getSessionId())
.closeObject()
)
.willRespondWith()
.status(Response.Status.OK.getStatusCode())
.headers(singletonMap(CONTENT_TYPE, APPLICATION_JSON))
.body(
new PactDslJsonBody()
.stringValue("issuer", COUNTRY_ENTITY_ID)
.stringValue("persistentId", "UK/GB/12345")
.stringValue("status", "Success")
.nullValue("statusMessage")
.stringMatcher("encryptedIdentityAssertionBlob", ".+", encryptedIdentityAssertionString)
.stringValue("levelOfAssurance", "LEVEL_2")
)
.uponReceiving("A request to generate an attribute query request")
.path(Urls.SamlEngineUrls.GENERATE_COUNTRY_ATTRIBUTE_QUERY_RESOURCE).method("POST")
.headers(singletonMap(CONTENT_TYPE, APPLICATION_JSON))
.body(
new PactDslJsonBody()
.stringMatcher("requestId", ".+", ID)
.stringValue("assertionConsumerServiceUri", "/default-service-index")
.stringValue("encryptedIdentityAssertion", encryptedIdentityAssertionString)
.stringValue("authnRequestIssuerEntityId", TEST_RP)
.stringValue("levelOfAssurance", "LEVEL_2")
.stringValue("matchingServiceAdapterUri", MATCHING_SERVICE_URI)
.stringValue("matchingServiceEntityId", TEST_RP_MS)
.timestamp("matchingServiceRequestTimeOut", "yyyy-MM-dd'T'HH:mm:ss.S'Z'")
.booleanValue("onboarding", true)
.nullValue("cycle3Dataset")
.nullValue("userAccountCreationAttributes")
.timestamp("assertionExpiry", "yyyy-MM-dd'T'HH:mm:ss.S'Z'")
.object("persistentId")
.stringValue("nameId", "UK/GB/12345")
.closeObject()
)
.willRespondWith()
.status(Response.Status.OK.getStatusCode())
.headers(singletonMap(CONTENT_TYPE, APPLICATION_JSON))
.body(
new PactDslJsonBody()
.stringMatcher("samlRequest", "[\\s\\S]+", SAML_ATTRIBUTE_QUERY)
.stringValue("matchingServiceUri", MATCHING_SERVICE_URI)
.stringValue("id", ID)
.stringValue("issuer", EIDAS_HUB_ENTITY_ID)
.timestamp("attributeQueryClientTimeOut", "yyyy-MM-dd'T'HH:mm:ss.S'Z'")
.booleanValue("onboarding", true)
)
.toPact();
}
示例13: LambdaDslObject
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
LambdaDslObject(final PactDslJsonBody object) {
this.object = object;
}
示例14: newJsonBody
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
public static LambdaDslJsonBody newJsonBody(Consumer<LambdaDslJsonBody> array) {
final PactDslJsonBody pactDslJsonBody = new PactDslJsonBody();
final LambdaDslJsonBody dslBody = new LambdaDslJsonBody(pactDslJsonBody);
array.accept(dslBody);
return dslBody;
}
示例15: LambdaDslJsonBody
import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
LambdaDslJsonBody(final PactDslJsonBody dslPart) {
super(dslPart);
this.dslPart = dslPart;
}