diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b56cecbcd1a..23067a39c51 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # How to contribute to Arcs -Thank you for taking the time to contribute to the Arcs project. +Thank you for taking the time to contribute to the Arcs project. This guide outlines how to become an Arcs developer. **Table of Contents** @@ -33,12 +33,12 @@ This guide outlines how to become an Arcs developer. **If you notice a security issue, please file a bug.** -* Before filing an [issue](https://github.com/PolymerLabs/arcs/issues), please check if one already exists. +* Before filing an [issue](https://github.com/PolymerLabs/arcs/issues), please check if one already exists. * After filing an issue, please attach an appropriate [label](https://github.com/PolymerLabs/arcs/labels). -* Questions are welcome! If you do ask a question that doesn't have an answer, please add the -[question](https://github.com/PolymerLabs/arcs/labels/question) or +* Questions are welcome! If you do ask a question that doesn't have an answer, please add the +[question](https://github.com/PolymerLabs/arcs/labels/question) or [design question](https://github.com/PolymerLabs/arcs/labels/design%20question) label to your issue. * All `TODO`s in the project need to be tracked with a buginizer bug or an issue (e.g. `TODO(#3838)`). @@ -49,18 +49,18 @@ This guide outlines how to become an Arcs developer. 1) Create a PR and go through reviews. - If you are an external contributor, you will have to agree to the + If you are an external contributor, you will have to agree to the [Contributor License Agreement](https://opensource.google/docs/cla/). 1) When you are ready to merge, add the "ready to pull" label to your PR. - This will trigger an internal review process for the change. If you are an + This will trigger an internal review process for the change. If you are an internal contributor, please click `+2` to the Safe Review. Otherwise, please reach out to an [approved committer](AUTHORS.md) to help you land the change. - -1) [Copybara](https://github.com/google/copybara) will create another import CL. + +1) [Copybara](https://github.com/google/copybara) will create another import CL. Get _another [approved committer](AUTHORS.md)_ to approve the CL. - + 1) When GCB and our internal integration tests are green, the import CL will be automatically submitted and the corresponding PR will be merged on GitHub. @@ -90,7 +90,7 @@ This guide outlines how to become an Arcs developer. ```shell script $ npm install -g npm # can use npm@6.3.0 to install a specific version ``` - + 1) Setup subprojects & invoke `sigh`. ```shell script @@ -101,7 +101,7 @@ This guide outlines how to become an Arcs developer. `tools/npm-install-all` is required on a fresh checkout. After that it only needs to be re-run infrequently as new dependencies are included, and usually a build failure will be the signal for that. - + `tools/sigh` is the web-runtime's main build tool. Please run `tools/sigh --help` to see all available commands. @@ -111,36 +111,36 @@ If you only want to develop using JavaScript, the following instructions are opt These are required for building / running WebAssembly particles, or working with Android. 1) Install Bazel. - - Please follow the [official docs](https://docs.bazel.build/versions/master/install.html) to - learn how to install Bazel on your machine. - + + Please follow the [official docs](https://docs.bazel.build/versions/master/install.html) to + learn how to install Bazel on your machine. + 1) Install the Android SDK. - Follow steps 1-3 of [this section of the IDE Setup doc](docs/IDE-Setup.md#add-android-support) to install the - Android SDK. - + Follow steps 1-3 of [this section of the IDE Setup doc](docs/IDE-Setup.md#add-android-support) to install the + Android SDK. + 1) Install [ktlint](https://ktlint.github.io/). ```shell script - $ mkdir -p $HOME/bin && cd $HOME/bin && curl -L -s -O https://github.com/pinterest/ktlint/releases/download/0.35.0/ktlint && cd - + $ mkdir -p $HOME/bin && cd $HOME/bin && curl -L -s -O https://github.com/pinterest/ktlint/releases/download/0.39.0/ktlint && cd - $ chmod a+x $HOME/bin/ktlint $ echo 'export PATH="$HOME/bin:$PATH"' >> $HOME/.bashrc ``` - + Thereafter, lint checks can be done with `tools/sigh lint` or `tools/sigh ktlint`. - + 1) Build & run targets with Bazelisk - - Our project manages Bazel versions with Bazelisk. To run a test or build a target, please + + Our project manages Bazel versions with Bazelisk. To run a test or build a target, please use the wrapper in `tools/`. For example: - + ```shell script $ tools/bazelisk sync $ tools/bazelisk build //java/... $ tools/bazelisk test //javatests/... ``` - + 1) For more information about Wasm, see the [C++ wasm instructions](src/wasm/cpp/README.md). @@ -167,9 +167,9 @@ These are required for building / running WebAssembly particles, or working with ### Mac Installation Notes -- Instructions above assume that Command Line Tools are installed. To check or install these, run the +- Instructions above assume that Command Line Tools are installed. To check or install these, run the following command: - + `xcode-select --version || xcode-select --install` - When installing, if you run into SSL Cert verification errors, consider certifying Python 3.6 on Mac: `/Applications/Python\ 3.6/Install\ Certificates.command` ([source](https://stackoverflow.com/a/42334357)) diff --git a/Dockerfile b/Dockerfile index b7e052888c7..ee062791cd7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,7 @@ WORKDIR $WORKSPACE # Install ktlint RUN (cd /usr/bin/ && \ - curl -L -s -O https://github.com/pinterest/ktlint/releases/download/0.35.0/ktlint && \ + curl -L -s -O https://github.com/pinterest/ktlint/releases/download/0.39.0/ktlint && \ cd - && \ chmod +x /usr/bin/ktlint) diff --git a/java/arcs/android/common/resurrection/DbHelper.kt b/java/arcs/android/common/resurrection/DbHelper.kt index fac2a8fcd0f..381767cfb9a 100644 --- a/java/arcs/android/common/resurrection/DbHelper.kt +++ b/java/arcs/android/common/resurrection/DbHelper.kt @@ -146,7 +146,7 @@ class DbHelper( SELECT component_package, component_class, notification_key, target_id FROM requested_notifiers - """.trimIndent(), + """.trimIndent(), null ).forEach { val componentName = ComponentName(it.getString(0), it.getString(1)) @@ -171,7 +171,7 @@ class DbHelper( intent_extras, target_id FROM resurrection_requests - """.trimIndent(), + """.trimIndent(), null ).map { val componentName = ComponentName(it.getString(0), it.getString(1)) @@ -223,7 +223,7 @@ class DbHelper( intent_extras BLOB, PRIMARY KEY (component_package, component_class, target_id) ) - """.trimIndent(), + """.trimIndent(), """ CREATE TABLE requested_notifiers ( component_package TEXT NOT NULL, @@ -231,7 +231,7 @@ class DbHelper( target_id TEXT NOT NULL, notification_key TEXT NOT NULL ) - """.trimIndent(), + """.trimIndent(), """ CREATE INDEX notifiers_by_component_and_id ON requested_notifiers ( @@ -239,7 +239,7 @@ class DbHelper( component_class, target_id ) - """.trimIndent() + """.trimIndent() ) private val VERSION_2_MIGRATION = arrayOf( diff --git a/java/arcs/android/common/resurrection/ResurrectorService.kt b/java/arcs/android/common/resurrection/ResurrectorService.kt index 24bd7b75210..f93514055a1 100644 --- a/java/arcs/android/common/resurrection/ResurrectorService.kt +++ b/java/arcs/android/common/resurrection/ResurrectorService.kt @@ -18,7 +18,6 @@ import androidx.annotation.VisibleForTesting import arcs.android.common.resurrection.ResurrectionRequest.UnregisterRequest import arcs.core.storage.StorageKey import arcs.core.util.guardedBy -import java.io.PrintWriter import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -29,6 +28,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import java.io.PrintWriter /** * Extension point for [Service]s which wish to be capable of resurrecting their clients. @@ -46,9 +46,9 @@ abstract class ResurrectorService : Service() { private val mutex = Mutex() private var registeredRequests: Set - by guardedBy(mutex, setOf()) + by guardedBy(mutex, setOf()) private var registeredRequestsByNotifiers: Map> - by guardedBy(mutex, mapOf()) + by guardedBy(mutex, mapOf()) @VisibleForTesting var loadJob: Job? = null @@ -118,7 +118,7 @@ abstract class ResurrectorService : Service() { """ Resurrection Requests --------------------- - """.trimIndent() + """.trimIndent() ) val requests = StringBuilder().apply { diff --git a/java/arcs/android/crdt/ReferencableInlineEntityListProto.kt b/java/arcs/android/crdt/ReferencableInlineEntityListProto.kt index 9869c1b56cb..ae2f3157708 100644 --- a/java/arcs/android/crdt/ReferencableInlineEntityListProto.kt +++ b/java/arcs/android/crdt/ReferencableInlineEntityListProto.kt @@ -35,12 +35,14 @@ fun ReferencableList<*>.toInlineEntityListProto(): ReferencableInlineEntityListP ReferencableInlineEntityListProto .newBuilder() .setType(type.schemaHash) - .addAllValue(value.map { - require(it is RawEntity) { - "Non-entity found in entity list" + .addAllValue( + value.map { + require(it is RawEntity) { + "Non-entity found in entity list" + } + it.toProto() } - it.toProto() - }) + ) .build() } else -> throw IllegalStateException( diff --git a/java/arcs/android/crdt/ReferencablePrimitiveListProto.kt b/java/arcs/android/crdt/ReferencablePrimitiveListProto.kt index 33979605c79..6dac3388b7d 100644 --- a/java/arcs/android/crdt/ReferencablePrimitiveListProto.kt +++ b/java/arcs/android/crdt/ReferencablePrimitiveListProto.kt @@ -32,16 +32,19 @@ fun ReferencablePrimitiveListProto.toReferencableList(): ReferencableList.toPrimitiveListProto(): ReferencablePrimitiveListProto { val type = (itemType as FieldType.ListOf).primitiveType return when (type) { - is FieldType.Primitive -> ReferencablePrimitiveListProto - .newBuilder() - .setType(type.primitiveType.ordinal) - .addAllValue(value.map { - require(it is ReferencablePrimitive<*>) { - "Non-primitive found in primitive list" - } - it.toProto() - }) - .build() + is FieldType.Primitive -> + ReferencablePrimitiveListProto + .newBuilder() + .setType(type.primitiveType.ordinal) + .addAllValue( + value.map { + require(it is ReferencablePrimitive<*>) { + "Non-primitive found in primitive list" + } + it.toProto() + } + ) + .build() else -> throw IllegalStateException("Invalid FieldType for primitive ReferencableList") } } diff --git a/java/arcs/android/crdt/ReferencableReferenceListProto.kt b/java/arcs/android/crdt/ReferencableReferenceListProto.kt index eb937c347f9..3b3299236b6 100644 --- a/java/arcs/android/crdt/ReferencableReferenceListProto.kt +++ b/java/arcs/android/crdt/ReferencableReferenceListProto.kt @@ -35,12 +35,14 @@ fun ReferencableList<*>.toReferenceListProto(): ReferencableReferenceListProto { ReferencableReferenceListProto .newBuilder() .setType(type.schemaHash) - .addAllValue(value.map { - require(it is Reference) { - "Non-reference found in reference list" + .addAllValue( + value.map { + require(it is Reference) { + "Non-reference found in reference list" + } + it.toProto() } - it.toProto() - }) + ) .build() } else -> throw IllegalStateException("Invalid FieldType for ReferencableList of references") diff --git a/java/arcs/android/devtools/ModelUpdateMessage.kt b/java/arcs/android/devtools/ModelUpdateMessage.kt index 0e998a7be84..0154a25d266 100644 --- a/java/arcs/android/devtools/ModelUpdateMessage.kt +++ b/java/arcs/android/devtools/ModelUpdateMessage.kt @@ -62,7 +62,8 @@ class ModelUpdateMessage( collections: Map> ) = JsonValue.JsonObject( collections.map { - (name, collection) -> name to JsonValue.JsonObject( + (name, collection) -> + name to JsonValue.JsonObject( VERSION_MAP to collection.data.versionMap.toJson(), "values" to getValues(collection.data.values) ) @@ -76,7 +77,8 @@ class ModelUpdateMessage( singletons: Map> ) = JsonValue.JsonObject( singletons.map { - (name, singleton) -> name to JsonValue.JsonObject( + (name, singleton) -> + name to JsonValue.JsonObject( VERSION_MAP to singleton.data.versionMap.toJson(), "values" to getValues(singleton.data.values) ) diff --git a/java/arcs/android/labs/host/AndroidManifestHostRegistry.kt b/java/arcs/android/labs/host/AndroidManifestHostRegistry.kt index d0529b8028a..95d490549cc 100644 --- a/java/arcs/android/labs/host/AndroidManifestHostRegistry.kt +++ b/java/arcs/android/labs/host/AndroidManifestHostRegistry.kt @@ -78,13 +78,15 @@ class AndroidManifestHostRegistry private constructor( override suspend fun availableArcHosts(): List { if (arcHosts.isEmpty()) { - arcHosts.addAll(serviceHosts.flatMap { registryHost -> - try { - registryHost.registeredHosts() - } catch (e: TimeoutCancellationException) { - emptyList() + arcHosts.addAll( + serviceHosts.flatMap { registryHost -> + try { + registryHost.registeredHosts() + } catch (e: TimeoutCancellationException) { + emptyList() + } } - }) + ) } return arcHosts } diff --git a/java/arcs/android/labs/host/prod/ProdArcHostService.kt b/java/arcs/android/labs/host/prod/ProdArcHostService.kt index 79a58b48b1a..c899e91cf0f 100644 --- a/java/arcs/android/labs/host/prod/ProdArcHostService.kt +++ b/java/arcs/android/labs/host/prod/ProdArcHostService.kt @@ -22,8 +22,8 @@ import arcs.core.storage.StorageEndpointManager import arcs.jvm.host.scanForParticles import arcs.sdk.android.labs.host.AndroidHost import arcs.sdk.android.labs.host.ArcHostService -import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlin.coroutines.CoroutineContext /** * An isolatable (can run in another process) [Service] that has a [ProdHost] inside. [Particle] diff --git a/java/arcs/android/storage/database/DatabaseImpl.kt b/java/arcs/android/storage/database/DatabaseImpl.kt index cf797f7d382..860a1d0df48 100644 --- a/java/arcs/android/storage/database/DatabaseImpl.kt +++ b/java/arcs/android/storage/database/DatabaseImpl.kt @@ -69,9 +69,6 @@ import arcs.core.util.performance.PerformanceStatistics import arcs.core.util.performance.Timer import arcs.jvm.util.JvmTime import com.google.protobuf.InvalidProtocolBufferException -import kotlin.coroutines.coroutineContext -import kotlin.math.roundToLong -import kotlin.reflect.KClass import kotlinx.atomicfu.atomic import kotlinx.atomicfu.updateAndGet import kotlinx.coroutines.CoroutineScope @@ -83,6 +80,9 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import kotlin.coroutines.coroutineContext +import kotlin.math.roundToLong +import kotlin.reflect.KClass /** The Type ID that gets stored in the database. */ typealias TypeId = Long @@ -944,7 +944,7 @@ class DatabaseImpl( if (storageKey is InlineStorageKey) { throw UnsupportedOperationException( "Invalid attempt to delete inline storage key $storageKey." + - " Inline entities should not be removed using delete()." + " Inline entities should not be removed using delete()." ) } counters.increment(DatabaseCounters.GET_STORAGE_KEY_ID) diff --git a/java/arcs/android/storage/service/DevToolsStorageManager.kt b/java/arcs/android/storage/service/DevToolsStorageManager.kt index d64a7f376b7..188124d95e6 100644 --- a/java/arcs/android/storage/service/DevToolsStorageManager.kt +++ b/java/arcs/android/storage/service/DevToolsStorageManager.kt @@ -12,8 +12,8 @@ package arcs.android.storage.service import arcs.core.storage.StorageKey -import java.util.concurrent.ConcurrentHashMap import kotlinx.coroutines.ExperimentalCoroutinesApi +import java.util.concurrent.ConcurrentHashMap /** * A [DevToolsStorageManager] is used by a client of the [StorageService] to manage diff --git a/java/arcs/android/storage/service/MuxedStorageServiceImpl.kt b/java/arcs/android/storage/service/MuxedStorageServiceImpl.kt index ef3ff9282d2..3c58c6d6974 100644 --- a/java/arcs/android/storage/service/MuxedStorageServiceImpl.kt +++ b/java/arcs/android/storage/service/MuxedStorageServiceImpl.kt @@ -19,9 +19,9 @@ import arcs.core.storage.UntypedDirectStoreMuxer import arcs.core.storage.WriteBackProvider import arcs.flags.BuildFlagDisabledError import arcs.flags.BuildFlags -import java.util.concurrent.ConcurrentHashMap import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch +import java.util.concurrent.ConcurrentHashMap /** * Implementation of the [IMuxedStorageService] AIDL interface. Responsible for forwarding messages diff --git a/java/arcs/android/storage/service/StorageServiceManager.kt b/java/arcs/android/storage/service/StorageServiceManager.kt index bca87e36e7e..80aa0b02b01 100644 --- a/java/arcs/android/storage/service/StorageServiceManager.kt +++ b/java/arcs/android/storage/service/StorageServiceManager.kt @@ -15,10 +15,10 @@ import arcs.core.host.ArcHostManager import arcs.core.storage.DriverFactory import arcs.core.storage.StorageKey import arcs.core.storage.driver.DatabaseDriverProvider -import java.util.concurrent.ConcurrentHashMap import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.launch +import java.util.concurrent.ConcurrentHashMap /** * A [StorageServiceManager] is used by a client of the [StorageService] to manage diff --git a/java/arcs/android/storage/service/StorageServiceNgImpl.kt b/java/arcs/android/storage/service/StorageServiceNgImpl.kt index be35f7eac34..7686bfa847d 100644 --- a/java/arcs/android/storage/service/StorageServiceNgImpl.kt +++ b/java/arcs/android/storage/service/StorageServiceNgImpl.kt @@ -20,9 +20,9 @@ import arcs.core.storage.UntypedProxyMessage import arcs.core.storage.WriteBackProvider import arcs.flags.BuildFlagDisabledError import arcs.flags.BuildFlags -import java.util.concurrent.ConcurrentHashMap import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch +import java.util.concurrent.ConcurrentHashMap /** * Implementation of the [IStorageServiceNg] AIDL interface. Responsible for forwarding messages diff --git a/java/arcs/android/storage/service/SuspendingServiceMethods.kt b/java/arcs/android/storage/service/SuspendingServiceMethods.kt index 5d2f0a6c614..93dfa6d5408 100644 --- a/java/arcs/android/storage/service/SuspendingServiceMethods.kt +++ b/java/arcs/android/storage/service/SuspendingServiceMethods.kt @@ -3,10 +3,10 @@ package arcs.android.storage.service import android.os.IBinder import arcs.android.crdt.CrdtExceptionProto import arcs.android.crdt.decode -import kotlin.coroutines.resumeWithException import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.suspendCancellableCoroutine +import kotlin.coroutines.resumeWithException // The documentation provides no information about these flags, and any examples seem to // always use 0, so we use 0 here. diff --git a/java/arcs/core/allocator/CollectionHandlePartitionMap.kt b/java/arcs/core/allocator/CollectionHandlePartitionMap.kt index 84dddb6e2c5..325ff6c1244 100644 --- a/java/arcs/core/allocator/CollectionHandlePartitionMap.kt +++ b/java/arcs/core/allocator/CollectionHandlePartitionMap.kt @@ -39,15 +39,17 @@ class CollectionHandlePartitionMap( @Suppress("UNCHECKED_CAST") private val collection = SuspendableLazy { val entitySpec = EntityBaseSpec(SCHEMA) - (handleManager.createHandle( - HandleSpec( - "partitions", - HandleMode.ReadWrite, - CollectionType(EntityType(entitySpec.SCHEMA)), - entitySpec - ), - STORAGE_KEY - ) as ReadWriteCollectionHandle).also { + ( + handleManager.createHandle( + HandleSpec( + "partitions", + HandleMode.ReadWrite, + CollectionType(EntityType(entitySpec.SCHEMA)), + entitySpec + ), + STORAGE_KEY + ) as ReadWriteCollectionHandle + ).also { it.awaitReady() } } diff --git a/java/arcs/core/analysis/AccessPathLabels.kt b/java/arcs/core/analysis/AccessPathLabels.kt index 9ff97158633..42115109399 100644 --- a/java/arcs/core/analysis/AccessPathLabels.kt +++ b/java/arcs/core/analysis/AccessPathLabels.kt @@ -90,9 +90,10 @@ data class AccessPathLabels private constructor( return when { _accessPathLabels.isTop -> "${linePrefix}TOP" _accessPathLabels.isBottom -> "${linePrefix}BOTTOM" - else -> requireNotNull(_accessPathLabels.value).map { (accessPath, labels) -> - "$accessPath -> ${labels.toString(transform)}" - }.joinToString("\n$linePrefix", prefix = linePrefix) + else -> + requireNotNull(_accessPathLabels.value).map { (accessPath, labels) -> + "$accessPath -> ${labels.toString(transform)}" + }.joinToString("\n$linePrefix", prefix = linePrefix) } } diff --git a/java/arcs/core/analysis/InformationFlow.kt b/java/arcs/core/analysis/InformationFlow.kt index fcab26aa06c..49b92475cff 100644 --- a/java/arcs/core/analysis/InformationFlow.kt +++ b/java/arcs/core/analysis/InformationFlow.kt @@ -337,11 +337,12 @@ class InformationFlow private constructor( Tag.Mux -> { (this as MuxType<*>).containedType.typeVariableClaims(prefix, restrictions) } - Tag.Tuple -> (this as TupleType).elementTypes - .foldIndexed(emptyList()) { index, acc, cur -> - val newPrefix = AccessPath(prefix.root, prefix.selectors + getTupleField(index)) - acc + cur.typeVariableClaims(newPrefix, restrictions) - } + Tag.Tuple -> + (this as TupleType).elementTypes + .foldIndexed(emptyList()) { index, acc, cur -> + val newPrefix = AccessPath(prefix.root, prefix.selectors + getTupleField(index)) + acc + cur.typeVariableClaims(newPrefix, restrictions) + } Tag.Singleton -> { (this as SingletonType<*>).containedType.typeVariableClaims(prefix, restrictions) } @@ -438,10 +439,11 @@ class InformationFlow private constructor( // TODO(b/154234733): This only supports simple use cases of references. Tag.Reference -> (this as ReferenceType<*>).containedType.accessPathSelectors(partial) Tag.Mux -> (this as MuxType<*>).containedType.accessPathSelectors(partial) - Tag.Tuple -> (this as TupleType).elementTypes - .foldIndexed(emptySet>()) { index, acc, cur -> - acc + cur.accessPathSelectors(partial).map { listOf(getTupleField(index)) + it } - } + Tag.Tuple -> + (this as TupleType).elementTypes + .foldIndexed(emptySet>()) { index, acc, cur -> + acc + cur.accessPathSelectors(partial).map { listOf(getTupleField(index)) + it } + } Tag.Singleton -> (this as SingletonType<*>).containedType.accessPathSelectors(partial) Tag.TypeVariable -> throw IllegalArgumentException("TypeVariable should be resolved!") } diff --git a/java/arcs/core/common/CompositeException.kt b/java/arcs/core/common/CompositeException.kt index f373a1b6dfa..9fe01255764 100644 --- a/java/arcs/core/common/CompositeException.kt +++ b/java/arcs/core/common/CompositeException.kt @@ -1,11 +1,11 @@ package arcs.core.common -import java.io.PrintWriter -import java.io.StringWriter import kotlinx.coroutines.Deferred import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.async import kotlinx.coroutines.supervisorScope +import java.io.PrintWriter +import java.io.StringWriter /** * This class wraps one or more exceptions that occur when running a set of operations on all diff --git a/java/arcs/core/crdt/CrdtEntity.kt b/java/arcs/core/crdt/CrdtEntity.kt index 077637480bc..94473310118 100644 --- a/java/arcs/core/crdt/CrdtEntity.kt +++ b/java/arcs/core/crdt/CrdtEntity.kt @@ -13,15 +13,15 @@ package arcs.core.crdt import arcs.core.common.Referencable import arcs.core.common.ReferenceId +import arcs.core.data.FieldName +import arcs.core.data.RawEntity +import arcs.core.data.util.ReferencablePrimitive import arcs.core.crdt.CrdtSet.Data as SetData import arcs.core.crdt.CrdtSet.IOperation as ISetOp import arcs.core.crdt.CrdtSet.Operation as SetOp import arcs.core.crdt.CrdtSingleton.Data as SingletonData import arcs.core.crdt.CrdtSingleton.IOperation as ISingletonOp import arcs.core.crdt.CrdtSingleton.Operation as SingletonOp -import arcs.core.data.FieldName -import arcs.core.data.RawEntity -import arcs.core.data.util.ReferencablePrimitive /** * A [CrdtModel] capable of managing a complex entity consisting of named [CrdtSingleton]s and named diff --git a/java/arcs/core/data/expression/Builders.kt b/java/arcs/core/data/expression/Builders.kt index 076d9a9e48a..597eceb1658 100644 --- a/java/arcs/core/data/expression/Builders.kt +++ b/java/arcs/core/data/expression/Builders.kt @@ -240,9 +240,12 @@ open class MapScope( } override fun toString() = - """$scopeName ${allKeys.joinToString(", ", prefix = "{", postfix = "}", transform = { - "$it: ${lookup(it)}" - })}""" + """$scopeName ${allKeys.joinToString( + ", ", prefix = "{", postfix = "}", + transform = { + "$it: ${lookup(it)}" + } + )}""" } /** Constructs a [Scope] from a [Map]. */ diff --git a/java/arcs/core/data/expression/EvaluatorParticle.kt b/java/arcs/core/data/expression/EvaluatorParticle.kt index 9ba370bb366..850cf893d3e 100644 --- a/java/arcs/core/data/expression/EvaluatorParticle.kt +++ b/java/arcs/core/data/expression/EvaluatorParticle.kt @@ -162,7 +162,8 @@ class EvaluatorParticle( time: Time? = null ): ParticleRegistration { return EvaluatorParticle::class.toParticleIdentifier() to { - spec -> EvaluatorParticle(spec, analytics, time) + spec -> + EvaluatorParticle(spec, analytics, time) } } } diff --git a/java/arcs/core/data/expression/Expression.kt b/java/arcs/core/data/expression/Expression.kt index c60331fcfb3..24d7a1c1189 100644 --- a/java/arcs/core/data/expression/Expression.kt +++ b/java/arcs/core/data/expression/Expression.kt @@ -545,7 +545,8 @@ private operator fun Number.compareTo(other: Number) = widenAndApply( ).toInt() private operator fun Number.plus(other: Number): Number { - return widenAndApply(this, other, + return widenAndApply( + this, other, { l, r -> l + r }, { l, r -> l + r }, { l, r -> l + r }, @@ -554,7 +555,8 @@ private operator fun Number.plus(other: Number): Number { } private operator fun Number.minus(other: Number): Number { - return widenAndApply(this, other, + return widenAndApply( + this, other, { l, r -> l - r }, { l, r -> l - r }, { l, r -> l - r }, @@ -563,7 +565,8 @@ private operator fun Number.minus(other: Number): Number { } private operator fun Number.times(other: Number): Number { - return widenAndApply(this, other, + return widenAndApply( + this, other, { l, r -> l * r }, { l, r -> l * r }, { l, r -> l * r }, @@ -572,7 +575,8 @@ private operator fun Number.times(other: Number): Number { } private operator fun Number.div(other: Number): Number { - return widenAndApply(this, other, + return widenAndApply( + this, other, { l, r -> l / r }, { l, r -> l / r }, { l, r -> l / r }, diff --git a/java/arcs/core/data/expression/InferredType.kt b/java/arcs/core/data/expression/InferredType.kt index 8fa14618968..ce8b3614ab0 100644 --- a/java/arcs/core/data/expression/InferredType.kt +++ b/java/arcs/core/data/expression/InferredType.kt @@ -110,9 +110,11 @@ sealed class InferredType { data class UnionType(val types: Set) : InferredType() { constructor(vararg types: InferredType) : this(setOf(*types)) - override fun nonNull(): InferredType = UnionType(types.map { it.nonNull() }.filterNot { - it is Primitive.NullType - }.toSet()) + override fun nonNull(): InferredType = UnionType( + types.map { it.nonNull() }.filterNot { + it is Primitive.NullType + }.toSet() + ) override fun toString() = "${types.joinToString(separator = "|")}" diff --git a/java/arcs/core/data/expression/PaxelParser.kt b/java/arcs/core/data/expression/PaxelParser.kt index 79ab332fa17..cd1da52ae5a 100644 --- a/java/arcs/core/data/expression/PaxelParser.kt +++ b/java/arcs/core/data/expression/PaxelParser.kt @@ -80,16 +80,18 @@ object PaxelParser : Grammar>() { private val colon by -regex("($WS*:$WS*)") private val units by - optional(whitespace + - (regex("(millisecond)s?").map { Unit.Millisecond } / - regex("(second)s?").map { Unit.Second } / - regex("(minute)s?").map { Unit.Minute } / - regex("(hour)s?").map { Unit.Hour } / - regex("(day)s?").map { Unit.Day } + optional( + whitespace + + ( + regex("(millisecond)s?").map { Unit.Millisecond } / + regex("(second)s?").map { Unit.Second } / + regex("(minute)s?").map { Unit.Minute } / + regex("(hour)s?").map { Unit.Hour } / + regex("(day)s?").map { Unit.Day } ) - ).map { - it ?: Unit.Identity - } + ).map { + it ?: Unit.Identity + } private val typeIdentifier by token("n").map { DiscreteType.PaxelBigInt } / @@ -135,7 +137,8 @@ object PaxelParser : Grammar>() { Expression.FunctionExpression( maybeFail("unknown function name $id") { GlobalFunction.of(id) - }, args + }, + args ) } @@ -271,14 +274,14 @@ object PaxelParser : Grammar>() { (fromExpression / whereExpression / letExpression / orderByExpression) private val expressionWithQualifier by - (fromExpression + many(ows + qualifiedExpression) + selectExpression) - .map { (first, rest, select) -> - val all: List = listOf(first) + rest + listOf(select) - val nullQualifier: QualifiedExpression? = null - all.fold(nullQualifier) { qualifier: QualifiedExpression?, qualified: QualifiedExpression -> - qualified.withQualifier(qualifier) - } + (fromExpression + many(ows + qualifiedExpression) + selectExpression) + .map { (first, rest, select) -> + val all: List = listOf(first) + rest + listOf(select) + val nullQualifier: QualifiedExpression? = null + all.fold(nullQualifier) { qualifier: QualifiedExpression?, qualified: QualifiedExpression -> + qualified.withQualifier(qualifier) } + } @Suppress("UNCHECKED_CAST") private val paxelExpression by diff --git a/java/arcs/core/data/expression/RawEntityScope.kt b/java/arcs/core/data/expression/RawEntityScope.kt index f4c07857233..4647d55d87e 100644 --- a/java/arcs/core/data/expression/RawEntityScope.kt +++ b/java/arcs/core/data/expression/RawEntityScope.kt @@ -59,7 +59,8 @@ class RawEntityScope(val rawEntity: RawEntity) : Expression.Scope { } override fun properties(): Set = rawEntity.allData.map { - (name, _) -> name + (name, _) -> + name }.toSet() } diff --git a/java/arcs/core/data/expression/Serializer.kt b/java/arcs/core/data/expression/Serializer.kt index f6a610ddc7d..c52c2f4c924 100644 --- a/java/arcs/core/data/expression/Serializer.kt +++ b/java/arcs/core/data/expression/Serializer.kt @@ -131,7 +131,8 @@ class ExpressionSerializer() : Expression.Visitor, Unit> { "op" to JsonString("function"), "functionName" to JsonString(expr.function.name), "arguments" to JsonArray( - expr.arguments.map { it.accept(this, ctx) }) + expr.arguments.map { it.accept(this, ctx) } + ) ) ) @@ -139,9 +140,10 @@ class ExpressionSerializer() : Expression.Visitor, Unit> { JsonObject( mapOf( "op" to JsonString("orderBy"), - "selectors" to JsonArray(expr.selectors.map { sel -> - JsonArray(listOf(sel.expr.accept(this, ctx), JsonBoolean(sel.descending))) - } + "selectors" to JsonArray( + expr.selectors.map { sel -> + JsonArray(listOf(sel.expr.accept(this, ctx), JsonBoolean(sel.descending))) + } ), "qualifier" to expr.qualifier.accept(this, ctx) ) diff --git a/java/arcs/core/data/expression/Stringifier.kt b/java/arcs/core/data/expression/Stringifier.kt index 8228a11c72f..7daf9cb2d2c 100644 --- a/java/arcs/core/data/expression/Stringifier.kt +++ b/java/arcs/core/data/expression/Stringifier.kt @@ -66,7 +66,8 @@ class ExpressionStringifier(val parameterScope: Expression.Scope = ParameterScop "new " + expr.schemaName.joinToString(" ") + expr.fields.joinToString( ",\n ", " {\n ", - "\n}", transform = { (name, fieldExpr) -> + "\n}", + transform = { (name, fieldExpr) -> "$name: " + fieldExpr.accept(this, ctx) } ) @@ -75,7 +76,8 @@ class ExpressionStringifier(val parameterScope: Expression.Scope = ParameterScop expr.function.name + expr.arguments.joinToString( ",\n ", "(\n ", - "\n)", transform = { argExpr -> + "\n)", + transform = { argExpr -> argExpr.accept(this, ctx) } ) @@ -84,11 +86,13 @@ class ExpressionStringifier(val parameterScope: Expression.Scope = ParameterScop expr.qualifier.accept(this, ctx) + "\norderby " + expr.selectors.joinToString( separator = ", " ) { sel -> - sel.expr.accept(this, ctx) + (if (sel.descending) { - " descending" - } else { - "" - }) + sel.expr.accept(this, ctx) + ( + if (sel.descending) { + " descending" + } else { + "" + } + ) } + "\n" } diff --git a/java/arcs/core/data/proto/ClaimProtoDecoder.kt b/java/arcs/core/data/proto/ClaimProtoDecoder.kt index 0baa02dfb4f..a8af81b7b06 100644 --- a/java/arcs/core/data/proto/ClaimProtoDecoder.kt +++ b/java/arcs/core/data/proto/ClaimProtoDecoder.kt @@ -36,14 +36,16 @@ fun ClaimProto.decode( fun Claim.encode(): ClaimProto { val proto = ClaimProto.newBuilder() when (this) { - is Claim.Assume -> proto.assume = ClaimProto.Assume.newBuilder() - .setAccessPath(accessPath.encode()) - .setPredicate(predicate.encode()) - .build() - is Claim.DerivesFrom -> proto.derivesFrom = ClaimProto.DerivesFrom.newBuilder() - .setSource(source.encode()) - .setTarget(target.encode()) - .build() + is Claim.Assume -> + proto.assume = ClaimProto.Assume.newBuilder() + .setAccessPath(accessPath.encode()) + .setPredicate(predicate.encode()) + .build() + is Claim.DerivesFrom -> + proto.derivesFrom = ClaimProto.DerivesFrom.newBuilder() + .setSource(source.encode()) + .setTarget(target.encode()) + .build() else -> throw IllegalArgumentException("Unsupported Claim type: $this") } return proto.build() diff --git a/java/arcs/core/data/proto/PredicateProtoDecoder.kt b/java/arcs/core/data/proto/PredicateProtoDecoder.kt index 7754feedb4e..f5868b4cf21 100644 --- a/java/arcs/core/data/proto/PredicateProtoDecoder.kt +++ b/java/arcs/core/data/proto/PredicateProtoDecoder.kt @@ -38,17 +38,20 @@ fun Predicate.encode(): InformationFlowLabelProto.Predicate { } proto.label = InformationFlowLabelProto.newBuilder().setSemanticTag(label.name).build() } - is Predicate.Not -> proto.not = InformationFlowLabelProto.Predicate.Not.newBuilder() - .setPredicate(predicate.encode()) - .build() - is Predicate.Or -> proto.or = InformationFlowLabelProto.Predicate.Or.newBuilder() - .setDisjunct0(lhs.encode()) - .setDisjunct1(rhs.encode()) - .build() - is Predicate.And -> proto.and = InformationFlowLabelProto.Predicate.And.newBuilder() - .setConjunct0(lhs.encode()) - .setConjunct1(rhs.encode()) - .build() + is Predicate.Not -> + proto.not = InformationFlowLabelProto.Predicate.Not.newBuilder() + .setPredicate(predicate.encode()) + .build() + is Predicate.Or -> + proto.or = InformationFlowLabelProto.Predicate.Or.newBuilder() + .setDisjunct0(lhs.encode()) + .setDisjunct1(rhs.encode()) + .build() + is Predicate.And -> + proto.and = InformationFlowLabelProto.Predicate.And.newBuilder() + .setConjunct0(lhs.encode()) + .setConjunct1(rhs.encode()) + .build() else -> throw UnsupportedOperationException("Unsupported Predicate type: $this") } return proto.build() diff --git a/java/arcs/core/data/proto/SchemaProtoDecoder.kt b/java/arcs/core/data/proto/SchemaProtoDecoder.kt index 1eb6e9923aa..0fdbc4b8684 100644 --- a/java/arcs/core/data/proto/SchemaProtoDecoder.kt +++ b/java/arcs/core/data/proto/SchemaProtoDecoder.kt @@ -83,23 +83,27 @@ private fun SchemaFields.encode(): Map { fun FieldType.encode(): TypeProto { return when (this) { is FieldType.Primitive -> primitiveType.encodePrimitive().asTypeProto() - is FieldType.EntityRef -> ReferenceTypeProto.newBuilder() - .setReferredType(EntityType(SchemaRegistry.getSchema(schemaHash)).encode()) - .build() - .asTypeProto() - is FieldType.Tuple -> TupleTypeProto.newBuilder() - .addAllElements(types.map { it.encode() }) - .build() - .asTypeProto() - is FieldType.ListOf -> ListTypeProto.newBuilder() - .setElementType(primitiveType.encode()) - .build() - .asTypeProto() - is FieldType.InlineEntity -> EntityTypeProto.newBuilder() - .setSchema(SchemaRegistry.getSchema(schemaHash).encode()) - .setInline(true) - .build() - .asTypeProto() + is FieldType.EntityRef -> + ReferenceTypeProto.newBuilder() + .setReferredType(EntityType(SchemaRegistry.getSchema(schemaHash)).encode()) + .build() + .asTypeProto() + is FieldType.Tuple -> + TupleTypeProto.newBuilder() + .addAllElements(types.map { it.encode() }) + .build() + .asTypeProto() + is FieldType.ListOf -> + ListTypeProto.newBuilder() + .setElementType(primitiveType.encode()) + .build() + .asTypeProto() + is FieldType.InlineEntity -> + EntityTypeProto.newBuilder() + .setSchema(SchemaRegistry.getSchema(schemaHash).encode()) + .setInline(true) + .build() + .asTypeProto() else -> throw UnsupportedOperationException("Unsupported FieldType: $this") } } diff --git a/java/arcs/core/data/proto/TypeProtoDecoders.kt b/java/arcs/core/data/proto/TypeProtoDecoders.kt index f44efee33d3..df32e55d982 100644 --- a/java/arcs/core/data/proto/TypeProtoDecoders.kt +++ b/java/arcs/core/data/proto/TypeProtoDecoders.kt @@ -148,26 +148,31 @@ fun Type.encode(): TypeProto = when (this) { proto.constraint = infoBuilder.build() proto.build().asTypeProto() } - is EntityType -> EntityTypeProto.newBuilder() - .setSchema(entitySchema.encode()) - .build() - .asTypeProto() - is SingletonType<*> -> SingletonTypeProto.newBuilder() - .setSingletonType(containedType.encode()) - .build() - .asTypeProto() - is CollectionType<*> -> CollectionTypeProto.newBuilder() - .setCollectionType(containedType.encode()) - .build() - .asTypeProto() - is ReferenceType<*> -> ReferenceTypeProto.newBuilder() - .setReferredType(containedType.encode()) - .build() - .asTypeProto() - is TupleType -> TupleTypeProto.newBuilder() - .addAllElements(elementTypes.map { it.encode() }) - .build() - .asTypeProto() + is EntityType -> + EntityTypeProto.newBuilder() + .setSchema(entitySchema.encode()) + .build() + .asTypeProto() + is SingletonType<*> -> + SingletonTypeProto.newBuilder() + .setSingletonType(containedType.encode()) + .build() + .asTypeProto() + is CollectionType<*> -> + CollectionTypeProto.newBuilder() + .setCollectionType(containedType.encode()) + .build() + .asTypeProto() + is ReferenceType<*> -> + ReferenceTypeProto.newBuilder() + .setReferredType(containedType.encode()) + .build() + .asTypeProto() + is TupleType -> + TupleTypeProto.newBuilder() + .addAllElements(elementTypes.map { it.encode() }) + .build() + .asTypeProto() is CountType -> CountTypeProto.getDefaultInstance().asTypeProto() else -> throw UnsupportedOperationException("Unsupported Type: $this") } diff --git a/java/arcs/core/entity/EntityBase.kt b/java/arcs/core/entity/EntityBase.kt index 5c543b39389..ea1eae29d37 100644 --- a/java/arcs/core/entity/EntityBase.kt +++ b/java/arcs/core/entity/EntityBase.kt @@ -25,11 +25,11 @@ import arcs.core.data.SchemaRegistry import arcs.core.data.util.ReferencableList import arcs.core.data.util.ReferencablePrimitive import arcs.core.data.util.toReferencable -import arcs.core.storage.Reference as StorageReference import arcs.core.util.ArcsInstant import arcs.core.util.BigInt import arcs.core.util.Time import kotlin.reflect.KProperty +import arcs.core.storage.Reference as StorageReference open class EntityBase( private val entityClassName: String, diff --git a/java/arcs/core/entity/Handle.kt b/java/arcs/core/entity/Handle.kt index 926a0cde047..ea013fd100c 100644 --- a/java/arcs/core/entity/Handle.kt +++ b/java/arcs/core/entity/Handle.kt @@ -19,10 +19,10 @@ import arcs.core.data.SingletonType import arcs.core.storage.StorageProxy import arcs.core.storage.StorageProxy.StorageEvent import arcs.core.type.Type -import kotlin.coroutines.resume import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.Job import kotlinx.coroutines.suspendCancellableCoroutine +import kotlin.coroutines.resume /** Base interface for all handle classes. */ interface Handle { diff --git a/java/arcs/core/entity/Reference.kt b/java/arcs/core/entity/Reference.kt index 3dcf463619c..65d87950944 100644 --- a/java/arcs/core/entity/Reference.kt +++ b/java/arcs/core/entity/Reference.kt @@ -13,8 +13,8 @@ package arcs.core.entity import arcs.core.common.Referencable import arcs.core.data.Capability.Ttl -import arcs.core.storage.Reference as StorageReference import arcs.core.util.Time +import arcs.core.storage.Reference as StorageReference /** A reference to an [Entity]. */ data class Reference( diff --git a/java/arcs/core/entity/StorageAdapter.kt b/java/arcs/core/entity/StorageAdapter.kt index eb65a9d9453..d36b743fcfc 100644 --- a/java/arcs/core/entity/StorageAdapter.kt +++ b/java/arcs/core/entity/StorageAdapter.kt @@ -15,11 +15,11 @@ import arcs.core.common.Referencable import arcs.core.data.Capability.Ttl import arcs.core.data.RawEntity import arcs.core.data.Schema -import arcs.core.storage.Reference as StorageReference import arcs.core.storage.StorageKey import arcs.core.storage.keys.DatabaseStorageKey import arcs.core.storage.referencemode.ReferenceModeStorageKey import arcs.core.util.Time +import arcs.core.storage.Reference as StorageReference /** Converts instances of developer-facing type [T] into a raw storage instances of type [R]. */ sealed class StorageAdapter { diff --git a/java/arcs/core/host/AbstractArcHost.kt b/java/arcs/core/host/AbstractArcHost.kt index 16ec9efb419..b13836c5b86 100644 --- a/java/arcs/core/host/AbstractArcHost.kt +++ b/java/arcs/core/host/AbstractArcHost.kt @@ -32,7 +32,6 @@ import arcs.core.util.TaggedLog import arcs.core.util.Time import arcs.core.util.guardedBy import arcs.core.util.withTaggedTimeout -import kotlin.coroutines.CoroutineContext import kotlinx.atomicfu.atomic import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope @@ -43,6 +42,7 @@ import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import kotlin.coroutines.CoroutineContext typealias ParticleConstructor = suspend (Plan.Particle?) -> Particle typealias ParticleRegistration = Pair diff --git a/java/arcs/core/host/ArcHostContextParticle.kt b/java/arcs/core/host/ArcHostContextParticle.kt index af8360157d7..075a1f0256c 100755 --- a/java/arcs/core/host/ArcHostContextParticle.kt +++ b/java/arcs/core/host/ArcHostContextParticle.kt @@ -30,10 +30,10 @@ import arcs.core.type.Tag import arcs.core.type.Type import arcs.core.util.plus import arcs.core.util.traverse -import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.Job import kotlinx.coroutines.joinAll import kotlinx.coroutines.withContext +import kotlin.coroutines.CoroutineContext typealias ArcHostContextParticle_HandleConnections = AbstractArcHostContextParticle.HandleConnection typealias ArcHostContextParticle_Particles = AbstractArcHostContextParticle.ParticleSchema diff --git a/java/arcs/core/host/SimpleSchedulerProvider.kt b/java/arcs/core/host/SimpleSchedulerProvider.kt index 51b578e9c21..96b9484de59 100644 --- a/java/arcs/core/host/SimpleSchedulerProvider.kt +++ b/java/arcs/core/host/SimpleSchedulerProvider.kt @@ -1,9 +1,9 @@ package arcs.core.host import arcs.core.util.Scheduler -import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.Job +import kotlin.coroutines.CoroutineContext /** * Simple implementation of a [SchedulerProvider]. diff --git a/java/arcs/core/storage/DirectStore.kt b/java/arcs/core/storage/DirectStore.kt index 4f4da466ab1..c05dc7d8485 100644 --- a/java/arcs/core/storage/DirectStore.kt +++ b/java/arcs/core/storage/DirectStore.kt @@ -23,7 +23,6 @@ import arcs.core.storage.DirectStore.State.Name.Idle import arcs.core.storage.util.callbackManager import arcs.core.util.Random import arcs.core.util.TaggedLog -import kotlin.coroutines.coroutineContext import kotlinx.atomicfu.AtomicRef import kotlinx.atomicfu.atomic import kotlinx.atomicfu.getAndUpdate @@ -34,6 +33,7 @@ import kotlinx.coroutines.channels.ConflatedBroadcastChannel import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.launch +import kotlin.coroutines.coroutineContext // import kotlinx.coroutines.flow.debounce // import kotlinx.coroutines.flow.filter diff --git a/java/arcs/core/storage/ReferenceModeStore.kt b/java/arcs/core/storage/ReferenceModeStore.kt index 29b87e553f1..653d3e13224 100644 --- a/java/arcs/core/storage/ReferenceModeStore.kt +++ b/java/arcs/core/storage/ReferenceModeStore.kt @@ -49,13 +49,13 @@ import arcs.core.util.Result import arcs.core.util.TaggedLog import arcs.core.util.computeNotNull import arcs.core.util.nextSafeRandomLong -import kotlin.properties.Delegates import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.TimeoutCancellationException import kotlinx.coroutines.launch import kotlinx.coroutines.withTimeout +import kotlin.properties.Delegates /** This is a convenience for the parameter type of [handleContainerMessage]. */ internal typealias ContainerProxyMessage = diff --git a/java/arcs/core/storage/driver/VolatileDriverProvider.kt b/java/arcs/core/storage/driver/VolatileDriverProvider.kt index 9d9f5f7de34..bee481f0734 100644 --- a/java/arcs/core/storage/driver/VolatileDriverProvider.kt +++ b/java/arcs/core/storage/driver/VolatileDriverProvider.kt @@ -23,10 +23,10 @@ import arcs.core.storage.keys.VolatileStorageKey import arcs.core.type.Type import arcs.core.util.TaggedLog import arcs.core.util.guardedBy -import java.lang.IllegalStateException -import kotlin.reflect.KClass import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import java.lang.IllegalStateException +import kotlin.reflect.KClass /** * [DriverProvider] that creates an instance of [VolatileDriverProvider] per arc on demand. diff --git a/java/arcs/core/storage/referencemode/Message.kt b/java/arcs/core/storage/referencemode/Message.kt index cfdef40821d..d206fea7b76 100644 --- a/java/arcs/core/storage/referencemode/Message.kt +++ b/java/arcs/core/storage/referencemode/Message.kt @@ -24,14 +24,14 @@ import arcs.core.storage.UntypedProxyMessage /** Converts a general [ProxyMessage] into a reference mode-safe [ProxyMessage]. */ fun UntypedProxyMessage.toReferenceModeMessage(): ProxyMessage { - return when (this) { - is ProxyMessage.ModelUpdate -> - ProxyMessage.ModelUpdate(model, id) - is ProxyMessage.Operations -> - ProxyMessage.Operations(operations.toReferenceModeMessageOps(), id) - is ProxyMessage.SyncRequest -> ProxyMessage.SyncRequest(id) + return when (this) { + is ProxyMessage.ModelUpdate -> + ProxyMessage.ModelUpdate(model, id) + is ProxyMessage.Operations -> + ProxyMessage.Operations(operations.toReferenceModeMessageOps(), id) + is ProxyMessage.SyncRequest -> ProxyMessage.SyncRequest(id) + } } -} @Suppress("UNCHECKED_CAST") private fun List.toReferenceModeMessageOps(): List { diff --git a/java/arcs/core/storage/util/CallbackManager.kt b/java/arcs/core/storage/util/CallbackManager.kt index c2b2031a050..5918468884e 100644 --- a/java/arcs/core/storage/util/CallbackManager.kt +++ b/java/arcs/core/storage/util/CallbackManager.kt @@ -11,9 +11,9 @@ package arcs.core.storage.util -import kotlin.random.Random import kotlinx.atomicfu.atomic import kotlinx.atomicfu.update +import kotlin.random.Random typealias Callback = suspend (T) -> Unit diff --git a/java/arcs/core/storage/util/SimpleQueue.kt b/java/arcs/core/storage/util/SimpleQueue.kt index fda3ccae082..05c49fbb4ff 100644 --- a/java/arcs/core/storage/util/SimpleQueue.kt +++ b/java/arcs/core/storage/util/SimpleQueue.kt @@ -1,11 +1,11 @@ package arcs.core.storage.util -import kotlin.coroutines.coroutineContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import kotlin.coroutines.coroutineContext /** * A very basic implementation of [OperationQueue]. It dispatches jobs on coroutines in the diff --git a/java/arcs/core/testutil/Assertions.kt b/java/arcs/core/testutil/Assertions.kt index 82ba849dfab..6caf16e3bed 100644 --- a/java/arcs/core/testutil/Assertions.kt +++ b/java/arcs/core/testutil/Assertions.kt @@ -12,9 +12,9 @@ package arcs.core.testutil import com.google.common.truth.Truth.assertThat +import org.junit.Assert.fail import kotlin.AssertionError import kotlin.reflect.KClass -import org.junit.Assert.fail /** Utility to assert that a suspending lambda throws a specific exception type. */ @Suppress("UNCHECKED_CAST") diff --git a/java/arcs/core/testutil/RunTest.kt b/java/arcs/core/testutil/RunTest.kt index cd9984d24be..9a29d276556 100644 --- a/java/arcs/core/testutil/RunTest.kt +++ b/java/arcs/core/testutil/RunTest.kt @@ -11,11 +11,11 @@ package arcs.core.testutil -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.EmptyCoroutineContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withTimeout +import kotlin.coroutines.CoroutineContext +import kotlin.coroutines.EmptyCoroutineContext /** * Alternative to [runBlocking] which always returns [Unit] (safe for JUnit tests) and enforces a diff --git a/java/arcs/core/util/Guard.kt b/java/arcs/core/util/Guard.kt index 7ebf899d93a..9b2673e19d6 100644 --- a/java/arcs/core/util/Guard.kt +++ b/java/arcs/core/util/Guard.kt @@ -10,9 +10,9 @@ */ package arcs.core.util +import kotlinx.coroutines.sync.Mutex import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty -import kotlinx.coroutines.sync.Mutex /** * Builds a [Guard] property delegate where all access/mutation to the delegated property must be diff --git a/java/arcs/core/util/Parser.kt b/java/arcs/core/util/Parser.kt index 5821c9e9004..6311c48fe55 100644 --- a/java/arcs/core/util/Parser.kt +++ b/java/arcs/core/util/Parser.kt @@ -302,19 +302,21 @@ class Optional(val parser: Parser) : Parser() { */ class PairOfParser(val left: Parser, val right: Parser) : Parser>() { override fun invoke(string: String, pos: SourcePosition): ParseResult> = - when (val outerResult = left(string, pos).map { v1, s1, e1, c1 -> - val result = right(string, e1).map { v2, _, e2, c2 -> - Success(Pair(v1, v2), s1, e2, c1 + c2) - } - when (result) { - is Success<*> -> result as Success> - is Failure -> result.consumed( - result.consumed + c1, - this@PairOfParser.name, - result - ) + when ( + val outerResult = left(string, pos).map { v1, s1, e1, c1 -> + val result = right(string, e1).map { v2, _, e2, c2 -> + Success(Pair(v1, v2), s1, e2, c1 + c2) + } + when (result) { + is Success<*> -> result as Success> + is Failure -> result.consumed( + result.consumed + c1, + this@PairOfParser.name, + result + ) + } } - }) { + ) { is Success<*> -> outerResult as Success> is Failure -> outerResult.causedBy(name) } diff --git a/java/arcs/core/util/Scheduler.kt b/java/arcs/core/util/Scheduler.kt index 42efde77d49..9d845d85708 100644 --- a/java/arcs/core/util/Scheduler.kt +++ b/java/arcs/core/util/Scheduler.kt @@ -11,8 +11,6 @@ package arcs.core.util -import kotlin.coroutines.CoroutineContext -import kotlin.math.abs import kotlinx.atomicfu.atomic import kotlinx.atomicfu.update import kotlinx.coroutines.CoroutineDispatcher @@ -32,6 +30,8 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.withTimeout +import kotlin.coroutines.CoroutineContext +import kotlin.math.abs /** * The [Scheduler] is responsible for scheduling the execution of a batch of [Task]s (known as an diff --git a/java/arcs/core/util/testutil/LogRule.kt b/java/arcs/core/util/testutil/LogRule.kt index 1d6e907124c..c48832a6aa8 100644 --- a/java/arcs/core/util/testutil/LogRule.kt +++ b/java/arcs/core/util/testutil/LogRule.kt @@ -13,13 +13,13 @@ package arcs.core.util.testutil import arcs.core.util.Log import arcs.core.util.TaggedLog +import org.junit.rules.TestRule +import org.junit.runner.Description +import org.junit.runners.model.Statement import java.io.PrintWriter import java.io.StringWriter import java.util.Locale import java.util.concurrent.CopyOnWriteArrayList -import org.junit.rules.TestRule -import org.junit.runner.Description -import org.junit.runners.model.Statement /** JUnit [TestRule] which prints wrappers around the log output from each test. */ class LogRule( diff --git a/java/arcs/jvm/storage/database/testutil/FakeDatabaseManager.kt b/java/arcs/jvm/storage/database/testutil/FakeDatabaseManager.kt index 1f1ac82bb01..65a32409e64 100644 --- a/java/arcs/jvm/storage/database/testutil/FakeDatabaseManager.kt +++ b/java/arcs/jvm/storage/database/testutil/FakeDatabaseManager.kt @@ -27,8 +27,6 @@ import arcs.core.util.guardedBy import arcs.core.util.performance.PerformanceStatistics import arcs.core.util.performance.Timer import arcs.jvm.util.JvmTime -import kotlin.coroutines.coroutineContext -import kotlin.reflect.KClass import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.flow.Flow @@ -38,6 +36,8 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import kotlin.coroutines.coroutineContext +import kotlin.reflect.KClass /** [DatabaseManager] which generates fake [Database] objects. */ open class FakeDatabaseManager : DatabaseManager { diff --git a/java/arcs/sdk/HandleUtils.kt b/java/arcs/sdk/HandleUtils.kt index 26806dcc016..272076be73c 100644 --- a/java/arcs/sdk/HandleUtils.kt +++ b/java/arcs/sdk/HandleUtils.kt @@ -239,19 +239,19 @@ fun com } fun - combineUpdates( - handle1: ReadableHandle, - handle2: ReadableHandle, - handle3: ReadableHandle, - handle4: ReadableHandle, - handle5: ReadableHandle, - handle6: ReadableHandle, - handle7: ReadableHandle, - handle8: ReadableHandle, - handle9: ReadableHandle, - handle10: ReadableHandle, - action: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) -> Unit - ) { +combineUpdates( + handle1: ReadableHandle, + handle2: ReadableHandle, + handle3: ReadableHandle, + handle4: ReadableHandle, + handle5: ReadableHandle, + handle6: ReadableHandle, + handle7: ReadableHandle, + handle8: ReadableHandle, + handle9: ReadableHandle, + handle10: ReadableHandle, + action: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) -> Unit +) { val handles = listOf( handle1, handle2, diff --git a/java/arcs/sdk/android/labs/host/AndroidHost.kt b/java/arcs/sdk/android/labs/host/AndroidHost.kt index b131a02cdb4..aebc119243d 100644 --- a/java/arcs/sdk/android/labs/host/AndroidHost.kt +++ b/java/arcs/sdk/android/labs/host/AndroidHost.kt @@ -20,9 +20,9 @@ import arcs.core.host.ParticleRegistration import arcs.core.host.SchedulerProvider import arcs.core.storage.StorageEndpointManager import arcs.jvm.util.JvmTime -import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking +import kotlin.coroutines.CoroutineContext /** * An [ArcHost] that runs on Android inside of a [Service], uses [StorageService] for storage. diff --git a/java/arcs/sdk/android/labs/host/ArcHostHelper.kt b/java/arcs/sdk/android/labs/host/ArcHostHelper.kt index 97d57a9080f..1ff53c7ac8f 100644 --- a/java/arcs/sdk/android/labs/host/ArcHostHelper.kt +++ b/java/arcs/sdk/android/labs/host/ArcHostHelper.kt @@ -35,12 +35,12 @@ import arcs.core.host.ArcStateChangeRegistration import arcs.core.host.ParticleIdentifier import arcs.core.storage.StorageKeyParser import arcs.core.util.TaggedLog -import kotlin.reflect.KClass import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.launch +import kotlin.reflect.KClass /** * Tool which can be used by [ArcHost]s to handle [Intent] based API calls, as well as diff --git a/java/arcs/sdk/android/labs/host/IntentArcHostAdapter.kt b/java/arcs/sdk/android/labs/host/IntentArcHostAdapter.kt index b59fa7f17a4..4bbe66915da 100644 --- a/java/arcs/sdk/android/labs/host/IntentArcHostAdapter.kt +++ b/java/arcs/sdk/android/labs/host/IntentArcHostAdapter.kt @@ -25,12 +25,12 @@ import arcs.core.host.ArcState import arcs.core.host.ArcStateChangeCallback import arcs.core.host.ArcStateChangeRegistration import arcs.core.host.ParticleIdentifier -import kotlin.coroutines.EmptyCoroutineContext import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.launch +import kotlin.coroutines.EmptyCoroutineContext /** * An [ArcHost] stub that translates API calls into [Intent]s directed at a [Service] using @@ -132,9 +132,11 @@ class IntentArcHostAdapter( ResultReceiverStateChangeHandler(block) ) ) { - ArcStateChangeRegistration(requireNotNull(it) { - "No callbackId supplied from addOnStateChangeCallback" - }.toString()) + ArcStateChangeRegistration( + requireNotNull(it) { + "No callbackId supplied from addOnStateChangeCallback" + }.toString() + ) } ?: throw IllegalArgumentException("Unable to register state change listener") } diff --git a/java/arcs/sdk/android/storage/service/BoundService.kt b/java/arcs/sdk/android/storage/service/BoundService.kt index 396a5b15452..f5bbcbdb97d 100644 --- a/java/arcs/sdk/android/storage/service/BoundService.kt +++ b/java/arcs/sdk/android/storage/service/BoundService.kt @@ -6,13 +6,13 @@ import android.content.Intent import android.content.ServiceConnection import android.os.IBinder import android.os.IInterface -import kotlin.coroutines.resume -import kotlin.coroutines.resumeWithException import kotlinx.atomicfu.atomic import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.suspendCancellableCoroutine +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException /** * This interface exists so that we can swap out normal Android service connection routines diff --git a/java/arcs/sdk/android/storage/service/StorageService.kt b/java/arcs/sdk/android/storage/service/StorageService.kt index 3e12131fbb1..5d6e2272887 100644 --- a/java/arcs/sdk/android/storage/service/StorageService.kt +++ b/java/arcs/sdk/android/storage/service/StorageService.kt @@ -53,12 +53,6 @@ import arcs.core.util.TaggedLog import arcs.core.util.performance.MemoryStats import arcs.core.util.performance.PerformanceStatistics import arcs.flags.BuildFlags -import java.io.FileDescriptor -import java.io.PrintWriter -import java.util.concurrent.ConcurrentHashMap -import java.util.concurrent.Executors -import java.util.concurrent.TimeUnit -import kotlin.reflect.KClass import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -69,6 +63,12 @@ import kotlinx.coroutines.cancel import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking +import java.io.FileDescriptor +import java.io.PrintWriter +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import kotlin.reflect.KClass /** * Implementation of a [Service] which manages [Store]s and exposes the ability to access them via diff --git a/java/arcs/sdk/testing/BaseTestHarness.kt b/java/arcs/sdk/testing/BaseTestHarness.kt index 7051854c589..d783b32bf41 100644 --- a/java/arcs/sdk/testing/BaseTestHarness.kt +++ b/java/arcs/sdk/testing/BaseTestHarness.kt @@ -18,7 +18,6 @@ import arcs.jvm.util.JvmTime import arcs.sdk.Handle import arcs.sdk.Particle import com.google.common.truth.Truth.assertWithMessage -import kotlin.coroutines.EmptyCoroutineContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -29,6 +28,7 @@ import kotlinx.coroutines.withTimeout import org.junit.rules.TestRule import org.junit.runner.Description import org.junit.runners.model.Statement +import kotlin.coroutines.EmptyCoroutineContext /** * A base class for code generated test harnesses for Kotlin particles. diff --git a/java/arcs/sdk/wasm/WasmJsInterop.kt b/java/arcs/sdk/wasm/WasmJsInterop.kt index 2b9c6710ae4..1954f00fdcf 100644 --- a/java/arcs/sdk/wasm/WasmJsInterop.kt +++ b/java/arcs/sdk/wasm/WasmJsInterop.kt @@ -11,8 +11,6 @@ package arcs.sdk.wasm -import kotlin.native.Retain -import kotlin.native.internal.ExportForCppRuntime import kotlinx.cinterop.ByteVar import kotlinx.cinterop.CPointed import kotlinx.cinterop.CPointer @@ -20,6 +18,8 @@ import kotlinx.cinterop.NativePtr import kotlinx.cinterop.toCPointer import kotlinx.cinterop.toKStringFromUtf8 import kotlinx.cinterop.toLong +import kotlin.native.Retain +import kotlin.native.internal.ExportForCppRuntime // Model WasmAddress as an Int typealias WasmAddress = Address diff --git a/java/arcs/tools/PlanGenerator.kt b/java/arcs/tools/PlanGenerator.kt index 920d674e8c7..d7808bbea03 100644 --- a/java/arcs/tools/PlanGenerator.kt +++ b/java/arcs/tools/PlanGenerator.kt @@ -43,18 +43,20 @@ fun FileSpec.Builder.addRecipe(recipe: Recipe): FileSpec.Builder { "annotations" to buildCollectionBlock(listOf()) ) val plan = PropertySpec.builder("${recipe.name}Plan", Plan::class) - .initializer(buildCodeBlock { - addNamed( - """ + .initializer( + buildCodeBlock { + addNamed( + """ %plan:T( particles = %particles:L, handles = %handles:L, annotations = %annotations:L ) - """.trimIndent(), - ctx - ) - }) + """.trimIndent(), + ctx + ) + } + ) .build() handles.forEach { this.addProperty(it) } @@ -90,7 +92,7 @@ fun CodeBlock.Builder.addHandle(handle: Recipe.Handle): CodeBlock.Builder = with type = %type:L, annotations = %annotations:L ) - """.trimIndent(), + """.trimIndent(), ctx ) } @@ -144,7 +146,7 @@ fun CodeBlock.Builder.addSchema(schema: Schema): CodeBlock.Builder { fields = %fields:L, hash = %hash:S ) - """.trimIndent(), + """.trimIndent(), ctx ) return this @@ -170,7 +172,7 @@ fun CodeBlock.Builder.addSchemaFields(fields: SchemaFields): CodeBlock.Builder { singletons = %singletons:L, collections = %collections:L ) - """.trimIndent(), + """.trimIndent(), ctx ) return this diff --git a/java/arcs/tools/RunDFAMain.kt b/java/arcs/tools/RunDFAMain.kt index 04f3c17978d..3b9571c483e 100644 --- a/java/arcs/tools/RunDFAMain.kt +++ b/java/arcs/tools/RunDFAMain.kt @@ -20,7 +20,7 @@ fun main(args: Array) { """ Usage: SIGH_CMD=/path/to/sigh run_dfa ... - """.trimIndent() + """.trimIndent() ) return } diff --git a/javatests/arcs/android/common/resurrection/ResurrectorServiceTest.kt b/javatests/arcs/android/common/resurrection/ResurrectorServiceTest.kt index 1a5d126858c..38fce1a41b7 100644 --- a/javatests/arcs/android/common/resurrection/ResurrectorServiceTest.kt +++ b/javatests/arcs/android/common/resurrection/ResurrectorServiceTest.kt @@ -22,8 +22,6 @@ import arcs.android.common.resurrection.ResurrectionRequest.Companion.EXTRA_RESU import arcs.core.storage.StorageKeyParser import arcs.core.storage.keys.RamDiskStorageKey import com.google.common.truth.Truth.assertThat -import java.io.PrintWriter -import java.io.StringWriter import kotlinx.coroutines.runBlocking import org.junit.Before import org.junit.Test @@ -31,6 +29,8 @@ import org.junit.runner.RunWith import org.robolectric.Robolectric import org.robolectric.Shadows.shadowOf import org.robolectric.shadows.ShadowService +import java.io.PrintWriter +import java.io.StringWriter @RunWith(AndroidJUnit4::class) class ResurrectorServiceTest { @@ -83,7 +83,7 @@ class ResurrectorServiceTest { ] ] - """.trimIndent() + """.trimIndent() ) } diff --git a/javatests/arcs/android/crdt/CrdtExceptionProtoTest.kt b/javatests/arcs/android/crdt/CrdtExceptionProtoTest.kt index 292628bac23..48da3533d16 100644 --- a/javatests/arcs/android/crdt/CrdtExceptionProtoTest.kt +++ b/javatests/arcs/android/crdt/CrdtExceptionProtoTest.kt @@ -14,9 +14,9 @@ package arcs.android.crdt import androidx.test.ext.junit.runners.AndroidJUnit4 import arcs.core.crdt.CrdtException import com.google.common.truth.Truth.assertThat -import java.lang.IllegalArgumentException import org.junit.Test import org.junit.runner.RunWith +import java.lang.IllegalArgumentException /** Tests for [CrdtExceptionProto]. */ @RunWith(AndroidJUnit4::class) diff --git a/javatests/arcs/android/crdt/CrdtSetProtoTest.kt b/javatests/arcs/android/crdt/CrdtSetProtoTest.kt index aa22ad4d91f..0d428107c0f 100644 --- a/javatests/arcs/android/crdt/CrdtSetProtoTest.kt +++ b/javatests/arcs/android/crdt/CrdtSetProtoTest.kt @@ -48,7 +48,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/ParcelableCrdtSingletonTest.kt b/javatests/arcs/android/crdt/ParcelableCrdtSingletonTest.kt index 4525b459c04..ffe00fcf3b4 100644 --- a/javatests/arcs/android/crdt/ParcelableCrdtSingletonTest.kt +++ b/javatests/arcs/android/crdt/ParcelableCrdtSingletonTest.kt @@ -31,7 +31,8 @@ class ParcelableCrdtSingletonTest { @Test fun data_parcelableRoundTrip_works() { val data = CrdtSingleton.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/devtools/DevToolsStarterTest.kt b/javatests/arcs/android/devtools/DevToolsStarterTest.kt index 3b6c05d6dc6..64146359c9d 100644 --- a/javatests/arcs/android/devtools/DevToolsStarterTest.kt +++ b/javatests/arcs/android/devtools/DevToolsStarterTest.kt @@ -20,7 +20,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import arcs.android.devtools.DevToolsService.Companion.STORAGE_CLASS import arcs.sdk.android.storage.service.StorageService import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import kotlinx.coroutines.runBlocking import org.junit.Before import org.junit.Test @@ -28,6 +27,7 @@ import org.junit.runner.RunWith import org.robolectric.Robolectric import org.robolectric.Shadows.shadowOf import org.robolectric.shadows.ShadowService +import kotlin.test.assertFailsWith @RunWith(AndroidJUnit4::class) class DevToolsStarterTest { @@ -59,19 +59,19 @@ class DevToolsStarterTest { @Test fun start_withStorageService_appliesBundle() = lifecycle { _, serviceShadow -> - val devToolsStarter = DevToolsStarter(context) - val bundle = Bundle().apply { - putSerializable(STORAGE_CLASS, MySecondStorageService::class.java) - } - devToolsIntent.putExtras(bundle) + val devToolsStarter = DevToolsStarter(context) + val bundle = Bundle().apply { + putSerializable(STORAGE_CLASS, MySecondStorageService::class.java) + } + devToolsIntent.putExtras(bundle) - devToolsStarter.start(MySecondStorageService::class.java) - val actualIntent = serviceShadow.nextStartedService + devToolsStarter.start(MySecondStorageService::class.java) + val actualIntent = serviceShadow.nextStartedService - assertThat(actualIntent.filterEquals(devToolsIntent)).isTrue() - assertThat(actualIntent.extras?.getSerializable(STORAGE_CLASS)) - .isEqualTo(devToolsIntent.extras?.getSerializable(STORAGE_CLASS)) - } + assertThat(actualIntent.filterEquals(devToolsIntent)).isTrue() + assertThat(actualIntent.extras?.getSerializable(STORAGE_CLASS)) + .isEqualTo(devToolsIntent.extras?.getSerializable(STORAGE_CLASS)) + } @Test fun start_withBadStorageService_throwsError() = lifecycle { _, _ -> diff --git a/javatests/arcs/android/host/AndroidEntityHandleManagerTest.kt b/javatests/arcs/android/host/AndroidEntityHandleManagerTest.kt index 7aecc1339a1..b903c0b0075 100644 --- a/javatests/arcs/android/host/AndroidEntityHandleManagerTest.kt +++ b/javatests/arcs/android/host/AndroidEntityHandleManagerTest.kt @@ -36,9 +36,6 @@ import arcs.jvm.util.testutil.FakeTime import arcs.sdk.android.storage.AndroidStorageServiceEndpointManager import arcs.sdk.android.storage.service.testutil.TestBindHelper import com.google.common.truth.Truth.assertThat -import kotlin.coroutines.resume -import kotlin.coroutines.suspendCoroutine -import kotlin.test.assertFailsWith import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -49,6 +46,9 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import kotlin.coroutines.resume +import kotlin.coroutines.suspendCoroutine +import kotlin.test.assertFailsWith // Generated from ./javatests/arcs/android/host/test.arcs private typealias Person = AbstractTestParticle.TestParticleInternal1 diff --git a/javatests/arcs/android/host/ArcHostHelperTest.kt b/javatests/arcs/android/host/ArcHostHelperTest.kt index 45cfd0e084a..e4f0b623574 100644 --- a/javatests/arcs/android/host/ArcHostHelperTest.kt +++ b/javatests/arcs/android/host/ArcHostHelperTest.kt @@ -49,8 +49,6 @@ import arcs.sdk.android.labs.host.createUnpauseArcHostIntent import arcs.sdk.android.labs.host.toComponentName import arcs.sdk.android.storage.ResurrectionHelper import com.google.common.truth.Truth.assertThat -import kotlin.coroutines.resume -import kotlin.coroutines.suspendCoroutine import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import kotlinx.coroutines.sync.Mutex @@ -60,6 +58,8 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.robolectric.Robolectric +import kotlin.coroutines.resume +import kotlin.coroutines.suspendCoroutine @RunWith(AndroidJUnit4::class) @OptIn(ExperimentalCoroutinesApi::class) diff --git a/javatests/arcs/android/host/parcelables/ParcelableAnnotationParamTest.kt b/javatests/arcs/android/host/parcelables/ParcelableAnnotationParamTest.kt index 6495278b67d..47c28c71ee3 100644 --- a/javatests/arcs/android/host/parcelables/ParcelableAnnotationParamTest.kt +++ b/javatests/arcs/android/host/parcelables/ParcelableAnnotationParamTest.kt @@ -15,9 +15,9 @@ import android.os.Parcel import androidx.test.ext.junit.runners.AndroidJUnit4 import arcs.core.data.AnnotationParam import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith +import kotlin.test.assertFailsWith /** Tests for [ParcelableAnnotationParam]'s classes. */ @RunWith(AndroidJUnit4::class) diff --git a/javatests/arcs/android/host/parcelables/ParcelableAnnotationTest.kt b/javatests/arcs/android/host/parcelables/ParcelableAnnotationTest.kt index 046514c2d2c..bc85debb805 100644 --- a/javatests/arcs/android/host/parcelables/ParcelableAnnotationTest.kt +++ b/javatests/arcs/android/host/parcelables/ParcelableAnnotationTest.kt @@ -16,9 +16,9 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import arcs.core.data.Annotation import arcs.core.data.AnnotationParam import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith +import kotlin.test.assertFailsWith /** Tests for [ParcelableAnnotation]'s classes. */ @RunWith(AndroidJUnit4::class) diff --git a/javatests/arcs/android/host/parcelables/ParcelableHandleConnectionTest.kt b/javatests/arcs/android/host/parcelables/ParcelableHandleConnectionTest.kt index 2b1a3e37b82..40a455ad86a 100644 --- a/javatests/arcs/android/host/parcelables/ParcelableHandleConnectionTest.kt +++ b/javatests/arcs/android/host/parcelables/ParcelableHandleConnectionTest.kt @@ -27,11 +27,11 @@ import arcs.core.data.expression.asExpr import arcs.core.storage.StorageKeyParser import arcs.core.storage.keys.VolatileStorageKey import com.google.common.truth.Truth.assertThat -import java.lang.IllegalArgumentException -import kotlin.test.assertFailsWith import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import java.lang.IllegalArgumentException +import kotlin.test.assertFailsWith /** Tests for [ParcelableHandleConnection]'s classes. */ @RunWith(AndroidJUnit4::class) diff --git a/javatests/arcs/android/host/parcelables/ParcelableHandleTest.kt b/javatests/arcs/android/host/parcelables/ParcelableHandleTest.kt index 8c2b2d37ace..0a9c48be4e3 100644 --- a/javatests/arcs/android/host/parcelables/ParcelableHandleTest.kt +++ b/javatests/arcs/android/host/parcelables/ParcelableHandleTest.kt @@ -24,10 +24,10 @@ import arcs.core.data.SchemaName import arcs.core.storage.StorageKeyParser import arcs.core.storage.keys.VolatileStorageKey import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import kotlin.test.assertFailsWith /** Tests for [ParcelableHandle]'s classes. */ @RunWith(AndroidJUnit4::class) diff --git a/javatests/arcs/android/host/parcelables/ParcelableParticleIdentifierTest.kt b/javatests/arcs/android/host/parcelables/ParcelableParticleIdentifierTest.kt index 56d5e4097c1..1fe43d1fc6e 100644 --- a/javatests/arcs/android/host/parcelables/ParcelableParticleIdentifierTest.kt +++ b/javatests/arcs/android/host/parcelables/ParcelableParticleIdentifierTest.kt @@ -18,9 +18,9 @@ import arcs.core.host.toParticleIdentifier import arcs.sdk.HandleHolderBase import arcs.sdk.Particle import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith +import kotlin.test.assertFailsWith /** Tests for [ParcelableParticleIdentifier]'s classes. */ @RunWith(AndroidJUnit4::class) diff --git a/javatests/arcs/android/host/parcelables/ParcelableParticleTest.kt b/javatests/arcs/android/host/parcelables/ParcelableParticleTest.kt index 1c38134f9af..a8fbc3433aa 100644 --- a/javatests/arcs/android/host/parcelables/ParcelableParticleTest.kt +++ b/javatests/arcs/android/host/parcelables/ParcelableParticleTest.kt @@ -26,10 +26,10 @@ import arcs.core.storage.keys.RamDiskStorageKey import arcs.core.storage.keys.VolatileStorageKey import arcs.core.storage.referencemode.ReferenceModeStorageKey import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import kotlin.test.assertFailsWith /** Tests for [ParcelableParticle]'s classes. */ @RunWith(AndroidJUnit4::class) diff --git a/javatests/arcs/android/host/parcelables/ParcelablePlanTest.kt b/javatests/arcs/android/host/parcelables/ParcelablePlanTest.kt index e55b8b8183b..3c69852266d 100644 --- a/javatests/arcs/android/host/parcelables/ParcelablePlanTest.kt +++ b/javatests/arcs/android/host/parcelables/ParcelablePlanTest.kt @@ -25,10 +25,10 @@ import arcs.core.data.SchemaName import arcs.core.storage.StorageKeyParser import arcs.core.storage.keys.VolatileStorageKey import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import kotlin.test.assertFailsWith /** Tests for [ParcelablePlan]'s classes. */ @RunWith(AndroidJUnit4::class) diff --git a/javatests/arcs/android/integration/IntegrationEnvironment.kt b/javatests/arcs/android/integration/IntegrationEnvironment.kt index 7be9cab26bb..1b8fd083a38 100644 --- a/javatests/arcs/android/integration/IntegrationEnvironment.kt +++ b/javatests/arcs/android/integration/IntegrationEnvironment.kt @@ -28,9 +28,6 @@ import arcs.jvm.util.JvmTime import arcs.sdk.Particle import arcs.sdk.android.storage.AndroidStorageServiceEndpointManager import arcs.sdk.android.storage.service.testutil.TestBindHelper -import kotlin.coroutines.CoroutineContext -import kotlin.time.Duration -import kotlin.time.hours import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -43,6 +40,9 @@ import org.junit.rules.TestRule import org.junit.runner.Description import org.junit.runners.model.Statement import org.robolectric.shadows.ShadowSystemClock +import kotlin.coroutines.CoroutineContext +import kotlin.time.Duration +import kotlin.time.hours /** * A JUnit rule setting up an Arcs environment for integration tests. diff --git a/javatests/arcs/android/integration/ttl/TtlTest.kt b/javatests/arcs/android/integration/ttl/TtlTest.kt index 4a3f41a5fbc..0f6878dc4af 100644 --- a/javatests/arcs/android/integration/ttl/TtlTest.kt +++ b/javatests/arcs/android/integration/ttl/TtlTest.kt @@ -6,7 +6,6 @@ import arcs.core.allocator.Arc import arcs.core.host.toRegistration import arcs.core.util.testutil.LogRule import com.google.common.truth.Truth.assertThat -import kotlin.time.minutes import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking @@ -14,6 +13,7 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.robolectric.annotation.Config +import kotlin.time.minutes @OptIn(ExperimentalCoroutinesApi::class, kotlin.time.ExperimentalTime::class) @RunWith(AndroidJUnit4::class) diff --git a/javatests/arcs/android/storage/ReferenceModeStoreDatabaseImplIntegrationTest.kt b/javatests/arcs/android/storage/ReferenceModeStoreDatabaseImplIntegrationTest.kt index 4b6dc8983ef..fe36415990d 100644 --- a/javatests/arcs/android/storage/ReferenceModeStoreDatabaseImplIntegrationTest.kt +++ b/javatests/arcs/android/storage/ReferenceModeStoreDatabaseImplIntegrationTest.kt @@ -48,7 +48,6 @@ import arcs.core.storage.testutil.testWriteBackProvider import arcs.core.storage.toReference import arcs.core.util.testutil.LogRule import com.google.common.truth.Truth.assertThat -import kotlin.coroutines.coroutineContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.Job @@ -59,6 +58,7 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import kotlin.coroutines.coroutineContext @Suppress("UNCHECKED_CAST", "EXPERIMENTAL_IS_NOT_ENABLED") @OptIn(ExperimentalCoroutinesApi::class) diff --git a/javatests/arcs/android/storage/database/AndroidSqliteDatabaseManagerTest.kt b/javatests/arcs/android/storage/database/AndroidSqliteDatabaseManagerTest.kt index ed02c617af5..4004b1ae9e7 100644 --- a/javatests/arcs/android/storage/database/AndroidSqliteDatabaseManagerTest.kt +++ b/javatests/arcs/android/storage/database/AndroidSqliteDatabaseManagerTest.kt @@ -25,7 +25,6 @@ import arcs.core.storage.database.DatabaseData import arcs.core.storage.database.DatabaseManager import arcs.core.storage.testutil.DummyStorageKey import com.google.common.truth.Truth.assertThat -import java.util.Random import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.async import kotlinx.coroutines.delay @@ -33,6 +32,7 @@ import kotlinx.coroutines.test.runBlockingTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import java.util.Random @OptIn(ExperimentalCoroutinesApi::class) @RunWith(AndroidJUnit4::class) diff --git a/javatests/arcs/android/storage/database/DatabaseImplTest.kt b/javatests/arcs/android/storage/database/DatabaseImplTest.kt index 8ecfa7fb08f..79c03aa7cb6 100644 --- a/javatests/arcs/android/storage/database/DatabaseImplTest.kt +++ b/javatests/arcs/android/storage/database/DatabaseImplTest.kt @@ -45,7 +45,6 @@ import arcs.core.util.guardedBy import arcs.jvm.util.JvmTime import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertWithMessage -import kotlin.test.assertFailsWith import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock @@ -55,6 +54,7 @@ import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import kotlin.test.assertFailsWith @OptIn(ExperimentalCoroutinesApi::class) @RunWith(AndroidJUnit4::class) diff --git a/javatests/arcs/android/storage/service/BulkDeletesIntegrationTest.kt b/javatests/arcs/android/storage/service/BulkDeletesIntegrationTest.kt index 1f6d6e08d6f..b7e0f3f9a14 100644 --- a/javatests/arcs/android/storage/service/BulkDeletesIntegrationTest.kt +++ b/javatests/arcs/android/storage/service/BulkDeletesIntegrationTest.kt @@ -38,13 +38,13 @@ import arcs.core.testutil.handles.dispatchStore import arcs.core.util.testutil.LogRule import arcs.jvm.util.testutil.FakeTime import com.google.common.truth.Truth.assertThat -import kotlin.coroutines.EmptyCoroutineContext import kotlinx.coroutines.runBlocking import org.junit.After import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import kotlin.coroutines.EmptyCoroutineContext /** Integration tests for database bulk deletes. */ @Suppress("UNCHECKED_CAST", "EXPERIMENTAL_API_USAGE") diff --git a/javatests/arcs/android/storage/service/MutexOperationQueueTest.kt b/javatests/arcs/android/storage/service/MutexOperationQueueTest.kt index 4d13c2018b3..af308c9507f 100644 --- a/javatests/arcs/android/storage/service/MutexOperationQueueTest.kt +++ b/javatests/arcs/android/storage/service/MutexOperationQueueTest.kt @@ -1,7 +1,6 @@ package arcs.android.storage.service import com.google.common.truth.Truth.assertThat -import java.util.Random import kotlinx.atomicfu.atomic import kotlinx.atomicfu.update import kotlinx.coroutines.CompletableDeferred @@ -14,6 +13,7 @@ import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.util.Random @RunWith(JUnit4::class) class MutexOperationQueueTest { diff --git a/javatests/arcs/android/storage/service/MuxedStorageChannelImplTest.kt b/javatests/arcs/android/storage/service/MuxedStorageChannelImplTest.kt index f3af86e3ff4..7bef38dd7c2 100644 --- a/javatests/arcs/android/storage/service/MuxedStorageChannelImplTest.kt +++ b/javatests/arcs/android/storage/service/MuxedStorageChannelImplTest.kt @@ -18,7 +18,6 @@ import com.google.common.truth.Truth.assertThat import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.verify -import kotlin.test.assertFailsWith import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.Job @@ -27,6 +26,7 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import kotlin.test.assertFailsWith @RunWith(AndroidJUnit4::class) @OptIn(ExperimentalCoroutinesApi::class) diff --git a/javatests/arcs/android/storage/service/StorageChannelImplTest.kt b/javatests/arcs/android/storage/service/StorageChannelImplTest.kt index d5891e5eef7..61f13366ed9 100644 --- a/javatests/arcs/android/storage/service/StorageChannelImplTest.kt +++ b/javatests/arcs/android/storage/service/StorageChannelImplTest.kt @@ -33,7 +33,6 @@ import com.google.common.truth.Truth.assertThat import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.verify -import kotlin.test.assertFailsWith import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.Job @@ -42,6 +41,7 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import kotlin.test.assertFailsWith @RunWith(AndroidJUnit4::class) @OptIn(ExperimentalCoroutinesApi::class) diff --git a/javatests/arcs/android/storage/service/StorageServiceManagerTest.kt b/javatests/arcs/android/storage/service/StorageServiceManagerTest.kt index b2a1acd3c8a..ac69b54e765 100644 --- a/javatests/arcs/android/storage/service/StorageServiceManagerTest.kt +++ b/javatests/arcs/android/storage/service/StorageServiceManagerTest.kt @@ -47,7 +47,6 @@ import arcs.core.testutil.handles.dispatchStore import arcs.core.util.testutil.LogRule import arcs.jvm.util.testutil.FakeTime import com.google.common.truth.Truth.assertThat -import java.util.concurrent.ConcurrentHashMap import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking @@ -57,6 +56,7 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import java.util.concurrent.ConcurrentHashMap /** Tests for [StorageServiceManager]. */ @Suppress("UNCHECKED_CAST", "EXPERIMENTAL_API_USAGE") diff --git a/javatests/arcs/android/storage/service/StorageServiceNgImplTest.kt b/javatests/arcs/android/storage/service/StorageServiceNgImplTest.kt index 4000e1e6081..1010082ef71 100644 --- a/javatests/arcs/android/storage/service/StorageServiceNgImplTest.kt +++ b/javatests/arcs/android/storage/service/StorageServiceNgImplTest.kt @@ -29,7 +29,6 @@ import arcs.flags.BuildFlagDisabledError import arcs.flags.BuildFlags import arcs.flags.testing.BuildFlagsRule import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.TestCoroutineScope import kotlinx.coroutines.test.runBlockingTest @@ -38,6 +37,7 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import kotlin.test.assertFailsWith @RunWith(AndroidJUnit4::class) @OptIn(ExperimentalCoroutinesApi::class) diff --git a/javatests/arcs/android/systemhealth/testapp/PerformanceStorageService.kt b/javatests/arcs/android/systemhealth/testapp/PerformanceStorageService.kt index 5a9a723a760..eacb167b05e 100644 --- a/javatests/arcs/android/systemhealth/testapp/PerformanceStorageService.kt +++ b/javatests/arcs/android/systemhealth/testapp/PerformanceStorageService.kt @@ -1,12 +1,12 @@ package arcs.android.systemhealth.testapp -import arcs.android.systemhealth.testapp.Dispatchers as ArcsDispatchers -import arcs.android.systemhealth.testapp.Executors as ArcsExecutors import arcs.sdk.android.storage.service.StorageService import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.asCoroutineDispatcher +import arcs.android.systemhealth.testapp.Dispatchers as ArcsDispatchers +import arcs.android.systemhealth.testapp.Executors as ArcsExecutors /** * Arcs system-health-test storage service designed for performance tests. diff --git a/javatests/arcs/android/systemhealth/testapp/StabilityStorageService.kt b/javatests/arcs/android/systemhealth/testapp/StabilityStorageService.kt index 4faeb27c23d..4c8d60c6889 100644 --- a/javatests/arcs/android/systemhealth/testapp/StabilityStorageService.kt +++ b/javatests/arcs/android/systemhealth/testapp/StabilityStorageService.kt @@ -2,10 +2,7 @@ package arcs.android.systemhealth.testapp import android.content.Context import android.content.Intent -import arcs.android.systemhealth.testapp.Dispatchers as ArcsDispatchers -import arcs.android.systemhealth.testapp.Executors as ArcsExecutors import arcs.sdk.android.storage.service.StorageService -import kotlin.random.Random import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.SupervisorJob @@ -13,6 +10,9 @@ import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.cancel import kotlinx.coroutines.delay import kotlinx.coroutines.launch +import kotlin.random.Random +import arcs.android.systemhealth.testapp.Dispatchers as ArcsDispatchers +import arcs.android.systemhealth.testapp.Executors as ArcsExecutors /** * Arcs system-health-test storage service. Supports crashing itself when needed. diff --git a/javatests/arcs/android/systemhealth/testapp/StorageCore.kt b/javatests/arcs/android/systemhealth/testapp/StorageCore.kt index c699e24ebc5..ceec2ca4673 100644 --- a/javatests/arcs/android/systemhealth/testapp/StorageCore.kt +++ b/javatests/arcs/android/systemhealth/testapp/StorageCore.kt @@ -15,7 +15,6 @@ import android.content.Context import android.content.Intent import android.os.Debug import android.os.Trace -import arcs.android.systemhealth.testapp.Dispatchers as ArcsDispatchers import arcs.core.data.CollectionType import arcs.core.data.EntityType import arcs.core.data.HandleMode @@ -38,6 +37,20 @@ import arcs.sdk.WriteCollectionHandle import arcs.sdk.android.storage.AndroidStorageServiceEndpointManager import arcs.sdk.android.storage.service.DefaultBindHelper import com.google.common.math.StatsAccumulator +import kotlinx.atomicfu.atomic +import kotlinx.atomicfu.update +import kotlinx.coroutines.CompletableDeferred +import kotlinx.coroutines.CoroutineExceptionHandler +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.asCoroutineDispatcher +import kotlinx.coroutines.cancel +import kotlinx.coroutines.delay +import kotlinx.coroutines.joinAll +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.withContext import java.text.DateFormat import java.text.DecimalFormat import java.util.concurrent.ExecutorService @@ -73,20 +86,7 @@ import kotlin.run import kotlin.system.measureTimeMillis import kotlin.takeIf import kotlin.toString -import kotlinx.atomicfu.atomic -import kotlinx.atomicfu.update -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.CoroutineExceptionHandler -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.asCoroutineDispatcher -import kotlinx.coroutines.cancel -import kotlinx.coroutines.delay -import kotlinx.coroutines.joinAll -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.withContext +import arcs.android.systemhealth.testapp.Dispatchers as ArcsDispatchers private typealias HandleType = SystemHealthEnums.HandleType private typealias Function = SystemHealthEnums.Function diff --git a/javatests/arcs/android/systemhealth/testapp/TestApplication.kt b/javatests/arcs/android/systemhealth/testapp/TestApplication.kt index 0fa7be650f4..dc49a83185b 100644 --- a/javatests/arcs/android/systemhealth/testapp/TestApplication.kt +++ b/javatests/arcs/android/systemhealth/testapp/TestApplication.kt @@ -20,10 +20,10 @@ import arcs.android.util.initLogForAndroid import arcs.core.data.SchemaRegistry import arcs.core.storage.api.DriverAndKeyConfigurator import arcs.core.storage.driver.RamDisk +import kotlinx.coroutines.runBlocking import java.util.concurrent.SynchronousQueue import java.util.concurrent.ThreadPoolExecutor import java.util.concurrent.TimeUnit -import kotlinx.coroutines.runBlocking /** Application class for Arcs System Health measures. */ open class TestApplication : Application(), Configuration.Provider { diff --git a/javatests/arcs/android/systemhealth/testapp/TestSchedulerProvider.kt b/javatests/arcs/android/systemhealth/testapp/TestSchedulerProvider.kt index e21890d3070..50cc2845698 100644 --- a/javatests/arcs/android/systemhealth/testapp/TestSchedulerProvider.kt +++ b/javatests/arcs/android/systemhealth/testapp/TestSchedulerProvider.kt @@ -11,21 +11,21 @@ package arcs.android.systemhealth.testapp -import arcs.android.systemhealth.testapp.Executors as ArcsExecutors import arcs.core.host.SchedulerProvider import arcs.core.util.Scheduler import arcs.core.util.TaggedLog import arcs.jvm.util.JvmTime -import java.util.concurrent.ConcurrentHashMap -import java.util.concurrent.ExecutorService -import java.util.concurrent.Executors -import java.util.concurrent.TimeUnit -import kotlin.coroutines.CoroutineContext import kotlinx.atomicfu.atomic import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.Job import kotlinx.coroutines.asCoroutineDispatcher +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import kotlin.coroutines.CoroutineContext +import arcs.android.systemhealth.testapp.Executors as ArcsExecutors /** * A [JvmSchedulerProvider] variant supports evaluations on diverse threading @@ -52,22 +52,24 @@ class TestSchedulerProvider( dispatchers[providedSoFar.getAndIncrement() % maxThreadCount] } else { val threadIndex = providedSoFar.getAndIncrement() - (ArcsExecutors.schedulers?.next() ?: Executors - .newSingleThreadExecutor { - val thread = threads[threadIndex % maxThreadCount] - if (thread != null && thread.isAlive) return@newSingleThreadExecutor thread + ( + ArcsExecutors.schedulers?.next() ?: Executors + .newSingleThreadExecutor { + val thread = threads[threadIndex % maxThreadCount] + if (thread != null && thread.isAlive) return@newSingleThreadExecutor thread - if (thread?.isAlive == false) log.info { - "Creating a new thread (index: ${threadIndex % maxThreadCount}) because " + - "a previously-created one had died." - } + if (thread?.isAlive == false) log.info { + "Creating a new thread (index: ${threadIndex % maxThreadCount}) because " + + "a previously-created one had died." + } - Thread(it).apply { - priority = threadPriority - name = "Scheduler-Thread#${threadIndex % maxThreadCount}" - threads[threadIndex % maxThreadCount] = this + Thread(it).apply { + priority = threadPriority + name = "Scheduler-Thread#${threadIndex % maxThreadCount}" + threads[threadIndex % maxThreadCount] = this + } } - }) + ) .also { executors.add(it) } .asCoroutineDispatcher() .also { dispatchers.add(it) } diff --git a/javatests/arcs/core/allocator/AllocatorTestBase.kt b/javatests/arcs/core/allocator/AllocatorTestBase.kt index 3fe2005b740..4dea27f411f 100644 --- a/javatests/arcs/core/allocator/AllocatorTestBase.kt +++ b/javatests/arcs/core/allocator/AllocatorTestBase.kt @@ -37,7 +37,6 @@ import arcs.core.util.traverse import arcs.jvm.host.ExplicitHostRegistry import arcs.jvm.util.testutil.FakeTime import com.google.common.truth.Truth.assertThat -import kotlin.coroutines.EmptyCoroutineContext import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -48,6 +47,7 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.coroutines.EmptyCoroutineContext @RunWith(JUnit4::class) @OptIn(ExperimentalCoroutinesApi::class) diff --git a/javatests/arcs/core/analysis/AccessPathLabelsTest.kt b/javatests/arcs/core/analysis/AccessPathLabelsTest.kt index 579b1fcb04d..6c6be50bbb9 100644 --- a/javatests/arcs/core/analysis/AccessPathLabelsTest.kt +++ b/javatests/arcs/core/analysis/AccessPathLabelsTest.kt @@ -5,10 +5,10 @@ import arcs.core.data.HandleConnectionSpec import arcs.core.data.HandleMode import arcs.core.data.TypeVariable import com.google.common.truth.Truth.assertThat -import java.util.BitSet import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.util.BitSet @RunWith(JUnit4::class) class AccessPathLabelsTest { diff --git a/javatests/arcs/core/analysis/EntityTypeOperationsTest.kt b/javatests/arcs/core/analysis/EntityTypeOperationsTest.kt index 524797c72a5..7b920aaa962 100644 --- a/javatests/arcs/core/analysis/EntityTypeOperationsTest.kt +++ b/javatests/arcs/core/analysis/EntityTypeOperationsTest.kt @@ -6,10 +6,10 @@ import arcs.core.data.Schema import arcs.core.data.SchemaFields import arcs.core.data.SchemaName import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class EntityTypeOperationsTest { diff --git a/javatests/arcs/core/analysis/InformationFlowLabelsTest.kt b/javatests/arcs/core/analysis/InformationFlowLabelsTest.kt index e6b56da4735..7a29ec61a10 100644 --- a/javatests/arcs/core/analysis/InformationFlowLabelsTest.kt +++ b/javatests/arcs/core/analysis/InformationFlowLabelsTest.kt @@ -1,10 +1,10 @@ package arcs.core.analysis import com.google.common.truth.Truth.assertThat -import java.util.BitSet import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.util.BitSet @RunWith(JUnit4::class) class InformationFlowLabelsTest { diff --git a/javatests/arcs/core/analysis/InformationFlowTest.kt b/javatests/arcs/core/analysis/InformationFlowTest.kt index dd513faac42..c68f8312f3d 100644 --- a/javatests/arcs/core/analysis/InformationFlowTest.kt +++ b/javatests/arcs/core/analysis/InformationFlowTest.kt @@ -6,10 +6,10 @@ import arcs.core.data.proto.decodeRecipes import arcs.core.testutil.protoloader.loadManifestBinaryProto import arcs.repoutils.runfilesDir import com.google.common.truth.Truth.assertWithMessage -import java.io.File import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.io.File @RunWith(JUnit4::class) class InformationFlowTest { diff --git a/javatests/arcs/core/analysis/PolicyVerifierTest.kt b/javatests/arcs/core/analysis/PolicyVerifierTest.kt index fd812094194..56bc40de49e 100644 --- a/javatests/arcs/core/analysis/PolicyVerifierTest.kt +++ b/javatests/arcs/core/analysis/PolicyVerifierTest.kt @@ -5,10 +5,10 @@ import arcs.core.policy.PolicyViolation import arcs.core.policy.proto.decode import arcs.core.testutil.protoloader.loadManifestBinaryProto import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class PolicyVerifierTest { diff --git a/javatests/arcs/core/analysis/PredicateUtilsTest.kt b/javatests/arcs/core/analysis/PredicateUtilsTest.kt index a9e9030c1a4..9d235aef4f4 100644 --- a/javatests/arcs/core/analysis/PredicateUtilsTest.kt +++ b/javatests/arcs/core/analysis/PredicateUtilsTest.kt @@ -3,10 +3,10 @@ package arcs.core.analysis import arcs.core.data.InformationFlowLabel import arcs.core.data.InformationFlowLabel.Predicate import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class PredicateUtilsTest { diff --git a/javatests/arcs/core/crdt/CrdtEntityTest.kt b/javatests/arcs/core/crdt/CrdtEntityTest.kt index b6093300e29..8c842121850 100644 --- a/javatests/arcs/core/crdt/CrdtEntityTest.kt +++ b/javatests/arcs/core/crdt/CrdtEntityTest.kt @@ -16,13 +16,13 @@ import arcs.core.crdt.CrdtEntity.Operation.ClearAll import arcs.core.crdt.CrdtEntity.Operation.ClearSingleton import arcs.core.crdt.CrdtEntity.Operation.RemoveFromSet import arcs.core.crdt.CrdtEntity.Operation.SetSingleton -import arcs.core.crdt.CrdtEntity.ReferenceImpl as Reference import arcs.core.data.RawEntity import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith +import arcs.core.crdt.CrdtEntity.ReferenceImpl as Reference /** Tests for [CrdtEntity]. */ @RunWith(JUnit4::class) @@ -260,7 +260,8 @@ class CrdtEntityTest { @Test fun failsWhen_singletonOperations_areProvidedTo_collectionFields() { val entity = CrdtEntity( - VersionMap(), RawEntity( + VersionMap(), + RawEntity( singletonFields = setOf(), collectionFields = setOf("things") ) @@ -297,7 +298,8 @@ class CrdtEntityTest { expiration: Long = RawEntity.UNINITIALIZED_TIMESTAMP ) = CrdtEntity( - VersionMap(), RawEntity( + VersionMap(), + RawEntity( id = "an-id", singletons = mapOf(), collections = mapOf(), diff --git a/javatests/arcs/core/crdt/CrdtExceptionTest.kt b/javatests/arcs/core/crdt/CrdtExceptionTest.kt index 2aeba5e2f93..64bd11a6cfb 100644 --- a/javatests/arcs/core/crdt/CrdtExceptionTest.kt +++ b/javatests/arcs/core/crdt/CrdtExceptionTest.kt @@ -1,10 +1,10 @@ package arcs.core.crdt import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class CrdtExceptionTest { diff --git a/javatests/arcs/core/data/CapabilitiesTest.kt b/javatests/arcs/core/data/CapabilitiesTest.kt index 571f89735c6..2afefcae440 100644 --- a/javatests/arcs/core/data/CapabilitiesTest.kt +++ b/javatests/arcs/core/data/CapabilitiesTest.kt @@ -15,10 +15,10 @@ import arcs.core.data.Capability.Encryption import arcs.core.data.Capability.Persistence import arcs.core.data.Capability.Ttl import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class CapabilitiesTest { diff --git a/javatests/arcs/core/data/CapabilityTest.kt b/javatests/arcs/core/data/CapabilityTest.kt index 0a88b9d2b5f..595a8e5d567 100644 --- a/javatests/arcs/core/data/CapabilityTest.kt +++ b/javatests/arcs/core/data/CapabilityTest.kt @@ -18,10 +18,10 @@ import arcs.core.data.Capability.Shareable import arcs.core.data.Capability.Ttl import arcs.core.util.Time import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class CapabilityTest { diff --git a/javatests/arcs/core/data/InformationFlowLabelTest.kt b/javatests/arcs/core/data/InformationFlowLabelTest.kt index 3d4999eb3e5..9b2cbc143cf 100644 --- a/javatests/arcs/core/data/InformationFlowLabelTest.kt +++ b/javatests/arcs/core/data/InformationFlowLabelTest.kt @@ -14,10 +14,10 @@ package arcs.core.data import arcs.core.data.InformationFlowLabel.Predicate import arcs.core.data.InformationFlowLabel.SemanticTag import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class InformationFlowLabelTest { diff --git a/javatests/arcs/core/data/ParticleSpecTest.kt b/javatests/arcs/core/data/ParticleSpecTest.kt index 9de42ede2e6..90dcc0131cb 100644 --- a/javatests/arcs/core/data/ParticleSpecTest.kt +++ b/javatests/arcs/core/data/ParticleSpecTest.kt @@ -1,10 +1,10 @@ package arcs.core.data import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class ParticleSpecTest { diff --git a/javatests/arcs/core/data/PlanTest.kt b/javatests/arcs/core/data/PlanTest.kt index 1b7cc88dfb6..b9c9fac83a5 100644 --- a/javatests/arcs/core/data/PlanTest.kt +++ b/javatests/arcs/core/data/PlanTest.kt @@ -1,11 +1,11 @@ package arcs.core.data import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class PlanTest { diff --git a/javatests/arcs/core/data/SchemaRegistryTest.kt b/javatests/arcs/core/data/SchemaRegistryTest.kt index 1e9fe8d8a5a..8c98f735b5e 100644 --- a/javatests/arcs/core/data/SchemaRegistryTest.kt +++ b/javatests/arcs/core/data/SchemaRegistryTest.kt @@ -12,12 +12,12 @@ package arcs.core.data import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class SchemaRegistryTest { diff --git a/javatests/arcs/core/data/TypeUtilsTest.kt b/javatests/arcs/core/data/TypeUtilsTest.kt index 62e843fb503..f9cfa614c7f 100644 --- a/javatests/arcs/core/data/TypeUtilsTest.kt +++ b/javatests/arcs/core/data/TypeUtilsTest.kt @@ -15,11 +15,11 @@ import arcs.core.data.expression.InferredType import arcs.core.data.expression.MapScope import arcs.core.data.expression.asExpr import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith private const val testField = "test" diff --git a/javatests/arcs/core/data/expression/EvaluatorParticleTest.kt b/javatests/arcs/core/data/expression/EvaluatorParticleTest.kt index fe0c4309756..988929b0e0f 100644 --- a/javatests/arcs/core/data/expression/EvaluatorParticleTest.kt +++ b/javatests/arcs/core/data/expression/EvaluatorParticleTest.kt @@ -23,7 +23,6 @@ import com.google.common.truth.Truth.assertThat import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.times import com.nhaarman.mockitokotlin2.verify -import kotlin.test.assertFailsWith import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Before import org.junit.Rule @@ -32,6 +31,7 @@ import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.mockito.Mock import org.mockito.MockitoAnnotations +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) @OptIn(ExperimentalCoroutinesApi::class) @@ -205,9 +205,11 @@ class EvaluatorParticleTest { ) ) harness.start() - assertThat(harness.output.dispatchFetchAll().map { bar -> - bar.foos.joinToString { it.value } - }).containsExactly("(1-1)", "(2-1), (2-2)") + assertThat( + harness.output.dispatchFetchAll().map { bar -> + bar.foos.joinToString { it.value } + } + ).containsExactly("(1-1)", "(2-1), (2-2)") } @Test @@ -230,9 +232,11 @@ class EvaluatorParticleTest { ) ) harness.start() - assertThat(harness.output.dispatchFetchAll().map { bar -> - bar.foos.sortedBy { it.value }.joinToString { it.value } - }).containsExactly("(1-1)", "(2-1), (2-2)") + assertThat( + harness.output.dispatchFetchAll().map { bar -> + bar.foos.sortedBy { it.value }.joinToString { it.value } + } + ).containsExactly("(1-1)", "(2-1), (2-2)") } @Test @@ -259,9 +263,11 @@ class EvaluatorParticleTest { TypeErrorTestHarness { EvaluatorParticle(TypeErrorRecipePlan.particles.first()) } ) { harness -> harness.input.dispatchStore(TypeError_Input(a = "Hello", b = "World")) - assertThat(assertFailsWith { - harness.start() - }.message).contains( + assertThat( + assertFailsWith { + harness.start() + }.message + ).contains( "input.a + input.b: left hand side of expression expected to be numeric type but was String." ) } @@ -270,9 +276,11 @@ class EvaluatorParticleTest { fun typeOutputError() = runHarnessTest( TypeOutputErrorTestHarness { EvaluatorParticle(TypeOutputErrorRecipePlan.particles.first()) } ) { harness -> - assertThat(assertFailsWith { - harness.start() - }.message).contains("Handle output expected Bar {sum: Number} but found Bar {sum: String}") + assertThat( + assertFailsWith { + harness.start() + }.message + ).contains("Handle output expected Bar {sum: Number} but found Bar {sum: String}") } @Test @@ -282,9 +290,11 @@ class EvaluatorParticleTest { } ) { harness -> harness.input.dispatchStore(TypeErrorOutputTypo_Input(a = 1.0, b = 2.0)) - assertThat(assertFailsWith { - harness.start() - }.message).contains( + assertThat( + assertFailsWith { + harness.start() + }.message + ).contains( "Handle output expected Bar {sumx: Number} but found Bar {sum: Number}" ) } @@ -296,9 +306,11 @@ class EvaluatorParticleTest { } ) { harness -> harness.input.dispatchStore(TypeErrorInputTypo_Input(a = 1.0, c = 2.0)) - assertThat(assertFailsWith { - harness.start() - }.message).contains( + assertThat( + assertFailsWith { + harness.start() + }.message + ).contains( "Field `b` in input.b doesn't exist in scope Foo {a: Number, c: Number}" ) } diff --git a/javatests/arcs/core/data/expression/ExpressionTest.kt b/javatests/arcs/core/data/expression/ExpressionTest.kt index 50abf3ceb25..a48b689ddb9 100644 --- a/javatests/arcs/core/data/expression/ExpressionTest.kt +++ b/javatests/arcs/core/data/expression/ExpressionTest.kt @@ -14,11 +14,11 @@ package arcs.core.data.expression import arcs.core.data.expression.Expression.Scope import arcs.core.util.toBigInt import com.google.common.truth.Truth.assertThat -import java.math.BigInteger -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.math.BigInteger +import kotlin.test.assertFailsWith /** Tests for [Expression]. */ @RunWith(JUnit4::class) @@ -265,9 +265,11 @@ class ExpressionTest { fun evaluate_complexExpression() { // Test complex expression // (2 + (3 * 4) + blah + ?arg - 1) / 2 - val expr = (2.0.asExpr() + (3.asExpr() * 4.asExpr()) + num("blah") + query( - "arg" - ) - 1.asExpr()) / 2.asExpr() + val expr = ( + 2.0.asExpr() + (3.asExpr() * 4.asExpr()) + num("blah") + query( + "arg" + ) - 1.asExpr() + ) / 2.asExpr() assertThat(evalExpression(expr, currentScope, "arg" to 1)).isEqualTo(12) } @@ -335,9 +337,11 @@ class ExpressionTest { "sum" to scope("foo").get("val") + num("cnt") ) - assertThat(evalExpression(expr, currentScope).toList().map { - (it as MapScope<*>).map - }).containsExactly( + assertThat( + evalExpression(expr, currentScope).toList().map { + (it as MapScope<*>).map + } + ).containsExactly( mapOf("val" to 0, "count" to 2, "sum" to 2), mapOf("val" to 10, "count" to 0, "sum" to 10), mapOf("val" to 20, "count" to 3, "sum" to 23) @@ -413,11 +417,15 @@ class ExpressionTest { @Test fun evaluate_paxel_min_max_bigint() { - val scope = CurrentScope(mutableMapOf("numbers" to listOf( - BigInteger("55555555555555555"), - BigInteger("12345678987654321"), - BigInteger("98765432123456789") - ))) + val scope = CurrentScope( + mutableMapOf( + "numbers" to listOf( + BigInteger("55555555555555555"), + BigInteger("12345678987654321"), + BigInteger("98765432123456789") + ) + ) + ) assertThat( evalExpression(min(seq("numbers")), scope).toString() ).isEqualTo("12345678987654321") @@ -551,9 +559,11 @@ class ExpressionTest { | }""".trimMargin() ) as Expression.SelectExpression - assertThat(evalExpression(paxelExpr, currentScope).toList().map { - (it as MapScope<*>).map - }).containsExactly( + assertThat( + evalExpression(paxelExpr, currentScope).toList().map { + (it as MapScope<*>).map + } + ).containsExactly( mapOf("x" to 2.0, "y" to 3.0, "z" to 10, "foo" to 0), mapOf("x" to 3.0, "y" to 4.0, "z" to 10, "foo" to 0), mapOf("x" to 4.0, "y" to 5.0, "z" to 10, "foo" to 0), @@ -611,9 +621,11 @@ class ExpressionTest { |""".trimMargin() ) val parsed = PaxelParser.parse(toString) as Expression> - assertThat(evalExpression(parsed, currentScope).toList().map { - (it as MapScope<*>).map - }).containsExactly( + assertThat( + evalExpression(parsed, currentScope).toList().map { + (it as MapScope<*>).map + } + ).containsExactly( mapOf("val" to 0, "count" to 2, "sum" to 2), mapOf("val" to 20, "count" to 3, "sum" to 23) ) @@ -663,9 +675,11 @@ class ExpressionTest { ) val json = expr.serialize() val parsed = json.deserializeExpression() as Expression> - assertThat(evalExpression(parsed, currentScope).toList().map { - (it as MapScope<*>).map - }).containsExactly( + assertThat( + evalExpression(parsed, currentScope).toList().map { + (it as MapScope<*>).map + } + ).containsExactly( mapOf("val" to 0, "count" to 2, "sum" to 2), mapOf("val" to 20, "count" to 3, "sum" to 23) ) diff --git a/javatests/arcs/core/data/expression/TypeCheckerTest.kt b/javatests/arcs/core/data/expression/TypeCheckerTest.kt index a09fc86150f..13ddede65a4 100644 --- a/javatests/arcs/core/data/expression/TypeCheckerTest.kt +++ b/javatests/arcs/core/data/expression/TypeCheckerTest.kt @@ -26,11 +26,11 @@ import arcs.core.data.expression.InferredType.SeqType import arcs.core.data.expression.InferredType.UnionType import arcs.core.util.BigInt import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith -import kotlin.test.assertTrue import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith +import kotlin.test.assertTrue /** Tests for [TypeEvaluator]. */ @RunWith(JUnit4::class) diff --git a/javatests/arcs/core/data/proto/AccessPathProtoDecoderTest.kt b/javatests/arcs/core/data/proto/AccessPathProtoDecoderTest.kt index 15f9d0a2893..ab6321aecf6 100644 --- a/javatests/arcs/core/data/proto/AccessPathProtoDecoderTest.kt +++ b/javatests/arcs/core/data/proto/AccessPathProtoDecoderTest.kt @@ -7,10 +7,10 @@ import arcs.core.data.ParticleSpec import arcs.core.data.Recipe import arcs.core.data.TypeVariable import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class AccessPathProtoDecoderTest { diff --git a/javatests/arcs/core/data/proto/HandleProtoDecoderTest.kt b/javatests/arcs/core/data/proto/HandleProtoDecoderTest.kt index 01ae09607d1..05a36e94900 100644 --- a/javatests/arcs/core/data/proto/HandleProtoDecoderTest.kt +++ b/javatests/arcs/core/data/proto/HandleProtoDecoderTest.kt @@ -5,10 +5,10 @@ import arcs.core.data.Recipe.Handle import arcs.core.data.TypeVariable import com.google.common.truth.Truth.assertThat import com.google.protobuf.TextFormat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith /** Parses a given proto text as [HandleProto]. */ fun parseHandleProtoText(protoText: String): HandleProto { @@ -71,7 +71,7 @@ class HandleProtoDecoderTest { } } } - """.trimIndent() + """.trimIndent() val storageKey = "ramdisk://b" val entityType = parseTypeProtoText(entityTypeProto).decode() val handleText = buildHandleProtoText( @@ -120,7 +120,7 @@ class HandleProtoDecoderTest { } } } - """.trimIndent() + """.trimIndent() val storageKey = "ramdisk://b" val entityType = parseTypeProtoText(entityTypeProto).decode() val handleText = buildHandleProtoText( @@ -227,5 +227,5 @@ class HandleProtoDecoderTest { $type annotations: $annotations ${tags.joinToString { """tags: "$it"""" }} - """.trimIndent() + """.trimIndent() } diff --git a/javatests/arcs/core/data/proto/ParseManifestProtoTest.kt b/javatests/arcs/core/data/proto/ParseManifestProtoTest.kt index f5587cf7da3..a2bb0f6e3f2 100644 --- a/javatests/arcs/core/data/proto/ParseManifestProtoTest.kt +++ b/javatests/arcs/core/data/proto/ParseManifestProtoTest.kt @@ -3,10 +3,10 @@ package arcs.core.data.proto import arcs.repoutils.runfilesDir import com.google.common.truth.Truth.assertThat import com.google.protobuf.TextFormat -import java.io.File import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.io.File @RunWith(JUnit4::class) class ParseManifestProtoTest { diff --git a/javatests/arcs/core/data/proto/ParticleProtoDecoderTest.kt b/javatests/arcs/core/data/proto/ParticleProtoDecoderTest.kt index 3c7ef282ced..e49e6d2d7d6 100644 --- a/javatests/arcs/core/data/proto/ParticleProtoDecoderTest.kt +++ b/javatests/arcs/core/data/proto/ParticleProtoDecoderTest.kt @@ -12,10 +12,10 @@ import arcs.core.data.SchemaFields import arcs.core.data.SchemaName import arcs.core.data.TypeVariable import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class ParticleProtoDecoderTest { @@ -38,7 +38,7 @@ class ParticleProtoDecoderTest { } } } - """.trimIndent() + """.trimIndent() ) val thingType = EntityType( Schema( diff --git a/javatests/arcs/core/data/proto/ParticleSpecProtoDecoderTest.kt b/javatests/arcs/core/data/proto/ParticleSpecProtoDecoderTest.kt index 61de53123c5..bb8b0d39e33 100644 --- a/javatests/arcs/core/data/proto/ParticleSpecProtoDecoderTest.kt +++ b/javatests/arcs/core/data/proto/ParticleSpecProtoDecoderTest.kt @@ -18,10 +18,10 @@ import arcs.core.data.SchemaName import arcs.core.data.expression.Expression import com.google.common.truth.Truth.assertThat import com.google.protobuf.TextFormat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith typealias DirectionProto = HandleConnectionSpecProto.Direction @@ -87,7 +87,7 @@ class ParticleSpecProtoDecoderTest { } } ${expression?.let { "expression: \"$it\"" } ?: ""} - """.trimIndent() + """.trimIndent() } @Test @@ -123,7 +123,7 @@ class ParticleSpecProtoDecoderTest { annotations { name: "isolated" } - """.trimIndent() + """.trimIndent() val readerSpec = decodeParticleSpecProto(readerSpecProto) val readConnectionSpec = decodeHandleConnectionSpecProto(readConnectionSpecProto) assertThat(readerSpec).isEqualTo( @@ -147,7 +147,7 @@ class ParticleSpecProtoDecoderTest { str_value: "MyEgressType" } } - """.trimIndent() + """.trimIndent() val readerWriterSpec = decodeParticleSpecProto(readerWriterSpecProto) val writeConnectionSpec = decodeHandleConnectionSpecProto(writeConnectionSpecProto) assertThat(readerWriterSpec).isEqualTo( @@ -200,7 +200,7 @@ class ParticleSpecProtoDecoderTest { } } } - """.trimIndent() + """.trimIndent() val readerWriterSpec = decodeParticleSpecProto(readerWriterSpecProto) val readConnectionSpec = decodeHandleConnectionSpecProto(readConnectionSpecProto) val writeConnectionSpec = decodeHandleConnectionSpecProto(writeConnectionSpecProto) @@ -249,7 +249,7 @@ class ParticleSpecProtoDecoderTest { } } } - """.trimIndent() + """.trimIndent() val readerWriterSpec = decodeParticleSpecProto(readerWriterSpecProto) val readConnectionSpec = decodeHandleConnectionSpecProto(readConnectionSpecProto) assertThat(readerWriterSpec.checks).containsExactly( @@ -272,7 +272,7 @@ class ParticleSpecProtoDecoderTest { connections { $readConnectionSpecProto } connections { $readConnectionSpecProto } location: "Everywhere" - """.trimIndent() + """.trimIndent() val exception = assertFailsWith { decodeParticleSpecProto(readerSpecProto) } diff --git a/javatests/arcs/core/data/proto/RecipeProtoDecoderTest.kt b/javatests/arcs/core/data/proto/RecipeProtoDecoderTest.kt index 91ed5afc5a5..a9b285f1396 100644 --- a/javatests/arcs/core/data/proto/RecipeProtoDecoderTest.kt +++ b/javatests/arcs/core/data/proto/RecipeProtoDecoderTest.kt @@ -12,10 +12,10 @@ import arcs.core.data.SchemaFields import arcs.core.data.SchemaName import arcs.core.data.TypeVariable import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith /** Creates and [arcId] [AnnotationProto]. */ fun arcIdAnnotationProto(id: String): AnnotationProto { diff --git a/javatests/arcs/core/data/proto/TypeProtoDecodersTest.kt b/javatests/arcs/core/data/proto/TypeProtoDecodersTest.kt index c59b1def136..ad42078761a 100644 --- a/javatests/arcs/core/data/proto/TypeProtoDecodersTest.kt +++ b/javatests/arcs/core/data/proto/TypeProtoDecodersTest.kt @@ -15,12 +15,12 @@ import arcs.core.data.TypeVariable import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertWithMessage import com.google.protobuf.TextFormat -import kotlin.test.assertFailsWith import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith /** Parses a given proto text as [TypeProto]. */ fun parseTypeProtoText(protoText: String): TypeProto { diff --git a/javatests/arcs/core/data/util/ReferencableListTest.kt b/javatests/arcs/core/data/util/ReferencableListTest.kt index 8a77de2d937..226de1b81f9 100644 --- a/javatests/arcs/core/data/util/ReferencableListTest.kt +++ b/javatests/arcs/core/data/util/ReferencableListTest.kt @@ -13,10 +13,10 @@ package arcs.core.data.util import arcs.core.data.FieldType import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFails import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFails @RunWith(JUnit4::class) class ReferencableListTest { diff --git a/javatests/arcs/core/data/util/ReferencablePrimitiveTest.kt b/javatests/arcs/core/data/util/ReferencablePrimitiveTest.kt index ac899c8faca..742c20a333b 100644 --- a/javatests/arcs/core/data/util/ReferencablePrimitiveTest.kt +++ b/javatests/arcs/core/data/util/ReferencablePrimitiveTest.kt @@ -15,11 +15,11 @@ import arcs.core.data.util.ReferencablePrimitive.Companion.isSupportedPrimitive import arcs.core.util.ArcsInstant import arcs.core.util.BigInt import com.google.common.truth.Truth.assertThat -import java.math.BigInteger -import java.time.Instant import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized +import java.math.BigInteger +import java.time.Instant @RunWith(Parameterized::class) class ReferencablePrimitiveTest(private val params: UnwrapWrapParams) { diff --git a/javatests/arcs/core/entity/EntityBaseTest.kt b/javatests/arcs/core/entity/EntityBaseTest.kt index 4a14e5c93ea..7c945079db9 100644 --- a/javatests/arcs/core/entity/EntityBaseTest.kt +++ b/javatests/arcs/core/entity/EntityBaseTest.kt @@ -23,18 +23,18 @@ import arcs.core.data.util.ReferencablePrimitive import arcs.core.data.util.toReferencable import arcs.core.entity.testutil.DummyEntity import arcs.core.entity.testutil.InlineDummyEntity -import arcs.core.storage.Reference as StorageReference import arcs.core.storage.testutil.DummyStorageKey import arcs.core.util.ArcsInstant import arcs.core.util.BigInt import arcs.jvm.util.testutil.FakeTime import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith +import arcs.core.storage.Reference as StorageReference @RunWith(JUnit4::class) @Suppress("UNCHECKED_CAST") diff --git a/javatests/arcs/core/entity/ForeignReferenceCheckerTest.kt b/javatests/arcs/core/entity/ForeignReferenceCheckerTest.kt index 9ed7818706d..50b8c2e3c36 100644 --- a/javatests/arcs/core/entity/ForeignReferenceCheckerTest.kt +++ b/javatests/arcs/core/entity/ForeignReferenceCheckerTest.kt @@ -5,11 +5,11 @@ import arcs.core.data.Schema.Companion.EMPTY import arcs.core.data.SchemaName import arcs.core.entity.testutil.DummyEntity import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class ForeignReferenceCheckerTest { diff --git a/javatests/arcs/core/entity/HandleManagerTestBase.kt b/javatests/arcs/core/entity/HandleManagerTestBase.kt index 3b8b8c09797..c58135879d6 100644 --- a/javatests/arcs/core/entity/HandleManagerTestBase.kt +++ b/javatests/arcs/core/entity/HandleManagerTestBase.kt @@ -42,8 +42,6 @@ import arcs.flags.BuildFlags import arcs.flags.testing.BuildFlagsRule import arcs.jvm.util.testutil.FakeTime import com.google.common.truth.Truth.assertThat -import java.util.concurrent.Executors -import kotlin.test.assertFailsWith import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.asCoroutineDispatcher @@ -54,6 +52,8 @@ import kotlinx.coroutines.withTimeout import org.junit.Ignore import org.junit.Rule import org.junit.Test +import java.util.concurrent.Executors +import kotlin.test.assertFailsWith @Suppress("EXPERIMENTAL_API_USAGE", "UNCHECKED_CAST") open class HandleManagerTestBase { diff --git a/javatests/arcs/core/entity/HandleTest.kt b/javatests/arcs/core/entity/HandleTest.kt index 63be91afe98..6d109e66732 100644 --- a/javatests/arcs/core/entity/HandleTest.kt +++ b/javatests/arcs/core/entity/HandleTest.kt @@ -18,10 +18,10 @@ import arcs.core.data.ReferenceType import arcs.core.data.SingletonType import arcs.core.entity.testutil.DummyEntity import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class HandleTest { diff --git a/javatests/arcs/core/entity/ReferenceTest.kt b/javatests/arcs/core/entity/ReferenceTest.kt index 608df5de4af..f604b8a7193 100644 --- a/javatests/arcs/core/entity/ReferenceTest.kt +++ b/javatests/arcs/core/entity/ReferenceTest.kt @@ -10,7 +10,6 @@ import arcs.core.entity.testutil.DummyEntity import arcs.core.entity.testutil.InlineDummyEntity import arcs.core.host.EntityHandleManager import arcs.core.storage.RawEntityDereferencer -import arcs.core.storage.Reference as StorageReference import arcs.core.storage.api.DriverAndKeyConfigurator import arcs.core.storage.driver.RamDisk import arcs.core.storage.keys.RamDiskStorageKey @@ -23,7 +22,6 @@ import arcs.core.util.Scheduler import arcs.core.util.testutil.LogRule import arcs.jvm.util.testutil.FakeTime import com.google.common.truth.Truth.assertThat -import java.util.concurrent.Executors import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.asCoroutineDispatcher import org.junit.After @@ -32,6 +30,8 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.util.concurrent.Executors +import arcs.core.storage.Reference as StorageReference @OptIn(ExperimentalCoroutinesApi::class) @RunWith(JUnit4::class) diff --git a/javatests/arcs/core/entity/SingletonHandleTest.kt b/javatests/arcs/core/entity/SingletonHandleTest.kt index d57c3f0d418..5f352b3fec8 100644 --- a/javatests/arcs/core/entity/SingletonHandleTest.kt +++ b/javatests/arcs/core/entity/SingletonHandleTest.kt @@ -26,13 +26,13 @@ import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.whenever -import kotlin.test.assertFailsWith import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runBlockingTest import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @OptIn(ExperimentalCoroutinesApi::class) @Suppress("DeferredResultUnused") diff --git a/javatests/arcs/core/entity/StorageAdapterTest.kt b/javatests/arcs/core/entity/StorageAdapterTest.kt index 5785960ac90..b808eab59b4 100644 --- a/javatests/arcs/core/entity/StorageAdapterTest.kt +++ b/javatests/arcs/core/entity/StorageAdapterTest.kt @@ -13,7 +13,6 @@ import arcs.core.data.util.toReferencable import arcs.core.entity.testutil.DummyEntity import arcs.core.entity.testutil.InlineDummyEntity import arcs.core.entity.testutil.RestrictedDummyEntity -import arcs.core.storage.Reference as StorageReference import arcs.core.storage.StorageKey import arcs.core.storage.keys.DatabaseStorageKey import arcs.core.storage.keys.RamDiskStorageKey @@ -22,11 +21,12 @@ import arcs.core.storage.testutil.DummyStorageKey import arcs.core.storage.testutil.testStorageEndpointManager import arcs.jvm.util.testutil.FakeTime import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith +import arcs.core.storage.Reference as StorageReference @RunWith(JUnit4::class) class StorageAdapterTest { diff --git a/javatests/arcs/core/entity/VariableEntityBaseTest.kt b/javatests/arcs/core/entity/VariableEntityBaseTest.kt index 12c80b100d0..700fbd96b35 100644 --- a/javatests/arcs/core/entity/VariableEntityBaseTest.kt +++ b/javatests/arcs/core/entity/VariableEntityBaseTest.kt @@ -7,12 +7,12 @@ import arcs.core.entity.testutil.DummyVariableEntity import arcs.core.entity.testutil.InlineDummyEntity import arcs.core.storage.testutil.DummyStorageKey import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) @Suppress("UNCHECKED_CAST") diff --git a/javatests/arcs/core/host/HandleAdapterTest.kt b/javatests/arcs/core/host/HandleAdapterTest.kt index b867d3f11fe..cda564e5f31 100644 --- a/javatests/arcs/core/host/HandleAdapterTest.kt +++ b/javatests/arcs/core/host/HandleAdapterTest.kt @@ -46,7 +46,6 @@ import arcs.core.util.testutil.LogRule import arcs.jvm.util.testutil.FakeTime import arcs.sdk.ReadWriteCollectionHandle import com.google.common.truth.Truth.assertThat -import kotlin.coroutines.EmptyCoroutineContext import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking @@ -56,6 +55,7 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.coroutines.EmptyCoroutineContext private typealias Person = ReadPerson_Person private typealias QueryPerson = QueryPerson_Person diff --git a/javatests/arcs/core/host/LifecycleTest.kt b/javatests/arcs/core/host/LifecycleTest.kt index c751a8c7642..02b2773079a 100644 --- a/javatests/arcs/core/host/LifecycleTest.kt +++ b/javatests/arcs/core/host/LifecycleTest.kt @@ -26,7 +26,6 @@ import arcs.core.util.testutil.LogRule import arcs.jvm.host.ExplicitHostRegistry import arcs.jvm.util.testutil.FakeTime import com.google.common.truth.Truth.assertThat -import kotlin.coroutines.EmptyCoroutineContext import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking @@ -37,6 +36,7 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.coroutines.EmptyCoroutineContext // TODO: test desync/resync diff --git a/javatests/arcs/core/host/ParticleContextTest.kt b/javatests/arcs/core/host/ParticleContextTest.kt index cc23d118dfb..169f5188909 100644 --- a/javatests/arcs/core/host/ParticleContextTest.kt +++ b/javatests/arcs/core/host/ParticleContextTest.kt @@ -39,8 +39,6 @@ import com.nhaarman.mockitokotlin2.times import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions import com.nhaarman.mockitokotlin2.whenever -import kotlin.coroutines.EmptyCoroutineContext -import kotlin.test.assertFailsWith import org.junit.Before import org.junit.Ignore import org.junit.Rule @@ -49,6 +47,8 @@ import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.mockito.Mock import org.mockito.MockitoAnnotations +import kotlin.coroutines.EmptyCoroutineContext +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class ParticleContextTest { diff --git a/javatests/arcs/core/host/ParticleIdentifierTest.kt b/javatests/arcs/core/host/ParticleIdentifierTest.kt index cc7888a6d86..2861f39ce1f 100644 --- a/javatests/arcs/core/host/ParticleIdentifierTest.kt +++ b/javatests/arcs/core/host/ParticleIdentifierTest.kt @@ -13,10 +13,10 @@ package arcs.core.host import arcs.core.host.api.HandleHolder import arcs.sdk.Particle import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class ParticleIdentifierTest { diff --git a/javatests/arcs/core/host/SimpleSchedulerProviderTest.kt b/javatests/arcs/core/host/SimpleSchedulerProviderTest.kt index 948d0052e70..106fd69ecf1 100644 --- a/javatests/arcs/core/host/SimpleSchedulerProviderTest.kt +++ b/javatests/arcs/core/host/SimpleSchedulerProviderTest.kt @@ -17,7 +17,6 @@ import arcs.core.util.Scheduler import arcs.core.util.testutil.LogRule import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertWithMessage -import java.util.concurrent.Executors import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.withContext @@ -25,6 +24,7 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.util.concurrent.Executors @RunWith(JUnit4::class) class SimpleSchedulerProviderTest { diff --git a/javatests/arcs/core/host/TestingHost.kt b/javatests/arcs/core/host/TestingHost.kt index 08ade34707d..248eba5b3bb 100644 --- a/javatests/arcs/core/host/TestingHost.kt +++ b/javatests/arcs/core/host/TestingHost.kt @@ -11,10 +11,10 @@ import arcs.sdk.Handle import arcs.sdk.HandleHolderBase import arcs.sdk.ReadWriteCollectionHandle import arcs.sdk.ReadWriteSingletonHandle -import java.lang.IllegalArgumentException import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi +import java.lang.IllegalArgumentException @OptIn(ExperimentalCoroutinesApi::class) open class TestingHost( diff --git a/javatests/arcs/core/host/TestingJvmProdHost.kt b/javatests/arcs/core/host/TestingJvmProdHost.kt index c7e7a2d1eb9..bf31d832a42 100644 --- a/javatests/arcs/core/host/TestingJvmProdHost.kt +++ b/javatests/arcs/core/host/TestingJvmProdHost.kt @@ -14,4 +14,5 @@ open class TestingJvmProdHost( storageEndpointManager, *scanForParticles(TestingJvmProdHost::class), *particles -), ProdHost +), + ProdHost diff --git a/javatests/arcs/core/host/UtilsTest.kt b/javatests/arcs/core/host/UtilsTest.kt index cfd584003a1..6fad5a3f0d4 100644 --- a/javatests/arcs/core/host/UtilsTest.kt +++ b/javatests/arcs/core/host/UtilsTest.kt @@ -16,12 +16,12 @@ import arcs.core.data.Plan import arcs.core.host.api.HandleHolder import arcs.sdk.Particle import com.google.common.truth.Truth.assertThat -import kotlin.reflect.KClass import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runBlockingTest import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized +import kotlin.reflect.KClass @ExperimentalCoroutinesApi @RunWith(Parameterized::class) diff --git a/javatests/arcs/core/host/WritePerson.kt b/javatests/arcs/core/host/WritePerson.kt index 0203c344c34..7ede4da8230 100644 --- a/javatests/arcs/core/host/WritePerson.kt +++ b/javatests/arcs/core/host/WritePerson.kt @@ -1,7 +1,7 @@ package arcs.core.host -import java.lang.IllegalArgumentException import kotlinx.coroutines.CompletableDeferred +import java.lang.IllegalArgumentException class WritePerson : AbstractWritePerson() { var wrote = false diff --git a/javatests/arcs/core/policy/PolicyTest.kt b/javatests/arcs/core/policy/PolicyTest.kt index a209e48ab47..b14a4aeb2cc 100644 --- a/javatests/arcs/core/policy/PolicyTest.kt +++ b/javatests/arcs/core/policy/PolicyTest.kt @@ -5,10 +5,10 @@ import arcs.core.data.Capability.Encryption import arcs.core.data.Capability.Persistence import arcs.core.data.Capability.Ttl import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class PolicyTest { diff --git a/javatests/arcs/core/policy/proto/PolicyProtoTest.kt b/javatests/arcs/core/policy/proto/PolicyProtoTest.kt index ab77ecfbcde..f5fda359d8f 100644 --- a/javatests/arcs/core/policy/proto/PolicyProtoTest.kt +++ b/javatests/arcs/core/policy/proto/PolicyProtoTest.kt @@ -11,10 +11,10 @@ import arcs.core.policy.PolicyTarget import arcs.core.policy.StorageMedium import arcs.core.policy.UsageType import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class PolicyProtoTest { diff --git a/javatests/arcs/core/storage/BulkReferenceModeStoreTest.kt b/javatests/arcs/core/storage/BulkReferenceModeStoreTest.kt index 60805123c4b..192625191d2 100644 --- a/javatests/arcs/core/storage/BulkReferenceModeStoreTest.kt +++ b/javatests/arcs/core/storage/BulkReferenceModeStoreTest.kt @@ -21,8 +21,6 @@ import arcs.core.storage.referencemode.ReferenceModeStorageKey import arcs.core.storage.testutil.testWriteBackProvider import arcs.core.util.testutil.LogRule import com.google.common.truth.Truth.assertThat -import java.util.concurrent.CountDownLatch -import kotlin.random.Random import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -37,6 +35,8 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.util.concurrent.CountDownLatch +import kotlin.random.Random @Suppress("UNCHECKED_CAST") @OptIn(ExperimentalCoroutinesApi::class) diff --git a/javatests/arcs/core/storage/CapabilitiesResolverTest.kt b/javatests/arcs/core/storage/CapabilitiesResolverTest.kt index 0071473ea6d..697c243c905 100644 --- a/javatests/arcs/core/storage/CapabilitiesResolverTest.kt +++ b/javatests/arcs/core/storage/CapabilitiesResolverTest.kt @@ -29,11 +29,11 @@ import arcs.core.storage.keys.RamDiskStorageKey import arcs.core.storage.keys.VolatileStorageKey import arcs.core.storage.referencemode.ReferenceModeStorageKey import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.After import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith /** Tests for [CapabilitiesResolver]. */ @RunWith(JUnit4::class) diff --git a/javatests/arcs/core/storage/DirectStoreMuxerTest.kt b/javatests/arcs/core/storage/DirectStoreMuxerTest.kt index f970affc116..001635a4e53 100644 --- a/javatests/arcs/core/storage/DirectStoreMuxerTest.kt +++ b/javatests/arcs/core/storage/DirectStoreMuxerTest.kt @@ -27,7 +27,6 @@ import arcs.core.storage.testutil.MockDriverProvider import arcs.core.storage.testutil.testDriverFactory import arcs.core.storage.testutil.testWriteBackProvider import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -40,6 +39,7 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) @OptIn(ExperimentalCoroutinesApi::class) diff --git a/javatests/arcs/core/storage/RamDiskStoreIntegrationTest.kt b/javatests/arcs/core/storage/RamDiskStoreIntegrationTest.kt index 33de006a9b6..043d5eb654d 100644 --- a/javatests/arcs/core/storage/RamDiskStoreIntegrationTest.kt +++ b/javatests/arcs/core/storage/RamDiskStoreIntegrationTest.kt @@ -24,7 +24,6 @@ import arcs.core.storage.keys.RamDiskStorageKey import arcs.core.storage.testutil.testDriverFactory import arcs.core.storage.testutil.testWriteBackProvider import com.google.common.truth.Truth.assertThat -import kotlin.random.Random import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -40,6 +39,7 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.random.Random /** Tests behaviors of the combination of [DirectStore] and [RamDisk]. */ @OptIn(ExperimentalCoroutinesApi::class) diff --git a/javatests/arcs/core/storage/StorageKeyParserTest.kt b/javatests/arcs/core/storage/StorageKeyParserTest.kt index 4aa9a99614a..255b2a6ef73 100644 --- a/javatests/arcs/core/storage/StorageKeyParserTest.kt +++ b/javatests/arcs/core/storage/StorageKeyParserTest.kt @@ -14,7 +14,6 @@ package arcs.core.storage import arcs.core.storage.api.DriverAndKeyConfigurator import arcs.core.storage.keys.RamDiskStorageKey import com.google.common.truth.Truth.assertThat -import java.util.concurrent.Executors import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.launch @@ -22,6 +21,7 @@ import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.util.concurrent.Executors /** Tests for [StorageKeyParser]. */ @OptIn(ExperimentalCoroutinesApi::class) diff --git a/javatests/arcs/core/storage/StorageKeyUtilsTest.kt b/javatests/arcs/core/storage/StorageKeyUtilsTest.kt index 2efdf63f2e8..78c2c659bf9 100644 --- a/javatests/arcs/core/storage/StorageKeyUtilsTest.kt +++ b/javatests/arcs/core/storage/StorageKeyUtilsTest.kt @@ -5,10 +5,10 @@ import arcs.core.storage.keys.RamDiskStorageKey import arcs.core.storage.keys.VolatileStorageKey import arcs.core.storage.referencemode.ReferenceModeStorageKey import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class StorageKeyUtilsTest { diff --git a/javatests/arcs/core/storage/StorageProxyImplTest.kt b/javatests/arcs/core/storage/StorageProxyImplTest.kt index 789e6ed429e..de438222b26 100644 --- a/javatests/arcs/core/storage/StorageProxyImplTest.kt +++ b/javatests/arcs/core/storage/StorageProxyImplTest.kt @@ -38,8 +38,6 @@ import com.nhaarman.mockitokotlin2.times import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions import com.nhaarman.mockitokotlin2.whenever -import java.util.concurrent.Executors -import kotlin.test.assertFailsWith import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.Job @@ -57,6 +55,8 @@ import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.mockito.Mock import org.mockito.MockitoAnnotations +import java.util.concurrent.Executors +import kotlin.test.assertFailsWith @OptIn(ExperimentalCoroutinesApi::class) @RunWith(JUnit4::class) diff --git a/javatests/arcs/core/storage/StoreWriteBackTest.kt b/javatests/arcs/core/storage/StoreWriteBackTest.kt index 5f7b12456f6..09d46d569ff 100644 --- a/javatests/arcs/core/storage/StoreWriteBackTest.kt +++ b/javatests/arcs/core/storage/StoreWriteBackTest.kt @@ -31,10 +31,6 @@ import arcs.core.storage.testutil.testWriteBackProvider import arcs.core.util.testutil.LogRule import arcs.jvm.storage.database.testutil.FakeDatabaseManager import com.google.common.truth.Truth.assertThat -import java.util.concurrent.CopyOnWriteArrayList -import java.util.concurrent.Executors -import kotlin.coroutines.coroutineContext -import kotlin.random.Random import kotlinx.atomicfu.atomic import kotlinx.atomicfu.update import kotlinx.coroutines.CoroutineScope @@ -53,6 +49,10 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.util.concurrent.CopyOnWriteArrayList +import java.util.concurrent.Executors +import kotlin.coroutines.coroutineContext +import kotlin.random.Random @Suppress("EXPERIMENTAL_API_USAGE") @RunWith(JUnit4::class) diff --git a/javatests/arcs/core/storage/driver/DatabaseDriverTest.kt b/javatests/arcs/core/storage/driver/DatabaseDriverTest.kt index 51b1b8dde8a..494560f4c2e 100644 --- a/javatests/arcs/core/storage/driver/DatabaseDriverTest.kt +++ b/javatests/arcs/core/storage/driver/DatabaseDriverTest.kt @@ -35,7 +35,6 @@ import arcs.core.util.testutil.LogRule import arcs.jvm.storage.database.testutil.FakeDatabase import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertWithMessage -import kotlin.reflect.KClass import kotlinx.coroutines.test.runBlockingTest import org.junit.Assert.fail import org.junit.Before @@ -43,6 +42,7 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.reflect.KClass @Suppress("EXPERIMENTAL_API_USAGE") @RunWith(JUnit4::class) diff --git a/javatests/arcs/core/storage/keys/DatabaseStorageKeyTest.kt b/javatests/arcs/core/storage/keys/DatabaseStorageKeyTest.kt index c9fd7e3c28d..ae7d9741071 100644 --- a/javatests/arcs/core/storage/keys/DatabaseStorageKeyTest.kt +++ b/javatests/arcs/core/storage/keys/DatabaseStorageKeyTest.kt @@ -14,11 +14,11 @@ package arcs.core.storage.keys import arcs.core.storage.StorageKeyParser import arcs.core.testutil.fail import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class DatabaseStorageKeyTest { diff --git a/javatests/arcs/core/storage/keys/JoinStorageKeyTest.kt b/javatests/arcs/core/storage/keys/JoinStorageKeyTest.kt index f8570d3512c..2ce11303a37 100644 --- a/javatests/arcs/core/storage/keys/JoinStorageKeyTest.kt +++ b/javatests/arcs/core/storage/keys/JoinStorageKeyTest.kt @@ -13,11 +13,11 @@ package arcs.core.storage.keys import arcs.core.storage.StorageKeyParser import arcs.core.storage.embed import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith /** Tests for [JoinStorageKey]. */ @RunWith(JUnit4::class) diff --git a/javatests/arcs/core/storage/keys/VolatileStorageKeyTest.kt b/javatests/arcs/core/storage/keys/VolatileStorageKeyTest.kt index 6a705fe6cea..7df0ec22477 100644 --- a/javatests/arcs/core/storage/keys/VolatileStorageKeyTest.kt +++ b/javatests/arcs/core/storage/keys/VolatileStorageKeyTest.kt @@ -14,12 +14,12 @@ import arcs.core.common.ArcId import arcs.core.common.toArcId import arcs.core.storage.StorageKeyParser import com.google.common.truth.Truth.assertThat -import java.lang.IllegalArgumentException -import kotlin.test.assertFailsWith import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.lang.IllegalArgumentException +import kotlin.test.assertFailsWith /** Tests for [VolatileStorageKey]. */ @RunWith(JUnit4::class) diff --git a/javatests/arcs/core/storage/referencemode/ReferenceModeStorageKeyTest.kt b/javatests/arcs/core/storage/referencemode/ReferenceModeStorageKeyTest.kt index 84655e400d2..fe594eba75f 100644 --- a/javatests/arcs/core/storage/referencemode/ReferenceModeStorageKeyTest.kt +++ b/javatests/arcs/core/storage/referencemode/ReferenceModeStorageKeyTest.kt @@ -15,11 +15,11 @@ import arcs.core.storage.embed import arcs.core.storage.keys.DatabaseStorageKey import arcs.core.storage.keys.RamDiskStorageKey import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith /** Tests for [ReferenceModeStorageKey]. */ @RunWith(JUnit4::class) diff --git a/javatests/arcs/core/storage/util/CallbackManagerTest.kt b/javatests/arcs/core/storage/util/CallbackManagerTest.kt index db3df3d0cdf..51226c7ecd0 100644 --- a/javatests/arcs/core/storage/util/CallbackManagerTest.kt +++ b/javatests/arcs/core/storage/util/CallbackManagerTest.kt @@ -16,11 +16,11 @@ import arcs.core.crdt.CrdtOperation import arcs.core.crdt.VersionMap import arcs.core.storage.ProxyMessage import com.google.common.truth.Truth.assertThat -import kotlin.random.Random import kotlinx.coroutines.ExperimentalCoroutinesApi import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.random.Random private typealias DummyProxyMessage = ProxyMessage diff --git a/javatests/arcs/core/storage/util/TokenGeneratorTest.kt b/javatests/arcs/core/storage/util/TokenGeneratorTest.kt index 880a2192a64..71403732e3d 100644 --- a/javatests/arcs/core/storage/util/TokenGeneratorTest.kt +++ b/javatests/arcs/core/storage/util/TokenGeneratorTest.kt @@ -1,10 +1,10 @@ package arcs.core.storage.util import com.google.common.truth.Truth.assertThat -import kotlin.random.Random import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.random.Random @RunWith(JUnit4::class) class TokenGeneratorTest { diff --git a/javatests/arcs/core/type/TypeTest.kt b/javatests/arcs/core/type/TypeTest.kt index b2c9ee6ebf8..6a31588a004 100644 --- a/javatests/arcs/core/type/TypeTest.kt +++ b/javatests/arcs/core/type/TypeTest.kt @@ -12,10 +12,10 @@ package arcs.core.type import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith /** * Tests for [Type]. diff --git a/javatests/arcs/core/util/Base64PerformanceTest.kt b/javatests/arcs/core/util/Base64PerformanceTest.kt index 0fcc8b3b81e..23e5229d8ca 100644 --- a/javatests/arcs/core/util/Base64PerformanceTest.kt +++ b/javatests/arcs/core/util/Base64PerformanceTest.kt @@ -12,16 +12,16 @@ package arcs.core.util import com.google.common.truth.Truth.assertWithMessage -import java.security.SecureRandom -import java.util.concurrent.Executors -import java.util.concurrent.TimeUnit -import kotlin.system.measureNanoTime import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.async import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized +import java.security.SecureRandom +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import kotlin.system.measureNanoTime /** * Performance comparison tests between Arcs' implementation of Base64-encoding/decoding and Java's. diff --git a/javatests/arcs/core/util/GuardTest.kt b/javatests/arcs/core/util/GuardTest.kt index 7808937f16d..6171fc79392 100644 --- a/javatests/arcs/core/util/GuardTest.kt +++ b/javatests/arcs/core/util/GuardTest.kt @@ -1,7 +1,6 @@ package arcs.core.util import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock @@ -9,6 +8,7 @@ import kotlinx.coroutines.test.runBlockingTest import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith /** Tests for the [guardedBy]-generated property delegate: [GuardDelegate]. */ @OptIn(ExperimentalCoroutinesApi::class) diff --git a/javatests/arcs/core/util/ParserTest.kt b/javatests/arcs/core/util/ParserTest.kt index 86ad60895d3..328c9e2b12f 100644 --- a/javatests/arcs/core/util/ParserTest.kt +++ b/javatests/arcs/core/util/ParserTest.kt @@ -3,10 +3,10 @@ package arcs.core.util import arcs.core.util.ParseResult.Failure import arcs.core.util.ParseResult.Success import com.google.common.truth.Truth.assertThat -import kotlin.test.fail import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.fail /** Tests for [Parser]. */ @RunWith(JUnit4::class) diff --git a/javatests/arcs/core/util/ResultTest.kt b/javatests/arcs/core/util/ResultTest.kt index 3736599f95a..57cbccb5fea 100644 --- a/javatests/arcs/core/util/ResultTest.kt +++ b/javatests/arcs/core/util/ResultTest.kt @@ -1,10 +1,10 @@ package arcs.core.util import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFails import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFails @RunWith(JUnit4::class) class ResultTest { diff --git a/javatests/arcs/core/util/RunningStatisticsTest.kt b/javatests/arcs/core/util/RunningStatisticsTest.kt index 0a1b3799fd1..a9ff540c235 100644 --- a/javatests/arcs/core/util/RunningStatisticsTest.kt +++ b/javatests/arcs/core/util/RunningStatisticsTest.kt @@ -12,10 +12,10 @@ package arcs.core.util import com.google.common.truth.Truth.assertThat -import kotlin.math.sqrt import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.math.sqrt @RunWith(JUnit4::class) class RunningStatisticsTest { diff --git a/javatests/arcs/core/util/SchedulerTest.kt b/javatests/arcs/core/util/SchedulerTest.kt index b7924cb96b6..5a877e1bd40 100644 --- a/javatests/arcs/core/util/SchedulerTest.kt +++ b/javatests/arcs/core/util/SchedulerTest.kt @@ -14,9 +14,6 @@ package arcs.core.util import arcs.core.util.testutil.LogRule import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertWithMessage -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executors -import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job @@ -31,6 +28,9 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executors +import kotlin.coroutines.CoroutineContext @RunWith(JUnit4::class) class SchedulerTest { diff --git a/javatests/arcs/core/util/performance/CounterStatisticsTest.kt b/javatests/arcs/core/util/performance/CounterStatisticsTest.kt index 41ecddac5a3..001f741b37f 100644 --- a/javatests/arcs/core/util/performance/CounterStatisticsTest.kt +++ b/javatests/arcs/core/util/performance/CounterStatisticsTest.kt @@ -13,10 +13,10 @@ package arcs.core.util.performance import arcs.core.util.RunningStatistics import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class CounterStatisticsTest { diff --git a/javatests/arcs/core/util/performance/CountersTest.kt b/javatests/arcs/core/util/performance/CountersTest.kt index 8e8ea175425..d4656650721 100644 --- a/javatests/arcs/core/util/performance/CountersTest.kt +++ b/javatests/arcs/core/util/performance/CountersTest.kt @@ -12,8 +12,6 @@ package arcs.core.util.performance import com.google.common.truth.Truth.assertThat -import kotlin.random.Random -import kotlin.test.assertFailsWith import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.joinAll import kotlinx.coroutines.launch @@ -21,6 +19,8 @@ import kotlinx.coroutines.test.runBlockingTest import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.random.Random +import kotlin.test.assertFailsWith @Suppress("EXPERIMENTAL_API_USAGE") @RunWith(JUnit4::class) diff --git a/javatests/arcs/flags/BuildFlagsTest.kt b/javatests/arcs/flags/BuildFlagsTest.kt index 0e2df60acff..aeff423fd73 100644 --- a/javatests/arcs/flags/BuildFlagsTest.kt +++ b/javatests/arcs/flags/BuildFlagsTest.kt @@ -1,10 +1,10 @@ package arcs.flags import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class BuildFlagsTest { diff --git a/javatests/arcs/flags/DevModeBuildFlagsTest.kt b/javatests/arcs/flags/DevModeBuildFlagsTest.kt index c00f1eee216..bc8bafca7ef 100644 --- a/javatests/arcs/flags/DevModeBuildFlagsTest.kt +++ b/javatests/arcs/flags/DevModeBuildFlagsTest.kt @@ -1,10 +1,10 @@ package arcs.flags import com.google.common.truth.Truth.assertThat -import kotlin.test.assertFailsWith import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import kotlin.test.assertFailsWith @RunWith(JUnit4::class) class DevModeBuildFlagsTest { diff --git a/javatests/arcs/sdk/HandleUtilsTest.kt b/javatests/arcs/sdk/HandleUtilsTest.kt index 61c22f1675c..6b462ec2e70 100644 --- a/javatests/arcs/sdk/HandleUtilsTest.kt +++ b/javatests/arcs/sdk/HandleUtilsTest.kt @@ -31,7 +31,6 @@ import arcs.core.util.Scheduler import arcs.core.util.testutil.LogRule import arcs.jvm.util.testutil.FakeTime import com.google.common.truth.Truth.assertWithMessage -import java.util.concurrent.Executors import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.Job import kotlinx.coroutines.asCoroutineDispatcher @@ -44,6 +43,7 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import java.util.concurrent.Executors private typealias Person = ReadSdkPerson_Person diff --git a/javatests/arcs/sdk/android/storage/AndroidStorageServiceEndpointTest.kt b/javatests/arcs/sdk/android/storage/AndroidStorageServiceEndpointTest.kt index 350806ceb42..10ea89a1e08 100644 --- a/javatests/arcs/sdk/android/storage/AndroidStorageServiceEndpointTest.kt +++ b/javatests/arcs/sdk/android/storage/AndroidStorageServiceEndpointTest.kt @@ -15,7 +15,6 @@ import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.whenever -import kotlin.test.assertFailsWith import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Deferred @@ -24,6 +23,7 @@ import kotlinx.coroutines.test.runBlockingTest import org.junit.Test import org.junit.runner.RunWith import org.mockito.stubbing.OngoingStubbing +import kotlin.test.assertFailsWith @OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) @RunWith(AndroidJUnit4::class) diff --git a/javatests/arcs/tools/PlanGeneratorTest.kt b/javatests/arcs/tools/PlanGeneratorTest.kt index 01733dbeea5..d646bbb3df3 100644 --- a/javatests/arcs/tools/PlanGeneratorTest.kt +++ b/javatests/arcs/tools/PlanGeneratorTest.kt @@ -350,7 +350,7 @@ class PlanGeneratorTest { singletons = emptyMap(), collections = emptyMap() ) - """.trimIndent() + """.trimIndent() ) } @@ -367,7 +367,7 @@ class PlanGeneratorTest { singletons = mapOf("sku" to arcs.core.data.FieldType.Int), collections = emptyMap() ) - """.trimIndent() + """.trimIndent() ) } @@ -384,7 +384,7 @@ class PlanGeneratorTest { singletons = emptyMap(), collections = mapOf("bananas" to arcs.core.data.FieldType.Text) ) - """.trimIndent() + """.trimIndent() ) } diff --git a/particles/Blackjack/BlackjackTable.kt b/particles/Blackjack/BlackjackTable.kt index 58278d74922..97039bd71a8 100644 --- a/particles/Blackjack/BlackjackTable.kt +++ b/particles/Blackjack/BlackjackTable.kt @@ -6,5 +6,5 @@ class BlackjackTable : AbstractBlackjackTable() { Welcome to the Arcs Casino!

- """.trimIndent() + """.trimIndent() } diff --git a/particles/Blackjack/Dealer.kt b/particles/Blackjack/Dealer.kt index 617f1b53d37..59f79b66c1c 100644 --- a/particles/Blackjack/Dealer.kt +++ b/particles/Blackjack/Dealer.kt @@ -20,7 +20,7 @@ class Dealer : AbstractDealer() { $name: {{hand}} - """.trimIndent() + """.trimIndent() override fun populateModel(slotName: String, model: Map): Map { val desc = handles.hand.fetchAll().joinToString(separator = ":") { diff --git a/particles/Blackjack/Player.kt b/particles/Blackjack/Player.kt index e8f52f4339c..6161c43b609 100644 --- a/particles/Blackjack/Player.kt +++ b/particles/Blackjack/Player.kt @@ -20,7 +20,7 @@ class Player : AbstractPlayer() { $name: {{hand}} - """.trimIndent() + """.trimIndent() override fun populateModel(slotName: String, model: Map): Map { val desc = handles.hand.fetchAll().joinToString(separator = ":") { card -> diff --git a/tools/setup b/tools/setup index cd5f534f72b..af3c14949c5 100755 --- a/tools/setup +++ b/tools/setup @@ -65,7 +65,7 @@ status "4.1. Install useful optional dependencies" (cd $ROOT && npm install --no-save chokidar) || fail 'Failed to install optional dependencies.' status "5. Install ktlint" -(mkdir -p $HOME/bin && cd $HOME/bin && curl -L -s -O https://github.com/pinterest/ktlint/releases/download/0.35.0/ktlint && cd -) || fail 'Failed to install ktlint' +(mkdir -p $HOME/bin && cd $HOME/bin && curl -L -s -O https://github.com/pinterest/ktlint/releases/download/0.39.0/ktlint && cd -) || fail 'Failed to install ktlint' chmod a+x $HOME/bin/ktlint append_once 'export PATH="$HOME/bin:$PATH"' $HOME/.bashrc