Skip to content

Commit

Permalink
CASL-391 fix xyz test
Browse files Browse the repository at this point in the history
  • Loading branch information
Amaneusz committed Aug 29, 2024
1 parent 4f53adb commit 94f076b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ internal const val ENC_STRUCT_VARIANT_RESERVED = 0b11
// Public types.
const val CLASS_MASK = 0b1111_0000
const val CLASS_SCALAR = 0b0001_0000
// 0b 1_0101
// ------------
// 1_0101
const val CLASS_STRING = 0b0010_0000
const val CLASS_STRUCT = 0b0100_0000

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import naksha.model.Flags
import naksha.model.XyzNs
import naksha.model.objects.NakshaFeature
import naksha.model.objects.NakshaProperties
import naksha.psql.assertions.CommonProxyAssertions.assertAnyObjectsEqual
import naksha.psql.assertions.NakshaFeatureFluidAssertions.Companion.assertThatFeature
import naksha.psql.util.ProxyBuilder.make
import kotlin.test.Test
import kotlin.test.assertNotNull

class PgUtilTest {

@Test
fun shouldDecodeEncodedFeature(){
fun shouldDecodeEncodedFeature() {
// Given
val feature = NakshaFeature().apply {
val beforeEncoding = NakshaFeature().apply {
id = "feature_1"
properties = NakshaProperties().apply {
featureType = "some_feature_type"
Expand All @@ -27,13 +27,20 @@ class PgUtilTest {

// When:
val noSpecialEncoding = Flags(0)
val encoded = PgUtil.encodeFeature(feature, noSpecialEncoding)
val encoded = PgUtil.encodeFeature(beforeEncoding, noSpecialEncoding)

// And:
val decoded = PgUtil.decodeFeature(encoded, noSpecialEncoding)

// Then:
// Then: features are equal but decoded one is missing Xyz
// note: Xyz should be populated after decoding (it's not stored in `feature` column, it's scattered in other columns)
assertNotNull(decoded)
assertAnyObjectsEqual(feature, decoded)
assertThatFeature(beforeEncoding)
.isIdenticalTo(decoded, ignoreProps = true)
.hasPropertiesThat { decodedProperties ->
decodedProperties
.hasFeatureType(beforeEncoding.properties.featureType)
.hasXyzThat { it.isEmpty() }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class AnyObjectFluidAssertions private constructor(val subject: AnyObject) {
assertEquals(value, subject[key])
}

fun isEmpty(): AnyObjectFluidAssertions =
apply { subject.isEmpty() }

companion object {
fun assertThatAnyObject(subject: AnyObject): AnyObjectFluidAssertions =
AnyObjectFluidAssertions(subject)
Expand Down

0 comments on commit 94f076b

Please sign in to comment.