本文整理汇总了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]"));
}
示例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));
}
示例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]"));
}
示例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"));
}
示例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);
}
示例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);
}