typedb icon indicating copy to clipboard operation
typedb copied to clipboard

Simplify subsumable BDD step implementations

Open flyingsilverfin opened this issue 1 year ago • 1 comments

Problem to Solve

As of https://github.com/vaticle/typedb-behaviour/pull/239 and follow up tweaks, we have several definitions that look something like this:

 @Then("{root_label}\\( ?{type_label} ?) get owns attribute types with annotations: {annotations}; contain")
thing_type_get_owns_attribute_types_with_annotations_contain(root_label, type_label, annotations)

and also

 @Then("{root_label}\\( ?{type_label} ?) get owns attribute types contain")
thing_type_get_owns_attribute_types_contain(root_label, type_label)

One step is a specialisation of another step.

Proposed Solution

The less constrained step implementations should call the more general step implementations:

thing_type_get_owns_attribute_types_contain(root_label, type_label) {
  thing_type_get_owns_attribute_types_with_annotations_contain(root_label, type_label, emptySet())
}

This will reduce the amount of duplicate code present in the BDD step implementations.

This issue applies to both Core and Client-Java.

flyingsilverfin avatar May 16 '23 15:05 flyingsilverfin

We can further extend this to also merge all the steps that are variants "..." and "...; throws exception" - the method that is expecting an exception should call the non-exceptional variant and wrap it in an operation that expects the operation.

flyingsilverfin avatar May 17 '23 09:05 flyingsilverfin