typedb
typedb copied to clipboard
Simplify subsumable BDD step implementations
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.
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.