Timothy Jones
03/07/2023, 1:40 AMTimothy Jones
05/11/2023, 5:37 AMDan Nichols
06/08/2023, 6:21 AMDan Nichols
06/08/2023, 6:25 AMDan Nichols
06/08/2023, 6:34 AMif (config.brokerBaseUrl != null) {
builder.brokerBaseUrl(config.brokerBaseUrl);
}
Is there a reason we donāt map everything anyway, even if the property is null? Looking at the Jsii types it seems like these should be nullable for the most partTimothy Jones
06/08/2023, 7:19 AMDan Nichols
06/09/2023, 6:14 AMrunExample
arguments (for a successful response)
2. In the runRejectingExample
arguments (for an unsuccessful response)
3. A group of named triggers in the ContractCaseConfig object (for contract verification)
The docs has the usage of (1) as:
await contract.runExample({
states: [...], // These `...` are not spreads, just for brevity
definition: willSendHttpRequest(...),
},
{
// Presumably the ContractCaseConfig object as an override for the parent config
trigger: (config: HttpRequestConfig) => {},
testResponse: (user) => {}
})
But looking in some examples in the codebase, the triggers are defined as:
contract.runRejectingExample({
states: [...],
definition: willSendHttpRequest(...),
trigger: (config: HttpRequestConfig) => { ... },
testResponse: (user) => { ... },
});
Are both of these patterns going to be supported? Can I converge on just one of these in the DSL?
Looks like the former example is more aligned to the boundary schema, but the latter feels more natural.
From the DSL ContractDefiner setup instructions there is a TODO. Is this just going to say that a trigger needs to be paired with a response (whether success or rejecting), and you canāt have one without the other?
TODO: Describe how to map trigger / testResponse - this is the only place where you may throw aCaseConfigurationError
Timothy Jones
06/09/2023, 7:24 AMcontract = new ContractDefiner(
ContractCaseConfig.ContractCaseConfigBuilder.aContractCaseConfig()
.providerName("Java Example HTTP Server")
.consumerName("Java Example HTTP Client")
.publish(PublishType.NEVER)
.build());
Run example:
@Test
public void getProduct() {
contract.runExample(
new ExampleDefinition<WillSendHttpRequest>(new ArrayList<>(), new WillSendHttpRequest(
HttpExample.builder()
.request(
new HttpRequest(
HttpRequestExample.builder()
.path("/product/10")
.method("GET")
.build()
)
).response(
new HttpResponse(
HttpResponseExample
.builder()
.status(200)
.body(
Map.of("name", new AnyString("product name"), "type",
new AnyString("product series"), "id",
new AnyString("5cc989d0-d800-434c-b4bb-b1268499e850")
)
).build()
)
).build())),
IndividualSuccessTestConfig.IndividualSuccessTestConfigBuilder.<Product>builder()
.withProviderName("Java Example HTTP Server")
.withConsumerName("Java Example HTTP Client")
.withLogLevel(LogLevel.DEEP_MAINTAINER_DEBUG)
.withTrigger(
config -> {
try {
return new ProductClient().setUrl(
config.get("baseUrl").toString().replace("localhost", "127.0.0.1"))
.getProduct("10");
} catch (IOException e) {
throw new RuntimeException(e);
}
})
.withTestResponse(
product -> {
assertThat(product.getId(), is("5cc989d0-d800-434c-b4bb-b1268499e850"));
}).build()
);
Timothy Jones
06/09/2023, 8:45 AMdef caseCoreVersion = "0.13.0"
dependencies {
api "io.contract-testing.contractcase:case_example_mock_types:${caseCoreVersion}"
api "io.contract-testing.contractcase:test-equivalence-matchers:${caseCoreVersion}"
implementation 'io.contract-testing.contractcase:case_boundary:0.6.3'
Timothy Jones
06/09/2023, 8:46 AMimport io.contract_testing.contractcase.case_example_mock_types.AnyMockDescriptor;
becomes:
import io.contract_testing.contractcase.case_example_mock_types.base.AnyMockDescriptor;
Timothy Jones
06/11/2023, 10:50 AMTimothy Jones
06/11/2023, 10:53 AMTimothy Jones
06/11/2023, 10:59 AM