-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix(#1031): update existing entity instead of creating new one - Prevent hibernate from merging entities - closes #1031 * chore(#1031): add documentation to public function * chore(#1031): adjust import style, update payloadAttributes instead of overwrite --------- Co-authored-by: Michael von Bargen <[email protected]>
- Loading branch information
1 parent
e52deee
commit c69e53c
Showing
4 changed files
with
112 additions
and
53 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
57 changes: 57 additions & 0 deletions
57
view/jpa/src/test/kotlin/io/holunda/polyflow/view/jpa/task/ConverterExtKtTest.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,57 @@ | ||
package io.holunda.polyflow.view.jpa.task | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import io.holunda.camunda.taskpool.api.task.ProcessReference | ||
import io.holunda.polyflow.view.jpa.data.DataEntryId | ||
import io.holunda.polyflow.view.jpa.payload.PayloadAttribute | ||
import io.holunda.polyflow.view.jpa.process.toSourceReferenceEmbeddable | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.assertj.core.data.MapEntry | ||
import org.junit.jupiter.api.Test | ||
|
||
class ConverterExtKtTest { | ||
|
||
@Test | ||
fun `should convert to task`() { | ||
val objectMapper = ObjectMapper() | ||
val entity = TaskEntity( | ||
taskId = "taskId", | ||
taskDefinitionKey = "taskDefinitionKey", | ||
name = "name", | ||
priority = 50, | ||
sourceReference = ProcessReference( | ||
instanceId = "instanceId", | ||
executionId = "executionId", | ||
definitionId = "definitionId", | ||
definitionKey = "definitionKey", | ||
name = "name", | ||
applicationName = "applicationName", | ||
).toSourceReferenceEmbeddable(), | ||
authorizedPrincipals = mutableSetOf("GROUP:FOO", "GROUP:BAR"), | ||
correlations = mutableSetOf(DataEntryId("1", "foo"), DataEntryId("2", "bar")), | ||
payloadAttributes = mutableSetOf(PayloadAttribute("foo", "bar")), | ||
payload = """ | ||
{"foo": "bar" } | ||
""".trimIndent(), | ||
formKey = "formKey", | ||
) | ||
|
||
val task = entity.toTask(objectMapper) | ||
|
||
assertThat(task.id).isEqualTo("taskId") | ||
assertThat(task.taskDefinitionKey).isEqualTo("taskDefinitionKey") | ||
assertThat(task.name).isEqualTo("name") | ||
assertThat(task.priority).isEqualTo(50) | ||
assertThat(task.sourceReference.instanceId).isEqualTo("instanceId") | ||
assertThat(task.sourceReference.executionId).isEqualTo("executionId") | ||
assertThat(task.sourceReference.definitionId).isEqualTo("definitionId") | ||
assertThat(task.sourceReference.definitionKey).isEqualTo("definitionKey") | ||
assertThat(task.sourceReference.name).isEqualTo("name") | ||
assertThat(task.sourceReference.applicationName).isEqualTo("applicationName") | ||
assertThat(task.candidateGroups).containsExactlyInAnyOrder("FOO", "BAR") | ||
assertThat(task.correlations).containsOnly(MapEntry.entry("bar", "2"), MapEntry.entry("foo", "1")) | ||
assertThat(task.payload).containsOnly(MapEntry.entry("foo", "bar")) | ||
assertThat(task.formKey).isEqualTo("formKey") | ||
|
||
} | ||
} |