-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
getActiveParticipationInvitation
test for multiple participants…
…/devices A question arose whether the `getActiveParticipationInvitation()` endpoint returning multiple invitations was a CARP core bug, or a bug in the CARP platform (webservices). This unit test shows this works properly in CARP core. An exception to the detekt rule `DestructuringDeclarationWithTooManyEntries` for test sources was added, as overall it can help clean up otherwise distracting repetitive parts of test setup. Closes #482 --------- Co-authored-by: Steven Jeuris <[email protected]>
- Loading branch information
1 parent
9001f8c
commit 0e0d28b
Showing
3 changed files
with
74 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import dk.cachet.carp.deployments.application.users.StudyInvitation | |
import dk.cachet.carp.deployments.domain.createParticipantInvitation | ||
import dk.cachet.carp.deployments.domain.users.AccountService | ||
import dk.cachet.carp.protocols.infrastructure.test.createSinglePrimaryDeviceProtocol | ||
import dk.cachet.carp.protocols.infrastructure.test.createTwoDevicesAndRolesProtocol | ||
import kotlinx.coroutines.test.runTest | ||
import kotlin.test.* | ||
|
||
|
@@ -77,6 +78,42 @@ interface ParticipationServiceTest | |
assertEquals( setOf( expectedAssignedDevice ), retrievedInvitation.assignedDevices ) | ||
} | ||
|
||
@Test | ||
fun getActiveParticipationInvitations_returns_invitations_specific_to_account() = runTest { | ||
val (participationService, deploymentService, accountService) = createSUT() | ||
val (protocol, device1, device2, role1, role2) = createTwoDevicesAndRolesProtocol() | ||
val invitation = StudyInvitation( "Test study", "description" ) | ||
val identity1 = AccountIdentity.fromEmailAddress( "[email protected]" ) | ||
val identity2 = AccountIdentity.fromEmailAddress( "[email protected]" ) | ||
val participantId1 = UUID.randomUUID() | ||
val participantId2 = UUID.randomUUID() | ||
val participantInvitation1 = | ||
ParticipantInvitation( participantId1, AssignedTo.Roles( setOf( role1 ) ), identity1, invitation ) | ||
val participantInvitation2 = | ||
ParticipantInvitation( participantId2, AssignedTo.Roles( setOf( role2 ) ), identity2, invitation ) | ||
deploymentService.createStudyDeployment( | ||
UUID.randomUUID(), | ||
protocol.getSnapshot(), | ||
listOf( participantInvitation1, participantInvitation2 ) | ||
) | ||
|
||
val account1 = accountService.findAccount( identity1 ) | ||
assertNotNull( account1 ) | ||
val retrievedInvitation1 = participationService.getActiveParticipationInvitations( account1.id ).singleOrNull() | ||
assertNotNull( retrievedInvitation1 ) | ||
assertEquals( participantId1, retrievedInvitation1.participation.participantId ) | ||
val assignedDevice1 = retrievedInvitation1.assignedDevices.singleOrNull()?.device?.roleName | ||
assertEquals( device1.roleName, assignedDevice1 ) | ||
|
||
val account2 = accountService.findAccount( identity2 ) | ||
assertNotNull( account2 ) | ||
val retrievedInvitation2 = participationService.getActiveParticipationInvitations( account2.id ).singleOrNull() | ||
assertNotNull( retrievedInvitation2 ) | ||
assertEquals( participantId2, retrievedInvitation2.participation.participantId ) | ||
val assignedDevice2 = retrievedInvitation2.assignedDevices.singleOrNull()?.device?.roleName | ||
assertEquals( device2.roleName, assignedDevice2 ) | ||
} | ||
|
||
@Test | ||
fun getParticipantData_initially_returns_null_for_all_expected_data() = runTest { | ||
val (participationService, deploymentService, _) = createSUT() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters