• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PactDslJsonBody类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中au.com.dius.pact.consumer.dsl.PactDslJsonBody的典型用法代码示例。如果您正苦于以下问题:Java PactDslJsonBody类的具体用法?Java PactDslJsonBody怎么用?Java PactDslJsonBody使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PactDslJsonBody类属于au.com.dius.pact.consumer.dsl包,在下文中一共展示了PactDslJsonBody类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
 
开发者ID:DiUS,项目名称:pact-workshop-android,代码行数:25,代码来源:ServicePactTest.java


示例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]"));
}
 
开发者ID:scheuchzer,项目名称:pact-jvm-consumer-java8,代码行数:28,代码来源:LambdaDslObjectTest.java


示例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;
}
 
开发者ID:scheuchzer,项目名称:pact-jvm-consumer-java8,代码行数:8,代码来源:LambdaDslObject.java


示例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));
}
 
开发者ID:scheuchzer,项目名称:pact-jvm-consumer-java8,代码行数:28,代码来源:LambdaDslObjectTest.java


示例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]"));
}
 
开发者ID:scheuchzer,项目名称:pact-jvm-consumer-java8,代码行数:16,代码来源:LambdaDslObjectTest.java


示例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"));
}
 
开发者ID:scheuchzer,项目名称:pact-jvm-consumer-java8,代码行数:15,代码来源:LambdaDslObjectTest.java


示例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);
}
 
开发者ID:scheuchzer,项目名称:pact-jvm-consumer-java8,代码行数:28,代码来源:LambdaDslObjectTest.java


示例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);
}
 
开发者ID:scheuchzer,项目名称:pact-jvm-consumer-java8,代码行数:37,代码来源:LambdaDslObjectTest.java


示例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();
}
 
开发者ID:robcrowley,项目名称:microservices-pact-demo,代码行数:38,代码来源:ProductCatalogueServiceAdapterTests.java


示例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();
}
 
开发者ID:andreschaffer,项目名称:microservices-testing-examples,代码行数:12,代码来源:CreditScoreServicePactIT.java


示例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();
}
 
开发者ID:andreschaffer,项目名称:microservices-testing-examples,代码行数:15,代码来源:MemberSignedUpEventPactIT.java


示例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();
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:64,代码来源:EidasSessionResourceContractTest.java


示例13: LambdaDslObject

import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
LambdaDslObject(final PactDslJsonBody object) {
    this.object = object;
}
 
开发者ID:scheuchzer,项目名称:pact-jvm-consumer-java8,代码行数:4,代码来源:LambdaDslObject.java


示例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;
}
 
开发者ID:scheuchzer,项目名称:pact-jvm-consumer-java8,代码行数:7,代码来源:LambdaDsl.java


示例15: LambdaDslJsonBody

import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
LambdaDslJsonBody(final PactDslJsonBody dslPart) {
    super(dslPart);
    this.dslPart = dslPart;
}
 
开发者ID:scheuchzer,项目名称:pact-jvm-consumer-java8,代码行数:5,代码来源:LambdaDslJsonBody.java


示例16: testObjectWithObjects

import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
@Test
public void testObjectWithObjects() throws IOException {
    /*
        {
            "propObj1": {
                "foo": "Foo"
            },
            "propObj2": {
                "bar": "Bar"
            },
            "someProperty": "Prop"
        }
     */

    // Old DSL
    final String pactDslJson = new PactDslJsonBody()
        .stringValue("someProperty", "Prop")
        .object("propObj1")
        .stringValue("foo", "Foo")
        .closeObject()
        .object("propObj2")
        .stringValue("bar", "Bar")
        .closeObject()
        .getBody().toString();

    // Lambda DSL
    final DslPart actualPactDsl = LambdaDsl.newJsonBody((body) -> {
        body
            .stringValue("someProperty", "Prop")
            .object("propObj1", (o) -> {
                o.stringValue("foo", "Foo");
            })
            .object("propObj2", (o) -> {
                o.stringValue("bar", "Bar");
            });
    })
        .build();

    String actualJson = actualPactDsl.getBody().toString();
    assertThat(actualJson, is(pactDslJson));
}
 
开发者ID:scheuchzer,项目名称:pact-jvm-consumer-java8,代码行数:42,代码来源:LambdaDslTest.java


示例17: testObjectWithComplexStructure

import au.com.dius.pact.consumer.dsl.PactDslJsonBody; //导入依赖的package包/类
@Test
public void testObjectWithComplexStructure() throws IOException {
    /*
        {
            "propObj1": {
                "foo": "Foo",
                "someProperty": 1
            },
            "someArray": [
                {
                    "arrayObj1Prop1": "ao1p1"
                },
                {
                    "arrayObj1Prop2Obj": {
                        "arrayObj1Prop2ObjProp1": "ao1p2op1"
                    },
                    "arrayObj2Prop1": "ao2p1"
                }
            ]
        }
     */

    // Old DSL
    final String pactDslJson = new PactDslJsonBody()
        .object("propObj1")
        .stringValue("foo", "Foo")
        .numberValue("someProperty", 1L)
        .closeObject()
        .array("someArray")
        .object()
        .stringValue("arrayObj1Prop1", "ao1p1")
        .closeObject()
        .object()
        .stringValue("arrayObj2Prop1", "ao2p1")
        .object("arrayObj1Prop2Obj")
        .stringValue("arrayObj1Prop2ObjProp1", "ao1p2op1")
        .closeObject()
        .closeObject()
        .closeArray()
        .getBody().toString();

    // Lambda DSL
    final DslPart actualPactDsl = LambdaDsl.newJsonBody((body) -> {
        body
            .object("propObj1", (o) -> {
                o.stringValue("foo", "Foo");
                o.numberValue("someProperty", 1L);
            })
            .array("someArray", (a) -> {
                a.object((oo) -> oo.stringValue("arrayObj1Prop1", "ao1p1"));
                a.object((oo) -> {
                    oo.stringValue("arrayObj2Prop1", "ao2p1");
                    oo.object("arrayObj1Prop2Obj", (ooo) -> ooo.stringValue("arrayObj1Prop2ObjProp1", "ao1p2op1"));
                });
            });
    })
        .build();

    String actualJson = actualPactDsl.getBody().toString();
    assertThat(actualJson, is(pactDslJson));
}
 
开发者ID:scheuchzer,项目名称:pact-jvm-consumer-java8,代码行数:62,代码来源:LambdaDslTest.java



注:本文中的au.com.dius.pact.consumer.dsl.PactDslJsonBody类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WebMenuItem类代码示例发布时间:2022-05-22
下一篇:
Java SortableField类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap