diff --git a/java/arcs/core/data/testutil/BUILD b/java/arcs/core/data/testutil/BUILD index 22bc8689bef..2ef19812723 100644 --- a/java/arcs/core/data/testutil/BUILD +++ b/java/arcs/core/data/testutil/BUILD @@ -7,12 +7,26 @@ licenses(["notice"]) package(default_visibility = ["//java/arcs:allowed-packages"]) +GENERATOR_SRCS = ["Generators.kt"] + arcs_kt_library( - name = "generators", - testonly = 1, - srcs = [ - "Generators.kt", + name = "testutil", + testonly = True, + srcs = glob( + ["*.kt"], + exclude = GENERATOR_SRCS, + ), + deps = [ + "//java/arcs/core/data:rawentity", + "//java/arcs/core/data/util:data-util", + "//third_party/java/truth:truth-android", ], +) + +arcs_kt_library( + name = "generators", + testonly = True, + srcs = GENERATOR_SRCS, deps = [ "//java/arcs/core/common", "//java/arcs/core/data", diff --git a/java/arcs/core/data/testutil/RawEntitySubject.kt b/java/arcs/core/data/testutil/RawEntitySubject.kt new file mode 100644 index 00000000000..e2671e34786 --- /dev/null +++ b/java/arcs/core/data/testutil/RawEntitySubject.kt @@ -0,0 +1,198 @@ +package arcs.core.data.testutil + +import arcs.core.data.RawEntity +import arcs.core.data.util.ReferencableList +import com.google.common.truth.Fact +import com.google.common.truth.Fact.fact +import com.google.common.truth.Fact.simpleFact +import com.google.common.truth.FailureMetadata +import com.google.common.truth.Subject +import com.google.common.truth.Truth.assertAbout +import java.lang.Integer.max + +/** + * Custom Truth [Subject] for asserting on [RawEntity] instances. + * + * Displays a much nicer diff between unequal entities than the default diff, e.g.: + * + * RawEntity instances are different + * for field: rawEntity.collections[foo][1] + * expected : Primitive(0.695700200506916) + * but was : Primitive(0.46839655204527963) + * + * See [RawEntitySubject.Companion.assertThat] for instructions on how to use this. + */ +class RawEntitySubject private constructor( + failureMetadata: FailureMetadata, + subject: RawEntity? +) : Subject(failureMetadata, subject) { + private val actual: RawEntity? = subject + + override fun isEqualTo(expected: Any?) { + if (actual == expected) { + return + } + if (expected !is RawEntity || actual == null) { + // Standard failure scenarios, defer to Truth's standard error message. + super.isEqualTo(expected) + return // Redundant return, above line should always throw. + } + + var diffs = RawEntityDiffer().diff(expected, actual) + + if (diffs.isEmpty()) { + diffs = listOf( + simpleFact(""), + fact("expected", expected.toString()), + fact("but was", actual.toString()) + ) + } + + failWithoutActual( + simpleFact("RawEntity instances are different"), + *diffs.toTypedArray() + ) + } + + class RawEntityDiffer { + private val diffs = mutableListOf() + + fun diff(expected: RawEntity, actual: RawEntity): List { + diffRawEntity(prefix = "rawEntity", expected, actual) + return diffs + } + + private fun diffRawEntity(prefix: String, expected: RawEntity, actual: RawEntity) { + if (expected == actual) { + return + } + if (actual.id != expected.id) { + addDiff("$prefix.id", expected.id, actual.id) + } + if (actual.creationTimestamp != expected.creationTimestamp) { + addDiff( + "$prefix.creationTimestamp", + expected.creationTimestamp.toString(), + actual.creationTimestamp.toString() + ) + } + if (actual.expirationTimestamp != expected.expirationTimestamp) { + addDiff( + "$prefix.expirationTimestamp", + expected.expirationTimestamp.toString(), + actual.expirationTimestamp.toString() + ) + } + diffMap("$prefix.singletons", expected.singletons, actual.singletons) + diffMap("$prefix.collections", expected.collections, actual.collections) + } + + private fun diffMap(prefix: String, expected: Map, actual: Map) { + if (expected == actual) { + return + } + val expectedKeys = expected.keys + val actualKeys = actual.keys + for (key in expectedKeys) { + if (key in actualKeys) { + // Check values. + diffValue("$prefix[$key]", expected[key], actual[key]) + } else { + // Expected key is missing. + addDiff("$prefix[$key]", expected[key].toString(), "") + } + } + for (key in actualKeys) { + if (key !in expectedKeys) { + // Unexpected key. + addDiff("$prefix[$key]", "", actual[key].toString()) + } + } + } + + private fun diffValue(prefix: String, expected: Any?, actual: Any?) { + when { + expected == actual -> Unit + expected is RawEntity && actual is RawEntity -> { + diffRawEntity(prefix, expected, actual) + } + expected is List<*> && actual is List<*> -> { + diffList(prefix, expected, actual) + } + expected is Set<*> && actual is Set<*> -> { + diffSet(prefix, expected, actual) + } + expected is ReferencableList<*> && actual is ReferencableList<*> -> { + diffValue("$prefix.itemType", expected.itemType, actual.itemType) + diffList(prefix, expected.value, actual.value) + } + else -> { + addDiff(prefix, expected.toString(), actual.toString()) + } + } + } + + private fun diffList(prefix: String, expected: List<*>, actual: List<*>) { + for (i in 0 until max(expected.size, actual.size)) { + diffValue( + "$prefix[$i]", + expected.getOrElse(i) { "" }, + actual.getOrElse(i) { "" } + ) + } + } + + private fun diffSet(prefix: String, expected: Set<*>, actual: Set<*>) { + // Convert each set to a stable sorted list, then compare lists. + diffList( + prefix, + expected.sortedBy { it.toString() }.toList(), + actual.sortedBy { it.toString() }.toList() + ) + } + + private fun addDiff(field: String, expected: String, actual: String) { + diffs.add(fact("for field", field)) + diffs.add(fact("expected", expected)) + diffs.add(fact("but was", actual)) + } + } + + private object Factory : Subject.Factory { + override fun createSubject( + failureMetadata: FailureMetadata, + actual: RawEntity? + ): RawEntitySubject { + return RawEntitySubject(failureMetadata, actual) + } + } + + companion object { + /** + * Returns a Truth [Subject] that can be used to assert on a [RawEntity]. + * + * To use this, simply import this method, and then use [assertThat] as usual on any [RawEntity] + * instance: + * + * ``` + * import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat + * + * val myEntity = RawEntity(...) + * assertThat(myEntity).isEqualTo(...) + * ``` + */ + fun assertThat(actual: RawEntity): RawEntitySubject { + return assertAbout(Factory).that(actual) + } + + /** + * Factory method for creating a [Factory] instance, to be used with methods like + * `assertWithMessage`. + * + * ```kotlin + * assertWithMessage("blah").about(rawEntities()).that(...) + * ``` + */ + fun rawEntities(): Subject.Factory = Factory + } +} diff --git a/javatests/arcs/android/crdt/BUILD b/javatests/arcs/android/crdt/BUILD index 615fc63573a..95c08573b7b 100644 --- a/javatests/arcs/android/crdt/BUILD +++ b/javatests/arcs/android/crdt/BUILD @@ -25,6 +25,7 @@ arcs_kt_android_test_suite( "//java/arcs/core/crdt/testutil:generators", "//java/arcs/core/data:rawentity", "//java/arcs/core/data:schema_fields", + "//java/arcs/core/data/testutil", "//java/arcs/core/data/testutil:generators", "//java/arcs/core/data/util:data-util", "//java/arcs/core/entity/testutil", diff --git a/javatests/arcs/android/crdt/CrdtSetProtoTest.kt b/javatests/arcs/android/crdt/CrdtSetProtoTest.kt index aa22ad4d91f..478cec38652 100644 --- a/javatests/arcs/android/crdt/CrdtSetProtoTest.kt +++ b/javatests/arcs/android/crdt/CrdtSetProtoTest.kt @@ -18,6 +18,7 @@ import arcs.core.common.Referencable import arcs.core.crdt.CrdtSet import arcs.core.crdt.VersionMap import arcs.core.data.RawEntity +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith @@ -48,7 +49,8 @@ class CrdtSetProtoTest { @Test fun data_parcelableRoundTrip_works() { val data = CrdtSet.DataImpl( - versionMap, mutableMapOf( + versionMap, + mutableMapOf( entity1.id to CrdtSet.DataValue(VersionMap("alice" to 1), entity1), entity2.id to CrdtSet.DataValue(VersionMap("alice" to 1), entity2) ) diff --git a/javatests/arcs/android/crdt/RawEntityProtoTest.kt b/javatests/arcs/android/crdt/RawEntityProtoTest.kt index 53d395c3aa7..3fea7eade20 100644 --- a/javatests/arcs/android/crdt/RawEntityProtoTest.kt +++ b/javatests/arcs/android/crdt/RawEntityProtoTest.kt @@ -15,6 +15,7 @@ import android.os.Parcel import androidx.test.ext.junit.runners.AndroidJUnit4 import arcs.android.util.writeProto import arcs.core.data.RawEntity +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat import arcs.core.entity.testutil.FixtureEntities import com.google.common.truth.Truth.assertThat import org.junit.Test diff --git a/javatests/arcs/android/crdt/ReferencableProtoTest.kt b/javatests/arcs/android/crdt/ReferencableProtoTest.kt index 24ac5682c8c..226ce733e25 100644 --- a/javatests/arcs/android/crdt/ReferencableProtoTest.kt +++ b/javatests/arcs/android/crdt/ReferencableProtoTest.kt @@ -19,6 +19,7 @@ import arcs.core.crdt.CrdtEntity import arcs.core.crdt.VersionMap import arcs.core.data.FieldType import arcs.core.data.RawEntity +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat import arcs.core.data.util.ReferencableList import arcs.core.data.util.ReferencablePrimitive import arcs.core.data.util.toReferencable diff --git a/javatests/arcs/android/crdt/ReferenceProtoTest.kt b/javatests/arcs/android/crdt/ReferenceProtoTest.kt index eb5fc83908e..d9d86c5ebe3 100644 --- a/javatests/arcs/android/crdt/ReferenceProtoTest.kt +++ b/javatests/arcs/android/crdt/ReferenceProtoTest.kt @@ -16,6 +16,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import arcs.android.util.writeProto import arcs.core.crdt.VersionMap import arcs.core.data.RawEntity +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat import arcs.core.storage.RawReference import arcs.core.storage.StorageKeyManager import arcs.core.storage.keys.RamDiskStorageKey diff --git a/javatests/arcs/android/storage/BUILD b/javatests/arcs/android/storage/BUILD index 8ecd6f16cab..e03c4494b06 100644 --- a/javatests/arcs/android/storage/BUILD +++ b/javatests/arcs/android/storage/BUILD @@ -25,6 +25,7 @@ arcs_kt_android_test_suite( "//java/arcs/android/util/testutil", "//java/arcs/core/crdt", "//java/arcs/core/data", + "//java/arcs/core/data/testutil", "//java/arcs/core/entity/testutil", "//java/arcs/core/storage", "//java/arcs/core/storage/database", diff --git a/javatests/arcs/core/crdt/BUILD b/javatests/arcs/core/crdt/BUILD index cf9bf6e8756..b574b541f59 100644 --- a/javatests/arcs/core/crdt/BUILD +++ b/javatests/arcs/core/crdt/BUILD @@ -19,6 +19,7 @@ arcs_kt_jvm_test_suite( "//java/arcs/core/crdt/testutil:generators", "//java/arcs/core/data", "//java/arcs/core/data:schema_fields", + "//java/arcs/core/data/testutil", "//java/arcs/core/data/util:data-util", "//java/arcs/core/testutil", "//java/arcs/core/util", diff --git a/javatests/arcs/core/crdt/CrdtEntityTest.kt b/javatests/arcs/core/crdt/CrdtEntityTest.kt index 0607f1398b7..aea14325228 100644 --- a/javatests/arcs/core/crdt/CrdtEntityTest.kt +++ b/javatests/arcs/core/crdt/CrdtEntityTest.kt @@ -20,6 +20,7 @@ import arcs.core.crdt.CrdtEntity.Operation.SetSingleton import arcs.core.crdt.CrdtEntity.Reference.Companion.defaultReferenceBuilder import arcs.core.data.FieldType import arcs.core.data.RawEntity +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat import arcs.core.data.util.ReferencableList import arcs.core.data.util.ReferencablePrimitive import arcs.core.data.util.toReferencable diff --git a/javatests/arcs/core/data/testutil/BUILD b/javatests/arcs/core/data/testutil/BUILD new file mode 100644 index 00000000000..86812441c02 --- /dev/null +++ b/javatests/arcs/core/data/testutil/BUILD @@ -0,0 +1,19 @@ +load( + "//third_party/java/arcs/build_defs:build_defs.bzl", + "arcs_kt_jvm_test_suite", +) + +licenses(["notice"]) + +arcs_kt_jvm_test_suite( + name = "testutil", + package = "arcs.core.data.testutil", + deps = [ + "//java/arcs/core/data:rawentity", + "//java/arcs/core/data:schema_fields", + "//java/arcs/core/data/testutil", + "//java/arcs/core/data/util:data-util", + "//third_party/java/junit:junit-android", + "//third_party/java/truth:truth-android", + ], +) diff --git a/javatests/arcs/core/data/testutil/RawEntitySubjectTest.kt b/javatests/arcs/core/data/testutil/RawEntitySubjectTest.kt new file mode 100644 index 00000000000..f9e969ca3dc --- /dev/null +++ b/javatests/arcs/core/data/testutil/RawEntitySubjectTest.kt @@ -0,0 +1,267 @@ +package arcs.core.data.testutil + +import arcs.core.data.FieldType +import arcs.core.data.RawEntity +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat +import arcs.core.data.testutil.RawEntitySubject.Companion.rawEntities +import arcs.core.data.util.ReferencableList +import arcs.core.data.util.toReferencable +import com.google.common.truth.ExpectFailure.assertThat +import com.google.common.truth.ExpectFailure.expectFailureAbout +import com.google.common.truth.SimpleSubjectBuilder +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(JUnit4::class) +class RawEntitySubjectTest { + @Test + fun isEqualTo_null_fails() { + expectFailure { + that(ENTITY).isEqualTo(null) + } + } + + @Test + fun isEqualTo_self_passes() { + assertThat(ENTITY).isEqualTo(ENTITY) + assertThat(ENTITY.copy()).isEqualTo(ENTITY) + } + + @Test + fun isEqualTo_differentId_fails() { + val expected = ENTITY.copy(id = "id1") + val actual = ENTITY.copy(id = "id2") + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff("rawEntity.id", expected = "id1", actual = "id2") + } + + @Test + fun isEqualTo_differentCreationTimestamp_fails() { + val expected = ENTITY.copy(creationTimestamp = 111) + val actual = ENTITY.copy(creationTimestamp = 222) + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff("rawEntity.creationTimestamp", expected = "111", actual = "222") + } + + @Test + fun isEqualTo_differentExpirationTimestamp_fails() { + val expected = ENTITY.copy(expirationTimestamp = 111) + val actual = ENTITY.copy(expirationTimestamp = 222) + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff("rawEntity.expirationTimestamp", expected = "111", actual = "222") + } + + @Test + fun isEqualTo_sameSingletonFields_passes() { + val expected = ENTITY.copy(singletons = mapOf("a" to VALUE1, "b" to VALUE2)) + val actual = expected.copy() + + assertThat(actual).isEqualTo(expected) + } + + @Test + fun isEqualTo_differentSingletonFields_fails() { + val expected = ENTITY.copy(singletons = mapOf("a" to VALUE1)) + val actual = expected.copy(singletons = mapOf("a" to VALUE2)) + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff( + "rawEntity.singletons[a]", + expected = VALUE1.toString(), + actual = VALUE2.toString() + ) + } + + @Test + fun isEqualTo_extraSingletonField_fails() { + val expected = ENTITY.copy(singletons = emptyMap()) + val actual = ENTITY.copy(singletons = mapOf("a" to VALUE1)) + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff( + "rawEntity.singletons[a]", + expected = "", + actual = VALUE1.toString() + ) + } + + @Test + fun isEqualTo_missingSingletonField_fails() { + val expected = ENTITY.copy(singletons = mapOf("a" to VALUE1)) + val actual = ENTITY.copy(singletons = emptyMap()) + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff( + "rawEntity.singletons[a]", + expected = VALUE1.toString(), + actual = "" + ) + } + + @Test + fun isEqualTo_sameCollectionFields_passes() { + val expected = ENTITY.copy(collections = mapOf("a" to setOf(VALUE1), "b" to setOf(VALUE2))) + val actual = expected.copy() + + assertThat(actual).isEqualTo(expected) + } + + @Test + fun isEqualTo_differentCollectionFields_differentValue_fails() { + val expected = ENTITY.copy(collections = mapOf("a" to setOf(VALUE1))) + val actual = expected.copy(collections = mapOf("a" to setOf(VALUE2))) + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff( + "rawEntity.collections[a][0]", + expected = VALUE1.toString(), + actual = VALUE2.toString() + ) + } + + @Test + fun isEqualTo_differentCollectionFields_additionalValue_fails() { + val expected = ENTITY.copy(collections = mapOf("a" to setOf(VALUE1))) + val actual = expected.copy(collections = mapOf("a" to setOf(VALUE1, VALUE2))) + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff( + "rawEntity.collections[a][1]", + expected = "", + actual = VALUE2.toString() + ) + } + + @Test + fun isEqualTo_extraCollectionField_fails() { + val expected = ENTITY.copy(collections = emptyMap()) + val actual = ENTITY.copy(collections = mapOf("a" to emptySet())) + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff( + "rawEntity.collections[a]", + expected = "", + actual = "[]" + ) + } + + @Test + fun isEqualTo_missingCollectionField_fails() { + val expected = ENTITY.copy(collections = mapOf("a" to emptySet())) + val actual = ENTITY.copy(collections = emptyMap()) + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff( + "rawEntity.collections[a]", + expected = "[]", + actual = "" + ) + } + + @Test + fun isEqualTo_nestedRawEntityInSingletonField() { + fun createNestedEntity(id: String): RawEntity { + val deepInnerEntity = ENTITY.copy(id = id) + val innerEntity = ENTITY.copy(singletons = mapOf("deep" to deepInnerEntity)) + return ENTITY.copy(singletons = mapOf("inner" to innerEntity)) + } + val expected = createNestedEntity("id1") + val actual = createNestedEntity("id2") + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff( + "rawEntity.singletons[inner].singletons[deep].id", + expected = "id1", + actual = "id2" + ) + } + + @Test + fun isEqualTo_nestedRawEntityInCollectionField() { + fun createNestedEntity(id: String): RawEntity { + val deepInnerEntity = ENTITY.copy(id = id) + val innerEntity = ENTITY.copy(collections = mapOf("deep" to setOf(VALUE1, deepInnerEntity))) + return ENTITY.copy(collections = mapOf("inner" to setOf(innerEntity))) + } + val expected = createNestedEntity("id1") + val actual = createNestedEntity("id2") + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff( + "rawEntity.collections[inner][0].collections[deep][1].id", + expected = "id1", + actual = "id2" + ) + } + + @Test + fun isEqualTo_referencableListWithDifferentItemType_fails() { + val expected = ENTITY.copy( + singletons = mapOf("a" to ReferencableList(listOf(VALUE1, VALUE2), FieldType.BigInt)) + ) + val actual = ENTITY.copy( + singletons = mapOf("a" to ReferencableList(listOf(VALUE1, VALUE2), FieldType.Duration)) + ) + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff( + "rawEntity.singletons[a].itemType", + expected = "BigInt", + actual = "Duration" + ) + } + + @Test + fun isEqualTo_referencableListWithDifferentItems_fails() { + val expected = ENTITY.copy( + singletons = mapOf("a" to ReferencableList(listOf(VALUE1, VALUE1), FieldType.BigInt)) + ) + val actual = ENTITY.copy( + singletons = mapOf("a" to ReferencableList(listOf(VALUE1, VALUE2), FieldType.BigInt)) + ) + + val failure = expectFailure { that(actual).isEqualTo(expected) } + + failure.expectDiff( + "rawEntity.singletons[a][1]", + expected = VALUE1.toString(), + actual = VALUE2.toString() + ) + } + + private companion object { + private fun expectFailure( + callback: (SimpleSubjectBuilder).() -> Unit + ): AssertionError { + return expectFailureAbout(rawEntities(), callback) + } + + private val ENTITY = RawEntity(id = "id", creationTimestamp = 987, expirationTimestamp = 654) + + private val VALUE1 = "value1".toReferencable() + private val VALUE2 = "value2".toReferencable() + + private fun AssertionError.expectDiff(field: String, expected: String, actual: String) { + assertThat(this).factValue("for field").isEqualTo(field) + assertThat(this).factValue("expected").isEqualTo(expected) + assertThat(this).factValue("but was").isEqualTo(actual) + } + } +} diff --git a/javatests/arcs/core/entity/BUILD b/javatests/arcs/core/entity/BUILD index 27e3ac72057..ef16a765a78 100644 --- a/javatests/arcs/core/entity/BUILD +++ b/javatests/arcs/core/entity/BUILD @@ -15,6 +15,7 @@ arcs_kt_jvm_test_suite( "//java/arcs/core/data", "//java/arcs/core/data:schema_fields", "//java/arcs/core/data/expression", + "//java/arcs/core/data/testutil", "//java/arcs/core/data/util:data-util", "//java/arcs/core/entity", "//java/arcs/core/entity/testutil", diff --git a/javatests/arcs/core/entity/EntityBaseTest.kt b/javatests/arcs/core/entity/EntityBaseTest.kt index 07991168a8e..76da267a066 100644 --- a/javatests/arcs/core/entity/EntityBaseTest.kt +++ b/javatests/arcs/core/entity/EntityBaseTest.kt @@ -19,6 +19,7 @@ import arcs.core.data.RawEntity import arcs.core.data.Schema import arcs.core.data.SchemaFields import arcs.core.data.SchemaRegistry +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat import arcs.core.data.util.toReferencable import arcs.core.entity.testutil.DummyEntity import arcs.core.entity.testutil.DummyVariableEntity diff --git a/javatests/arcs/core/entity/EntityDereferencerFactoryTest.kt b/javatests/arcs/core/entity/EntityDereferencerFactoryTest.kt index b76de3b7fc3..ca368042ae3 100644 --- a/javatests/arcs/core/entity/EntityDereferencerFactoryTest.kt +++ b/javatests/arcs/core/entity/EntityDereferencerFactoryTest.kt @@ -6,6 +6,7 @@ import arcs.core.data.RawEntity import arcs.core.data.Schema import arcs.core.data.SchemaFields import arcs.core.data.SchemaRegistry +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat import arcs.core.data.util.ReferencableList import arcs.core.data.util.toReferencable import arcs.core.storage.RawEntityDereferencer diff --git a/javatests/arcs/core/entity/StorageAdapterTest.kt b/javatests/arcs/core/entity/StorageAdapterTest.kt index f483ad4718a..9d662d29179 100644 --- a/javatests/arcs/core/entity/StorageAdapterTest.kt +++ b/javatests/arcs/core/entity/StorageAdapterTest.kt @@ -9,6 +9,7 @@ import arcs.core.data.SchemaRegistry import arcs.core.data.expression.asExpr import arcs.core.data.expression.neq import arcs.core.data.expression.text +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat import arcs.core.data.util.toReferencable import arcs.core.entity.testutil.DummyEntity import arcs.core.entity.testutil.InlineDummyEntity diff --git a/javatests/arcs/core/entity/VariableEntityBaseTest.kt b/javatests/arcs/core/entity/VariableEntityBaseTest.kt index 378a95faeab..bba9027bcfc 100644 --- a/javatests/arcs/core/entity/VariableEntityBaseTest.kt +++ b/javatests/arcs/core/entity/VariableEntityBaseTest.kt @@ -2,6 +2,7 @@ package arcs.core.entity import arcs.core.crdt.VersionMap import arcs.core.data.SchemaRegistry +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat import arcs.core.entity.testutil.DummyEntity import arcs.core.entity.testutil.DummyVariableEntity import arcs.core.entity.testutil.InlineDummyEntity diff --git a/javatests/arcs/core/storage/BUILD b/javatests/arcs/core/storage/BUILD index 5d3a1c4b1f3..eee3b81e45f 100644 --- a/javatests/arcs/core/storage/BUILD +++ b/javatests/arcs/core/storage/BUILD @@ -23,6 +23,7 @@ arcs_kt_android_test_suite( "//java/arcs/core/crdt/testing", "//java/arcs/core/data", "//java/arcs/core/data:schema_fields", + "//java/arcs/core/data/testutil", "//java/arcs/core/data/util:data-util", "//java/arcs/core/storage", "//java/arcs/core/storage/api", diff --git a/javatests/arcs/core/storage/ReferenceModeStoreDatabaseIntegrationTest.kt b/javatests/arcs/core/storage/ReferenceModeStoreDatabaseIntegrationTest.kt index cfee9b7710a..14c66094b14 100644 --- a/javatests/arcs/core/storage/ReferenceModeStoreDatabaseIntegrationTest.kt +++ b/javatests/arcs/core/storage/ReferenceModeStoreDatabaseIntegrationTest.kt @@ -16,6 +16,7 @@ import arcs.core.crdt.CrdtSet import arcs.core.crdt.VersionMap import arcs.core.data.RawEntity import arcs.core.data.SchemaRegistry +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat import arcs.core.storage.driver.DatabaseDriver import arcs.core.storage.driver.DatabaseDriverProvider import arcs.core.storage.keys.DatabaseStorageKey @@ -75,14 +76,16 @@ class ReferenceModeStoreDatabaseIntegrationTest( // Read data (using a new store ensures we read from the db instead of using cached values). val activeStore2 = collectionReferenceModeStore(scope = this) - val e1RefVersionMap = if (BuildFlags.REFERENCE_MODE_STORE_FIXES) + val e1RefVersionMap = if (BuildFlags.REFERENCE_MODE_STORE_FIXES) { VersionMap(activeStore.crdtKey to 1) - else + } else { VersionMap("me" to 1) - val e2RefVersionMap = if (BuildFlags.REFERENCE_MODE_STORE_FIXES) + } + val e2RefVersionMap = if (BuildFlags.REFERENCE_MODE_STORE_FIXES) { VersionMap(activeStore.crdtKey to 1) - else + } else { VersionMap("me" to 2) + } val e1Ref = CrdtSet.DataValue( VersionMap("me" to 1), diff --git a/javatests/arcs/core/storage/ReferenceModeStoreTest.kt b/javatests/arcs/core/storage/ReferenceModeStoreTest.kt index 49ba5059645..499dbedf6c1 100644 --- a/javatests/arcs/core/storage/ReferenceModeStoreTest.kt +++ b/javatests/arcs/core/storage/ReferenceModeStoreTest.kt @@ -15,6 +15,7 @@ import arcs.core.crdt.CrdtData import arcs.core.crdt.CrdtSet import arcs.core.crdt.VersionMap import arcs.core.data.RawEntity +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat import arcs.core.storage.referencemode.RefModeStoreData import arcs.core.storage.referencemode.ReferenceModeStorageKey import arcs.core.storage.testutil.FakeDriver diff --git a/javatests/arcs/core/storage/driver/BUILD b/javatests/arcs/core/storage/driver/BUILD index f174cf4133d..ae440fd6067 100644 --- a/javatests/arcs/core/storage/driver/BUILD +++ b/javatests/arcs/core/storage/driver/BUILD @@ -15,6 +15,7 @@ arcs_kt_jvm_test_suite( "//java/arcs/core/crdt", "//java/arcs/core/data", "//java/arcs/core/data:schema_fields", + "//java/arcs/core/data/testutil", "//java/arcs/core/data/util:data-util", "//java/arcs/core/storage", "//java/arcs/core/storage/database", diff --git a/javatests/arcs/core/storage/driver/DatabaseDriverTest.kt b/javatests/arcs/core/storage/driver/DatabaseDriverTest.kt index 0b9cf051a08..71d23cc28d7 100644 --- a/javatests/arcs/core/storage/driver/DatabaseDriverTest.kt +++ b/javatests/arcs/core/storage/driver/DatabaseDriverTest.kt @@ -22,6 +22,7 @@ import arcs.core.data.RawEntity import arcs.core.data.Schema import arcs.core.data.SchemaFields import arcs.core.data.SchemaName +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat import arcs.core.data.util.ReferencablePrimitive import arcs.core.data.util.toReferencable import arcs.core.storage.RawReference diff --git a/javatests/arcs/sdk/BUILD b/javatests/arcs/sdk/BUILD index fa302b42e97..c038e9c654c 100644 --- a/javatests/arcs/sdk/BUILD +++ b/javatests/arcs/sdk/BUILD @@ -20,6 +20,7 @@ arcs_kt_jvm_test_suite( "//java/arcs/core/common", "//java/arcs/core/data", "//java/arcs/core/data:schema_fields", + "//java/arcs/core/data/testutil", "//java/arcs/core/data/util:data-util", "//java/arcs/core/entity", "//java/arcs/core/entity/testutil", diff --git a/javatests/arcs/sdk/GeneratedEntityTest.kt b/javatests/arcs/sdk/GeneratedEntityTest.kt index e63af18181e..2fb3d462122 100755 --- a/javatests/arcs/sdk/GeneratedEntityTest.kt +++ b/javatests/arcs/sdk/GeneratedEntityTest.kt @@ -6,6 +6,7 @@ import arcs.core.data.FieldType import arcs.core.data.RawEntity import arcs.core.data.RawEntity.Companion.NO_REFERENCE_ID import arcs.core.data.SchemaRegistry +import arcs.core.data.testutil.RawEntitySubject.Companion.assertThat import arcs.core.data.util.ReferencableList import arcs.core.data.util.toReferencable import arcs.core.entity.testutil.FixtureEntities