-
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.
Make
deviceDisplayName
optional in DeviceRegistration
- Loading branch information
1 parent
df5affe
commit 205d34f
Showing
27 changed files
with
4,080 additions
and
14 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
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
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
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
53 changes: 53 additions & 0 deletions
53
...onMain/kotlin/dk/cachet/carp/common/infrastructure/versioning/Major1Minor2To3Migration.kt
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package dk.cachet.carp.common.infrastructure.versioning | ||
|
||
import kotlinx.serialization.ExperimentalSerializationApi | ||
import kotlinx.serialization.json.JsonPrimitive | ||
|
||
|
||
/** | ||
* - The `deviceDisplayName` field in `DeviceRegistration` is no longer required. | ||
* This also apply to `ConnectedDeviceRegistration`. | ||
*/ | ||
@Suppress( "MagicNumber" ) | ||
abstract class Major1Minor2To3Migration : ApiMigration( 1, 3 ) | ||
{ | ||
private val keyOrder = listOf( | ||
"__type", | ||
"registrationCreatedOn", | ||
"deviceDisplayName" | ||
) | ||
private val removedField = "deviceDisplayName" | ||
|
||
@OptIn( ExperimentalSerializationApi::class ) | ||
protected fun ApiJsonObjectMigrationBuilder.addDisplayNameField( fieldName: String ) = | ||
updateObject( fieldName ) { | ||
json[ removedField ] ?: json.put( removedField, JsonPrimitive(null ) ) | ||
.also { json.sortByKeyOrder( keyOrder ) } | ||
} | ||
|
||
|
||
// Helper function to sort the keys in a map based on a given order | ||
private fun <K, V> MutableMap<K, V>.sortByKeyOrder( keyOrder: List<K> ) | ||
{ | ||
val sortedMap = LinkedHashMap<K, V>( ) | ||
|
||
for ( key in keyOrder ) | ||
{ | ||
if (this.containsKey( key ) ) | ||
{ | ||
sortedMap[ key ] = this[ key ]!! | ||
} | ||
} | ||
|
||
for (entry in this) | ||
{ | ||
if ( !sortedMap.containsKey( entry.key ) ) | ||
{ | ||
sortedMap[ entry.key ] = entry.value | ||
} | ||
} | ||
|
||
this.clear() | ||
this.putAll( sortedMap ) | ||
} | ||
} |
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
194 changes: 194 additions & 0 deletions
194
...loymentService/1.3/DeploymentServiceTest/createStudyDeployment_fails_for_existing_id.json
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 |
---|---|---|
@@ -0,0 +1,194 @@ | ||
[ | ||
{ | ||
"outcome": "Succeeded", | ||
"request": { | ||
"__type": "dk.cachet.carp.deployments.infrastructure.DeploymentServiceRequest.CreateStudyDeployment", | ||
"apiVersion": "1.3", | ||
"id": "6a4ff16c-cafc-4392-836a-503fe0b81127", | ||
"protocol": { | ||
"id": "e55bf62d-56e1-4596-ad12-4868475d5398", | ||
"createdOn": "2024-10-09T08:17:33.762380Z", | ||
"version": 0, | ||
"ownerId": "27879e75-ccc1-4866-9ab3-4ece1b735052", | ||
"name": "Test protocol", | ||
"description": "Test description", | ||
"primaryDevices": [ | ||
{ | ||
"__type": "dk.cachet.carp.common.infrastructure.test.StubPrimaryDeviceConfiguration", | ||
"isPrimaryDevice": true, | ||
"roleName": "Primary" | ||
} | ||
], | ||
"connectedDevices": [ | ||
{ | ||
"__type": "dk.cachet.carp.common.infrastructure.test.StubDeviceConfiguration", | ||
"roleName": "Connected" | ||
} | ||
], | ||
"connections": [ | ||
{ | ||
"roleName": "Connected", | ||
"connectedToRoleName": "Primary" | ||
} | ||
] | ||
}, | ||
"invitations": [ | ||
{ | ||
"participantId": "bc2b736f-fbc0-434d-8e07-736f56396335", | ||
"assignedRoles": { | ||
"__type": "dk.cachet.carp.common.application.users.AssignedTo.All" | ||
}, | ||
"identity": { | ||
"__type": "dk.cachet.carp.common.application.users.UsernameAccountIdentity", | ||
"username": "Test" | ||
}, | ||
"invitation": { | ||
"name": "Some study" | ||
} | ||
} | ||
] | ||
}, | ||
"precedingEvents": [], | ||
"publishedEvents": [ | ||
{ | ||
"__type": "dk.cachet.carp.deployments.application.DeploymentService.Event.StudyDeploymentCreated", | ||
"aggregateId": "6a4ff16c-cafc-4392-836a-503fe0b81127", | ||
"apiVersion": "1.3", | ||
"studyDeploymentId": "6a4ff16c-cafc-4392-836a-503fe0b81127", | ||
"protocol": { | ||
"id": "e55bf62d-56e1-4596-ad12-4868475d5398", | ||
"createdOn": "2024-10-09T08:17:33.762380Z", | ||
"version": 0, | ||
"ownerId": "27879e75-ccc1-4866-9ab3-4ece1b735052", | ||
"name": "Test protocol", | ||
"description": "Test description", | ||
"primaryDevices": [ | ||
{ | ||
"__type": "dk.cachet.carp.common.infrastructure.test.StubPrimaryDeviceConfiguration", | ||
"isPrimaryDevice": true, | ||
"roleName": "Primary" | ||
} | ||
], | ||
"connectedDevices": [ | ||
{ | ||
"__type": "dk.cachet.carp.common.infrastructure.test.StubDeviceConfiguration", | ||
"roleName": "Connected" | ||
} | ||
], | ||
"connections": [ | ||
{ | ||
"roleName": "Connected", | ||
"connectedToRoleName": "Primary" | ||
} | ||
] | ||
}, | ||
"invitations": [ | ||
{ | ||
"participantId": "bc2b736f-fbc0-434d-8e07-736f56396335", | ||
"assignedRoles": { | ||
"__type": "dk.cachet.carp.common.application.users.AssignedTo.All" | ||
}, | ||
"identity": { | ||
"__type": "dk.cachet.carp.common.application.users.UsernameAccountIdentity", | ||
"username": "Test" | ||
}, | ||
"invitation": { | ||
"name": "Some study" | ||
} | ||
} | ||
], | ||
"connectedDevicePreregistrations": {} | ||
} | ||
], | ||
"response": { | ||
"__type": "dk.cachet.carp.deployments.application.StudyDeploymentStatus.Invited", | ||
"createdOn": "1970-01-01T00:00:00Z", | ||
"studyDeploymentId": "6a4ff16c-cafc-4392-836a-503fe0b81127", | ||
"deviceStatusList": [ | ||
{ | ||
"__type": "dk.cachet.carp.deployments.application.DeviceDeploymentStatus.Unregistered", | ||
"device": { | ||
"__type": "dk.cachet.carp.common.infrastructure.test.StubPrimaryDeviceConfiguration", | ||
"isPrimaryDevice": true, | ||
"roleName": "Primary" | ||
}, | ||
"canBeDeployed": true, | ||
"remainingDevicesToRegisterToObtainDeployment": [ | ||
"Primary" | ||
], | ||
"remainingDevicesToRegisterBeforeDeployment": [ | ||
"Primary", | ||
"Connected" | ||
] | ||
}, | ||
{ | ||
"__type": "dk.cachet.carp.deployments.application.DeviceDeploymentStatus.Unregistered", | ||
"device": { | ||
"__type": "dk.cachet.carp.common.infrastructure.test.StubDeviceConfiguration", | ||
"roleName": "Connected" | ||
}, | ||
"canBeDeployed": false, | ||
"remainingDevicesToRegisterToObtainDeployment": [ | ||
"Connected" | ||
], | ||
"remainingDevicesToRegisterBeforeDeployment": [ | ||
"Connected" | ||
] | ||
} | ||
], | ||
"participantStatusList": [ | ||
{ | ||
"participantId": "bc2b736f-fbc0-434d-8e07-736f56396335", | ||
"assignedParticipantRoles": { | ||
"__type": "dk.cachet.carp.common.application.users.AssignedTo.All" | ||
}, | ||
"assignedPrimaryDeviceRoleNames": [ | ||
"Primary" | ||
] | ||
} | ||
], | ||
"startedOn": null | ||
} | ||
}, | ||
{ | ||
"outcome": "Failed", | ||
"request": { | ||
"__type": "dk.cachet.carp.deployments.infrastructure.DeploymentServiceRequest.CreateStudyDeployment", | ||
"apiVersion": "1.3", | ||
"id": "6a4ff16c-cafc-4392-836a-503fe0b81127", | ||
"protocol": { | ||
"id": "d3d68082-69c7-4eda-8e60-3c134727bb84", | ||
"createdOn": "2024-10-09T08:17:33.763129Z", | ||
"version": 0, | ||
"ownerId": "27879e75-ccc1-4866-9ab3-4ece1b735052", | ||
"name": "Test protocol", | ||
"description": "Test description", | ||
"primaryDevices": [ | ||
{ | ||
"__type": "dk.cachet.carp.common.infrastructure.test.StubPrimaryDeviceConfiguration", | ||
"isPrimaryDevice": true, | ||
"roleName": "Test device" | ||
} | ||
] | ||
}, | ||
"invitations": [ | ||
{ | ||
"participantId": "3528a538-279d-4871-8d03-de6b3d5722f8", | ||
"assignedRoles": { | ||
"__type": "dk.cachet.carp.common.application.users.AssignedTo.All" | ||
}, | ||
"identity": { | ||
"__type": "dk.cachet.carp.common.application.users.UsernameAccountIdentity", | ||
"username": "User" | ||
}, | ||
"invitation": { | ||
"name": "Some study" | ||
} | ||
} | ||
] | ||
}, | ||
"precedingEvents": [], | ||
"publishedEvents": [], | ||
"exceptionType": "IllegalArgumentException" | ||
} | ||
] |
Oops, something went wrong.