I’m writing a test which checks that a search attribute is being set (Kotlin/Java SDK).
This is a helper I came up with:
private fun findSearchAttributeBooleanValue(
workflowId: String,
fieldName: String,
): Boolean {
val workflowExecution =
WorkflowExecution
.newBuilder()
.setWorkflowId(workflowId)
.build()
val request =
DescribeWorkflowExecutionRequest
.newBuilder()
.setNamespace(client.options.namespace)
.setExecution(workflowExecution)
.build()
val response = testEnv.workflowServiceStubs.blockingStub().describeWorkflowExecution(request)
val rawValue =
response.workflowExecutionInfo.searchAttributes.indexedFieldsMap[fieldName]
return (rawValue as Payload).data.toString(Charsets.UTF_8).toBoolean()
}
Is there a more reasonable way to access a workflow’s search attributes from the client?