Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,17 @@ class FormSubmissionVersion @JsonCreator constructor(
@JsonProperty("resources")
var resources: List<Map<String, Any>>? = null,
) {
val rawPayload: String?
get() = payload?.let {
try {
mapper.writeValueAsString(it)
} catch (e: Exception) {
null
}
}

// shared Jackson mapper configured to ignore unknown properties when hydrating attribute maps
private fun resourceMapper(): ObjectMapper = Companion.mapper
private fun resourceMapper(): ObjectMapper = mapper

/**
* Convert the raw resources list (List<Map<...>>) into typed JsonApiEnvelope objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ class FormSubmissionVersionsRouterTest {
assertNotNull(result.payload)
assertTrue(result.payload!!.containsKey("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"))
assertTrue(result.payload!!.containsKey("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"))

// check rawPayload is a valid JSON string
assertNotNull(result.rawPayload)
assertTrue(result.rawPayload!!.startsWith("{"))
assertTrue(result.rawPayload!!.endsWith("}"))
// verify it contains the expected keys in JSON format
assertTrue(result.rawPayload!!.contains("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"))
assertTrue(result.rawPayload!!.contains("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"))
}
}

Expand Down Expand Up @@ -169,6 +177,14 @@ class FormSubmissionVersionsRouterTest {
assertNotNull(result.payload)
assertTrue(result.payload!!.containsKey("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"))
assertTrue(result.payload!!.containsKey("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"))

// check rawPayload is a valid JSON string
assertNotNull(result.rawPayload)
assertTrue(result.rawPayload!!.startsWith("{"))
assertTrue(result.rawPayload!!.endsWith("}"))
// verify it contains the expected keys in JSON format
assertTrue(result.rawPayload!!.contains("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"))
assertTrue(result.rawPayload!!.contains("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"))
}
}
}
Loading