Test Suite: DEFINITION Service / I_DEFINITION_ADL2 and I_DEFINITION_ADL14 Interfaces
Normative Reference
Items under this validation suite conceptually use these abstract interfaces defined in the openEHR Platform Service Model:
These are concretely realised in implementation technology specfic APIs, such as the Definitions REST API.
This test suite uses artefacts defined by the following specifications:
TODO: add ref to dependency diagram in SM/Platform service model.
Test Environment
The server under test should support:
-
OPTs 1.4 or 2, but OPT 1.4 if more frequent since modeling tools supporting this were around for a long time. Could also support ADL, 1.4 or 2;
-
validation of OPTs and archetypes uploaded to it, or even provide a service to do so before uploading (useful while developing);
-
different versions of the same OPTs and archetypes.
The following should be taken into account when testing any given product:
-
The server under test should support the full cycle of OPT management, including: validation, loading, versioning, retrieving, delete or deactivation (data for this OPT is loaded but no new data should be accepted for it). For the delete, the internal behavior should be defined: 1. if data was committed referencing an OPT, can it be physically deleted? or should be logically deleted? 2. if there is no data, can the OPT be deleted physically? Logical delete might work as the deactivation mentioned above.
-
The test cases are the same for OPT 1.4/2, but tests should be written separately and different datasets should be created for 1.4 and 2.
-
Different implementations might use specific formats for the template IDs, when testing each server, the template IDs should be adapted to prevent failures for wrong format on the template ID. This is due to openEHR not yet defining a format for the template IDs in the specifications.
OPT 1.4/2 Test cases
Service Model operation: I_DEFINITION_ADL14.validate_opt()
Service Model reference: I_DEFINITION_ADL14.validate_opt()
Test Data Sets
-
minimal valid OPT (each containing each entry type);
-
maximal valid OPT (all types in the RM);
-
invalid OPT (empty file);
-
invalid OPT (empty
template_id); -
invalid OPT (removed mandatory elements);
-
invalid OPT (added multiple elements that had an upper bound of 1)
Test Case I_DEFINITION_ADL14.validate_opt-valid_opt
Description |
Validate valid OPTs |
|---|---|
Pre-conditions |
The server should be empty (no EHRs, no commits, no OPTs). |
Post-conditions |
None (validation should not change the state of the system). |
Flow |
|
Test runners |
| some servers might not have a way to just validate the OPT, and validation might be part of the OPT upload functionality. In that case, the validation should upload and validate the OPT, and in the cases of valid OPTs, the OPT should be deleted afterwards, so the system state doesn’t change. For invalid OPTs, the upload should fail. |
Test Case I_DEFINITION_ADL14.validate_opt-invalid_opt
Description |
Validate invalid OPTs |
|---|---|
Pre-conditions |
The server should be empty (no EHRs, no commits, no OPTs). |
Post-conditions |
None (validation should not change the state of the system). |
Flow |
|
Test runners |
Implementation note: when a step says “for each X, invoke service Y”, means that the test should run completely for each X, that is, the pre-conditions and post-conditions apply to the run for X. So if we have:
Test set: a, b, c
Test case:
-
ensure pre-conditions
-
verify post-conditions
-
flow
-
for each X in data set, run service Y
-
verify result
-
The run should be:
-
ensure pre-conditions
-
invoke Y(a)
-
verify result
-
verify post-conditions
-
ensure pre-conditions
-
invoke Y(b)
-
verify result
-
verify post-conditions
-
ensure pre-conditions
-
invoke Y(c)
-
verify result
-
verify post-conditions
Service Model operation: I_DEFINITION_ADL14.upload_opt()
Service Model reference: I_DEFINITION_ADL14.upload_opt()
Data set
-
minimal valid OPT (each with one type of entry, cover all entries)
-
minimal valid OPT, two versions
-
maximal valid OPT (all types in the RM)
-
invalid OPT (empty file)
-
invalid OPT (empty
template_id) -
invalid OPT (removed mandatory elements)
-
invalid OPT (added multiple elements that had an upper bound of 1)
Test Case I_DEFINITION_ADL14.upload_opt-valid_opt
Description |
upload valid OPTs |
|---|---|
Pre-conditions |
No OPTs should be loaded on the system. |
Post-conditions |
A new OPT with the given NOTE: the server should be able to retrieve the template by `template_id` or retrieve if an OPT exists or not by `template_id`. |
Flow |
|
Test runners |
Test Case I_DEFINITION_ADL14.upload_opt-invalid_opt
Description |
upload invalid OPTs |
|---|---|
Pre-conditions |
No OPTs should be loaded on the system. |
Post-conditions |
No OPTs should be loaded on the system. |
Flow |
|
Test runners |
Test Case I_DEFINITION_ADL14.upload_opt-valid_opt_twice_conflict
since there is no formal versioning mechanism for templates 1.4 (OPT 2 might use the archetype id format for the template id that also includes a version number, but this is not widely used), the OPT upload service needs to handle a version parameter, for instance this is the solution on the openEHR REST API. If the version information is not available when uploading OPTs, then uploading an OPT with the same template_id twice will make the second upload fail (conflict).
|
An alternative solution for the version parameter is to add the version number to the other_details of the OPT, or directly into the template_id.
See: SPECBASE-30 and SPECITS-42.
Description |
Upload valid OPT twice with conflict |
||
|---|---|---|---|
Pre-conditions |
No OPTs should be loaded on the system. |
||
Post-conditions |
A new OPT with the given
|
||
Flow |
|
||
Test runners |
Test Case I_DEFINITION_ADL14.upload_opt-valid_opt_twice_no_conflict
| considering the note on the previous flow, for this flow the version parameter is provided, and both service invocations contain a different version value. |
Description |
upload valid OPT twice with conflict |
||
|---|---|---|---|
Pre-conditions |
No OPTs should be loaded on the system. |
||
Post-conditions |
Two new OPTs with the given
|
||
Flow |
|
||
Test runners |
Service Model operation: I_DEFINITION_ADL14.get_opt()
Service Model reference: I_DEFINITION_ADL14.get_opt()
| the flows of this test case will include flows from the Upload OPT test case, in order to have something to retrieve. |
Data sets
-
minimal valid OPT (covering all entry types)
-
minimal valid OPT, two versions
-
maximal valid OPT (all types in the RM)
Test Case I_DEFINITION_ADL14.get_opt-retrieve_single
Description |
Retrieve a single OPT |
|---|---|
Pre-conditions |
All valid OPTs should be loaded into the system, only the single versioned ones. |
Post-conditions |
None (retrieve should not change the state of the system). |
Flow |
|
Test runners |
Test Case I_DEFINITION_ADL14.get_opt-retrieve_fail
Description |
Empty server OPT retrieve fail test |
|---|---|
Pre-conditions |
No OPTs should be loaded on the system. |
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_DEFINITION_ADL14.get_opt-retrieve_latest_version
Description |
retrieve last version of versioned OPT |
|---|---|
Pre-conditions |
OPTs with more than one version should be loaded. |
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_DEFINITION_ADL14.get_opt-retrieve_specific_version
Description |
retrieve a specific version (not last) of versioned OPT |
|---|---|
Pre-conditions |
OPTs with more than one version should be loaded. |
Post-conditions |
None |
Flow |
|
Test runners |
Service Model operation: I_DEFINITION_ADL14.get_opts()
Service Model reference: I_DEFINITION_ADL14.get_opts()
Data sets
-
minimal valid OPT (covering each type of entry);
-
minimal valid OPT, two versions;
-
maximal valid OPT (all types in the RM).
Test Case I_DEFINITION_ADL14.get_opts-retrieve_all
Description |
retrieve all loaded OPTs |
|---|---|
Pre-conditions |
All valid OPTs should be loaded. |
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_DEFINITION_ADL14.get_opts-retrieve_all_no_opts
Description |
retrieve all loaded OPTs when none is loaded |
|---|---|
Pre-conditions |
No OPTs should be loaded on the system. |
Post-conditions |
None |
Flow |
|
Test runners |
Service Model operation: I_DEFINITION_ADL14.delete_opt()
Service Model reference: I_DEFINITION_ADL14.delete_opt()
| the OPT delete can only happen if there is no associated data with the OPT, or if there exists a newer revision (minor version of the same OPT) in the server under test. For all these tests, there is not data committed to the server, so the delete can happen. |
Implementation recommendations: the delete could be logical, so the OPT exists in the server but is not available, and there could be a service to retrieve deleted OPTs. Those can be undeleted or physically deleted (this can’t be undone), and only users with admin permissions should be able to physically delete OPTs.
Data sets
-
minimal valid OPT
-
minimal valid OPT, two versions
-
maximal valid OPT (all types in the RM)
Test Case I_DEFINITION_ADL14.delete_opt-delete_existing
Description |
delete existing OPTs |
|---|---|
Pre-conditions |
All valid OPTs should be loaded into the system. |
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_DEFINITION_ADL14.delete_opt-delete_latest_version
Description |
delete last version of a versioned OPT |
|---|---|
Pre-conditions |
No OPTs should be loaded on the system. |
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_DEFINITION_ADL14.delete_opt-delete_specific_version
Description |
delete specific version of a versioned OPT |
|---|---|
Pre-conditions |
No OPTs should be loaded on the system. |
Post-conditions |
None |
Flow |
|
Test runners |
Test Case I_DEFINITION_ADL14.delete_opt-delete_non_existing
Description |
delete a non existing OPT |
|---|---|
Pre-conditions |
No OPTs should be loaded on the system. |
Post-conditions |
None |
Flow |
|
Test runners |