Skip to content

Commit

Permalink
Fix json deserialiser & add test
Browse files Browse the repository at this point in the history
  • Loading branch information
driessamyn committed Oct 2, 2023
1 parent 943995f commit 5171e1c
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.corda.libs.statemanager.impl.tests

import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper
import net.corda.db.admin.impl.ClassloaderChangeLog
import net.corda.db.admin.impl.LiquibaseSchemaMigratorImpl
Expand All @@ -14,6 +13,7 @@ import net.corda.libs.statemanager.api.State
import net.corda.libs.statemanager.api.StateManager
import net.corda.libs.statemanager.api.metadata
import net.corda.libs.statemanager.impl.StateManagerImpl
import net.corda.libs.statemanager.impl.convertToMetadata
import net.corda.libs.statemanager.impl.model.v1.StateEntity
import net.corda.libs.statemanager.impl.model.v1.StateManagerEntities
import net.corda.libs.statemanager.impl.repository.impl.KEY_PARAMETER_NAME
Expand Down Expand Up @@ -76,9 +76,6 @@ class StateManagerIntegrationTest {
private val stateManager: StateManager =
StateManagerImpl(StateRepositoryImpl(queryProvider), entityManagerFactoryFactory)

private fun ObjectMapper.toMetadata(metadata: String) =
this.readValue(metadata, object : TypeReference<Metadata>() {})

private fun cleanStates() = entityManagerFactoryFactory.createEntityManager().transaction {
it.createNativeQuery("DELETE FROM state s WHERE s.key LIKE '%$testUniqueId%'").executeUpdate()
it.flush()
Expand Down Expand Up @@ -129,7 +126,7 @@ class StateManagerIntegrationTest {
it.assertThat(loadedEntity.modifiedTime).isNotNull
it.assertThat(loadedEntity.version).isEqualTo(version(i, key))
it.assertThat(loadedEntity.value).isEqualTo((stateContent(i, key).toByteArray()))
it.assertThat(objectMapper.toMetadata(loadedEntity.metadata))
it.assertThat(objectMapper.convertToMetadata(loadedEntity.metadata))
.containsExactlyInAnyOrderEntriesOf(metadataContent(i, key))
}
}
Expand Down

0 comments on commit 5171e1c

Please sign in to comment.