当前位置: 首页>>代码示例>>Java>>正文


Java PactDslJsonBody.close方法代码示例

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


在下文中一共展示了PactDslJsonBody.close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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


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