Closed Whathecode closed 2 years ago
but the question is: It that firing those kind of even not necessary when manipulating StudyDeployment from snapshot?
@thaiphandinh The emitted events are actually omitted right before returning the snapshot since they are undesirable side effects. They represent changes made to the domain model while it was in memory. The events emitted as part of loading the snapshot are thus unwanted.
Loading a
StudyDeployment
which had an unregistered connected device failed since to deploy a device (deviceDeployed
), all required devices needed to be registered, and, when loading the snapshotdeviceDeployed
was called. This call failed after replaying the deployment's registration history and not all necessary devices were registered.deviceDeployed
was called as a way to ensure preconditions were checked. In this case, preconditions were checked incorrectly by doing so (a device can be deployed with connected devices unregistered after it has been deployed). The fix is to manipulate theStudyDeployment
state directly, while still verifying snapshot correctness.Also refactored test code a bit to remove redundant retrieval of the primary and connected device in the study protocols used for tests.