Skip to content

Commit

Permalink
added valueFromProviderState on LambdaDslObject
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaharia committed Aug 25, 2020
1 parent 9c592ff commit 8fd75bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,17 @@ public LambdaDslObject ipV4Address(String name) {
return this;
}

/**
* Attribute that will have its value injected from the provider state
* @param name Attribute name
* @param expression Expression to be evaluated from the provider state
* @param example Example value to be used in the consumer test
*/
public LambdaDslObject valueFromProviderState(String name, String expression, Object example) {
object.valueFromProviderState(name, expression, example);
return this;
}

/** Combine all the matchers using AND
* @param name Attribute name
* @param value Attribute example value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,4 +990,15 @@ public void testStringArray() {
arrayObjectRule = actualPactDsl.getMatchers().allMatchingRules().get(5).toMap(PactSpecVersion.V3);
assertThat(arrayObjectRule.get("match"), is("type"));
}

@Test
public void testValueFromProviderState() {
String pactDslJson = new PactDslJsonBody()
.valueFromProviderState("id", "id", "A1")
.getBody().toString();
String lambdaDslJson = LambdaDsl
.newJsonBody(body -> body.valueFromProviderState("id", "id", "A1"))
.build().toString();
assertThat(lambdaDslJson, is(pactDslJson));
}
}

0 comments on commit 8fd75bb

Please sign in to comment.