From 8fe7577780a8401d1906c0df4e425b247df29dee Mon Sep 17 00:00:00 2001 From: Aaron He Date: Fri, 15 Jun 2018 21:06:57 -0700 Subject: [PATCH 01/27] Update build tools * Gradle 4.8 * Android Gradle plugin 3.1.3 * Ktlint Gradle plugin 4.0.0 * Ktlint 0.23.1 --- build.gradle | 16 +++++----------- demo/build.gradle | 3 +-- .../app/echo/domain/AuthStatusRepository.kt | 1 - .../tinder/app/echo/domain/LoggedInLifecycle.kt | 1 - .../tinder/app/echo/inject/EchoBotComponent.kt | 1 - .../tinder/app/gdax/domain/TransactionBook.kt | 1 - .../app/gdax/domain/TransactionRepository.kt | 1 - .../com/tinder/app/gdax/inject/GdaxComponent.kt | 1 - .../com/tinder/app/gdax/target/GdaxTarget.kt | 1 - .../tinder/app/root/ScarletDemoApplication.kt | 1 - .../com/tinder/app/root/inject/CommonModule.kt | 1 - .../com/tinder/app/root/inject/StethoModule.kt | 1 - gradle/wrapper/gradle-wrapper.properties | 2 +- .../tinder/scarlet/utils/FlowableStreamTest.kt | 1 - .../main/java/com/tinder/scarlet/Lifecycle.kt | 1 - .../src/main/java/com/tinder/scarlet/Stream.kt | 1 - .../java/com/tinder/scarlet/StreamAdapter.kt | 1 - .../main/java/com/tinder/scarlet/WebSocket.kt | 1 - .../com/tinder/scarlet/utils/TypeUtilsTest.kt | 3 --- .../builtin/BuiltInMessageAdapterFactory.kt | 1 - .../builtin/ByteArrayMessageAdapter.kt | 1 - .../messageadapter/builtin/TextMessageAdapter.kt | 1 - .../builtin/BuiltInMessageAdapterFactoryTest.kt | 1 - .../builtin/ByteArrayMessageAdapterTest.kt | 1 - .../builtin/TextMessageAdapterTest.kt | 1 - .../messageadapter/gson/GsonMessageAdapter.kt | 1 - .../gson/GsonMessageAdapterTest.kt | 9 +++------ .../messageadapter/moshi/MoshiMessageAdapter.kt | 1 - .../moshi/MoshiMessageAdapterTest.kt | 5 ++--- .../protobuf/ProtobufMessageAdapterTest.kt | 1 - .../builtin/BuiltInStreamAdapterFactory.kt | 1 - .../builtin/IdentityStreamAdapter.kt | 1 - .../builtin/BuiltInStreamAdapterFactoryTest.kt | 1 - .../builtin/IdentityStreamAdapterTest.kt | 1 - .../rxjava/ObservableStreamAdapter.kt | 1 - .../rxjava/RxJavaStreamAdapterFactory.kt | 1 - .../rxjava2/FlowableStreamAdapter.kt | 1 - .../rxjava2/ObservableStreamAdapter.kt | 1 - .../streamadapter/rxjava2/ObservableTest.kt | 1 - ...ServerOkHttpWebSocketConnectionEstablisher.kt | 1 - .../mockwebserver/MockWebServerUtils.kt | 1 - ...OkHttpClientWebSocketConnectionEstablisher.kt | 1 - .../okhttp/OkHttpWebSocketEventObserver.kt | 1 - .../okhttp/request/StaticUrlRequestFactory.kt | 1 - .../okhttp/OkHttpWebSocketEventObserverTest.kt | 1 - .../okhttp/OkHttpWebSocketIntegrationTest.kt | 1 - .../websocket/okhttp/OkHttpWebSocketTest.kt | 1 - .../request/StaticUrlRequestFactoryTest.kt | 1 - .../src/main/java/com/tinder/scarlet/Scarlet.kt | 1 - .../scarlet/internal/connection/Connection.kt | 1 - .../internal/servicemethod/EventMapper.kt | 4 ++-- .../internal/servicemethod/ServiceMethod.kt | 1 - .../servicemethod/ServiceMethodExecutor.kt | 1 - .../servicemethod/StreamAdapterResolver.kt | 1 - .../scarlet/internal/utils/RuntimePlatform.kt | 10 ++++++++-- .../tinder/scarlet/lifecycle/DefaultLifecycle.kt | 1 - .../scarlet/lifecycle/FlowableLifecycle.kt | 1 - .../scarlet/lifecycle/LifecycleRegistry.kt | 1 - .../scarlet/retry/ExponentialBackoffStrategy.kt | 1 - .../ExponentialWithJitterBackoffStrategy.kt | 1 - .../scarlet/retry/LinearBackoffStrategy.kt | 1 - .../internal/connection/ConnectionFactoryTest.kt | 1 - .../internal/connection/ConnectionTest.kt | 1 - .../connection/LifecycleStateSubscriberTest.kt | 1 - .../connection/WebSocketEventSubscriberTest.kt | 1 - .../internal/servicemethod/EventMapperTest.kt | 1 - .../servicemethod/MessageAdapterResolverTest.kt | 1 - .../ReceiveServiceMethodFactoryTest.kt | 1 - .../servicemethod/ReceiveServiceMethodTest.kt | 1 - .../SendServiceMethodFactoryTest.kt | 1 - .../ServiceMethodExecutorFactoryTest.kt | 1 - .../servicemethod/ServiceMethodExecutorTest.kt | 1 - .../scarlet/lifecycle/DefaultLifecycleTest.kt | 1 - .../scarlet/lifecycle/FlowableLifecycleTest.kt | 1 - .../scarlet/lifecycle/LifecycleRegistryTest.kt | 1 - .../retry/ExponentialBackoffStrategyTest.kt | 1 - ...entialBackoffWithJitterBackoffStrategyTest.kt | 6 ++++-- .../java/com/tinder/statemachine/StateMachine.kt | 2 -- 78 files changed, 26 insertions(+), 102 deletions(-) diff --git a/build.gradle b/build.gradle index 55115d54..968d6076 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:3.1.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.5.4" classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}" @@ -18,28 +18,22 @@ buildscript { } plugins { - id 'org.jlleitschuh.gradle.ktlint' version '2.2.0' + id 'org.jlleitschuh.gradle.ktlint' version '4.0.0' } ktlint { - version = '0.9.2' + version = '0.23.1' } -allprojects { +subprojects { apply plugin: 'org.kordamp.gradle.stats' apply plugin: "com.jfrog.artifactory" group = 'com.tinder.scarlet' repositories { - mavenCentral() - maven { url "https://jitpack.io" } google() jcenter() } } -clean { - delete rootProject.buildDir -} - -apply from: rootProject.file('dependencies.gradle') +apply from: rootProject.file('dependencies.gradle') \ No newline at end of file diff --git a/demo/build.gradle b/demo/build.gradle index 80d62a25..cad1f91e 100755 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -3,8 +3,7 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' repositories { - mavenCentral() - google() + maven { url 'https://jitpack.io' } } android { diff --git a/demo/src/main/java/com/tinder/app/echo/domain/AuthStatusRepository.kt b/demo/src/main/java/com/tinder/app/echo/domain/AuthStatusRepository.kt index e9bb4575..7cda98a2 100644 --- a/demo/src/main/java/com/tinder/app/echo/domain/AuthStatusRepository.kt +++ b/demo/src/main/java/com/tinder/app/echo/domain/AuthStatusRepository.kt @@ -19,5 +19,4 @@ class AuthStatusRepository @Inject constructor() { fun observeAuthStatus(): Flowable = authStatusProcessor fun updateAuthStatus(authStatus: AuthStatus) = authStatusProcessor.onNext(authStatus) - } diff --git a/demo/src/main/java/com/tinder/app/echo/domain/LoggedInLifecycle.kt b/demo/src/main/java/com/tinder/app/echo/domain/LoggedInLifecycle.kt index 836add9d..a9d6d134 100644 --- a/demo/src/main/java/com/tinder/app/echo/domain/LoggedInLifecycle.kt +++ b/demo/src/main/java/com/tinder/app/echo/domain/LoggedInLifecycle.kt @@ -27,5 +27,4 @@ class LoggedInLifecycle constructor( } .subscribe(lifecycleRegistry) } - } diff --git a/demo/src/main/java/com/tinder/app/echo/inject/EchoBotComponent.kt b/demo/src/main/java/com/tinder/app/echo/inject/EchoBotComponent.kt index 90628a29..fe3d97e6 100644 --- a/demo/src/main/java/com/tinder/app/echo/inject/EchoBotComponent.kt +++ b/demo/src/main/java/com/tinder/app/echo/inject/EchoBotComponent.kt @@ -67,5 +67,4 @@ interface EchoBotComponent { interface ComponentProvider { val echoBotComponent: EchoBotComponent } - } diff --git a/demo/src/main/java/com/tinder/app/gdax/domain/TransactionBook.kt b/demo/src/main/java/com/tinder/app/gdax/domain/TransactionBook.kt index f38a64c4..54460ebf 100644 --- a/demo/src/main/java/com/tinder/app/gdax/domain/TransactionBook.kt +++ b/demo/src/main/java/com/tinder/app/gdax/domain/TransactionBook.kt @@ -16,5 +16,4 @@ class TransactionBook( newHistory.transactions[product] = (newHistory.transactions[product] ?: emptyList()) + transaction return newHistory } - } diff --git a/demo/src/main/java/com/tinder/app/gdax/domain/TransactionRepository.kt b/demo/src/main/java/com/tinder/app/gdax/domain/TransactionRepository.kt index 5e951fc0..3773379d 100644 --- a/demo/src/main/java/com/tinder/app/gdax/domain/TransactionRepository.kt +++ b/demo/src/main/java/com/tinder/app/gdax/domain/TransactionRepository.kt @@ -68,5 +68,4 @@ class TransactionRepository @Inject constructor( transactionBookRef.set(transactionBook) transactionBookProcessor.onNext(transactionBook) } - } diff --git a/demo/src/main/java/com/tinder/app/gdax/inject/GdaxComponent.kt b/demo/src/main/java/com/tinder/app/gdax/inject/GdaxComponent.kt index 450eac32..b74b2f4c 100644 --- a/demo/src/main/java/com/tinder/app/gdax/inject/GdaxComponent.kt +++ b/demo/src/main/java/com/tinder/app/gdax/inject/GdaxComponent.kt @@ -73,5 +73,4 @@ interface GdaxComponent { interface ComponentProvider { val gdaxComponent: GdaxComponent } - } diff --git a/demo/src/main/java/com/tinder/app/gdax/target/GdaxTarget.kt b/demo/src/main/java/com/tinder/app/gdax/target/GdaxTarget.kt index dcdb599b..1517452c 100644 --- a/demo/src/main/java/com/tinder/app/gdax/target/GdaxTarget.kt +++ b/demo/src/main/java/com/tinder/app/gdax/target/GdaxTarget.kt @@ -10,5 +10,4 @@ import com.tinder.app.gdax.domain.Transaction interface GdaxTarget { fun showTransactions(product: Product, transactions: List) - } diff --git a/demo/src/main/java/com/tinder/app/root/ScarletDemoApplication.kt b/demo/src/main/java/com/tinder/app/root/ScarletDemoApplication.kt index 5d24cd2c..47e16ced 100755 --- a/demo/src/main/java/com/tinder/app/root/ScarletDemoApplication.kt +++ b/demo/src/main/java/com/tinder/app/root/ScarletDemoApplication.kt @@ -46,5 +46,4 @@ class ScarletDemoApplication : Application(), Timber.plant(Timber.DebugTree()) Stetho.initialize(stethoInitializer) } - } diff --git a/demo/src/main/java/com/tinder/app/root/inject/CommonModule.kt b/demo/src/main/java/com/tinder/app/root/inject/CommonModule.kt index 4827a727..f965f563 100755 --- a/demo/src/main/java/com/tinder/app/root/inject/CommonModule.kt +++ b/demo/src/main/java/com/tinder/app/root/inject/CommonModule.kt @@ -16,5 +16,4 @@ class CommonModule { fun provideApplicationContext(application: Application): Context { return application } - } diff --git a/demo/src/main/java/com/tinder/app/root/inject/StethoModule.kt b/demo/src/main/java/com/tinder/app/root/inject/StethoModule.kt index ef0b0f42..9223979e 100755 --- a/demo/src/main/java/com/tinder/app/root/inject/StethoModule.kt +++ b/demo/src/main/java/com/tinder/app/root/inject/StethoModule.kt @@ -43,5 +43,4 @@ class StethoModule { internal fun provideInspectorModulesProvider(application: Application): InspectorModulesProvider { return Stetho.defaultInspectorModulesProvider(application) } - } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f8d6248b..1b3c553d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip diff --git a/scarlet-core-internal/src/test/java/com/tinder/scarlet/utils/FlowableStreamTest.kt b/scarlet-core-internal/src/test/java/com/tinder/scarlet/utils/FlowableStreamTest.kt index 7f4e2b71..776e7dc1 100644 --- a/scarlet-core-internal/src/test/java/com/tinder/scarlet/utils/FlowableStreamTest.kt +++ b/scarlet-core-internal/src/test/java/com/tinder/scarlet/utils/FlowableStreamTest.kt @@ -71,5 +71,4 @@ internal class FlowableStreamTest { // Then assertThat(processor.hasSubscribers()).isFalse() } - } diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/Lifecycle.kt b/scarlet-core/src/main/java/com/tinder/scarlet/Lifecycle.kt index c0952d95..5e12311b 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/Lifecycle.kt +++ b/scarlet-core/src/main/java/com/tinder/scarlet/Lifecycle.kt @@ -45,4 +45,3 @@ interface Lifecycle : Publisher { object Destroyed : State() } } - diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/Stream.kt b/scarlet-core/src/main/java/com/tinder/scarlet/Stream.kt index ea206e1d..b3a16d60 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/Stream.kt +++ b/scarlet-core/src/main/java/com/tinder/scarlet/Stream.kt @@ -40,5 +40,4 @@ interface Stream : Publisher { fun isDisposed(): Boolean } - } diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/StreamAdapter.kt b/scarlet-core/src/main/java/com/tinder/scarlet/StreamAdapter.kt index ca128731..270a02eb 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/StreamAdapter.kt +++ b/scarlet-core/src/main/java/com/tinder/scarlet/StreamAdapter.kt @@ -28,6 +28,5 @@ interface StreamAdapter { * handled by this factory. */ fun create(type: Type): StreamAdapter - } } diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/WebSocket.kt b/scarlet-core/src/main/java/com/tinder/scarlet/WebSocket.kt index 40103adb..eabe896f 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/WebSocket.kt +++ b/scarlet-core/src/main/java/com/tinder/scarlet/WebSocket.kt @@ -79,5 +79,4 @@ interface WebSocket { interface Factory { fun create(): WebSocket } - } diff --git a/scarlet-core/src/test/java/com/tinder/scarlet/utils/TypeUtilsTest.kt b/scarlet-core/src/test/java/com/tinder/scarlet/utils/TypeUtilsTest.kt index 7c987af4..4b4b7194 100644 --- a/scarlet-core/src/test/java/com/tinder/scarlet/utils/TypeUtilsTest.kt +++ b/scarlet-core/src/test/java/com/tinder/scarlet/utils/TypeUtilsTest.kt @@ -70,7 +70,6 @@ internal class TypeUtilsTest { private fun param(type: Type, expectedHasUnresolvableType: Boolean) = arrayOf(type, expectedHasUnresolvableType) } - } @RunWith(Parameterized::class) @@ -102,7 +101,6 @@ internal class TypeUtilsTest { private fun param(type: ParameterizedType, expectedParameterUpperBound: Array) = arrayOf(type, expectedParameterUpperBound) } - } private companion object { @@ -146,5 +144,4 @@ internal class TypeUtilsTest { } } } - } diff --git a/scarlet-message-adapter-builtin/src/main/java/com/tinder/scarlet/messageadapter/builtin/BuiltInMessageAdapterFactory.kt b/scarlet-message-adapter-builtin/src/main/java/com/tinder/scarlet/messageadapter/builtin/BuiltInMessageAdapterFactory.kt index 396ad2b2..8d66a01a 100644 --- a/scarlet-message-adapter-builtin/src/main/java/com/tinder/scarlet/messageadapter/builtin/BuiltInMessageAdapterFactory.kt +++ b/scarlet-message-adapter-builtin/src/main/java/com/tinder/scarlet/messageadapter/builtin/BuiltInMessageAdapterFactory.kt @@ -15,5 +15,4 @@ class BuiltInMessageAdapterFactory : MessageAdapter.Factory { ByteArray::class.java -> ByteArrayMessageAdapter() else -> throw IllegalArgumentException("Type is not supported by this MessageAdapterFactory: $type") } - } diff --git a/scarlet-message-adapter-builtin/src/main/java/com/tinder/scarlet/messageadapter/builtin/ByteArrayMessageAdapter.kt b/scarlet-message-adapter-builtin/src/main/java/com/tinder/scarlet/messageadapter/builtin/ByteArrayMessageAdapter.kt index 30a93d12..e09746e7 100644 --- a/scarlet-message-adapter-builtin/src/main/java/com/tinder/scarlet/messageadapter/builtin/ByteArrayMessageAdapter.kt +++ b/scarlet-message-adapter-builtin/src/main/java/com/tinder/scarlet/messageadapter/builtin/ByteArrayMessageAdapter.kt @@ -15,5 +15,4 @@ class ByteArrayMessageAdapter : MessageAdapter { } override fun toMessage(data: ByteArray): Message = Message.Bytes(data) - } diff --git a/scarlet-message-adapter-builtin/src/main/java/com/tinder/scarlet/messageadapter/builtin/TextMessageAdapter.kt b/scarlet-message-adapter-builtin/src/main/java/com/tinder/scarlet/messageadapter/builtin/TextMessageAdapter.kt index 7d3f060e..ed2fa782 100644 --- a/scarlet-message-adapter-builtin/src/main/java/com/tinder/scarlet/messageadapter/builtin/TextMessageAdapter.kt +++ b/scarlet-message-adapter-builtin/src/main/java/com/tinder/scarlet/messageadapter/builtin/TextMessageAdapter.kt @@ -15,5 +15,4 @@ class TextMessageAdapter : MessageAdapter { } override fun toMessage(data: String): Message = Message.Text(data) - } diff --git a/scarlet-message-adapter-builtin/src/test/java/com/tinder/scarlet/messageadapter/builtin/BuiltInMessageAdapterFactoryTest.kt b/scarlet-message-adapter-builtin/src/test/java/com/tinder/scarlet/messageadapter/builtin/BuiltInMessageAdapterFactoryTest.kt index 63aee894..0451ca7e 100644 --- a/scarlet-message-adapter-builtin/src/test/java/com/tinder/scarlet/messageadapter/builtin/BuiltInMessageAdapterFactoryTest.kt +++ b/scarlet-message-adapter-builtin/src/test/java/com/tinder/scarlet/messageadapter/builtin/BuiltInMessageAdapterFactoryTest.kt @@ -51,5 +51,4 @@ internal class BuiltInMessageAdapterFactoryTest { Collection::class.java ) } - } diff --git a/scarlet-message-adapter-builtin/src/test/java/com/tinder/scarlet/messageadapter/builtin/ByteArrayMessageAdapterTest.kt b/scarlet-message-adapter-builtin/src/test/java/com/tinder/scarlet/messageadapter/builtin/ByteArrayMessageAdapterTest.kt index 62d16694..1b36339e 100644 --- a/scarlet-message-adapter-builtin/src/test/java/com/tinder/scarlet/messageadapter/builtin/ByteArrayMessageAdapterTest.kt +++ b/scarlet-message-adapter-builtin/src/test/java/com/tinder/scarlet/messageadapter/builtin/ByteArrayMessageAdapterTest.kt @@ -38,5 +38,4 @@ internal class ByteArrayMessageAdapterTest { val (adaptedBytes) = (adaptedMessage as Message.Bytes) assertThat(adaptedBytes).isEqualTo(bytes) } - } diff --git a/scarlet-message-adapter-builtin/src/test/java/com/tinder/scarlet/messageadapter/builtin/TextMessageAdapterTest.kt b/scarlet-message-adapter-builtin/src/test/java/com/tinder/scarlet/messageadapter/builtin/TextMessageAdapterTest.kt index 89b7512c..28577d35 100644 --- a/scarlet-message-adapter-builtin/src/test/java/com/tinder/scarlet/messageadapter/builtin/TextMessageAdapterTest.kt +++ b/scarlet-message-adapter-builtin/src/test/java/com/tinder/scarlet/messageadapter/builtin/TextMessageAdapterTest.kt @@ -37,5 +37,4 @@ internal class TextMessageAdapterTest { // Then assertThat(adaptedMessage).isEqualTo(textMessage) } - } diff --git a/scarlet-message-adapter-gson/src/main/java/com/tinder/scarlet/messageadapter/gson/GsonMessageAdapter.kt b/scarlet-message-adapter-gson/src/main/java/com/tinder/scarlet/messageadapter/gson/GsonMessageAdapter.kt index 5c9346f0..592377c7 100644 --- a/scarlet-message-adapter-gson/src/main/java/com/tinder/scarlet/messageadapter/gson/GsonMessageAdapter.kt +++ b/scarlet-message-adapter-gson/src/main/java/com/tinder/scarlet/messageadapter/gson/GsonMessageAdapter.kt @@ -55,5 +55,4 @@ class GsonMessageAdapter private constructor( private val DEFAULT_GSON = Gson() } } - } diff --git a/scarlet-message-adapter-gson/src/test/java/com/tinder/scarlet/messageadapter/gson/GsonMessageAdapterTest.kt b/scarlet-message-adapter-gson/src/test/java/com/tinder/scarlet/messageadapter/gson/GsonMessageAdapterTest.kt index 526c8fad..a53bc991 100644 --- a/scarlet-message-adapter-gson/src/test/java/com/tinder/scarlet/messageadapter/gson/GsonMessageAdapterTest.kt +++ b/scarlet-message-adapter-gson/src/test/java/com/tinder/scarlet/messageadapter/gson/GsonMessageAdapterTest.kt @@ -10,17 +10,17 @@ import com.google.gson.TypeAdapter import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonToken import com.google.gson.stream.JsonWriter -import com.tinder.scarlet.WebSocket.Event +import com.tinder.scarlet.Lifecycle import com.tinder.scarlet.Message import com.tinder.scarlet.MessageAdapter import com.tinder.scarlet.Scarlet import com.tinder.scarlet.Stream -import com.tinder.scarlet.Lifecycle +import com.tinder.scarlet.WebSocket.Event import com.tinder.scarlet.lifecycle.LifecycleRegistry import com.tinder.scarlet.testutils.TestStreamObserver +import com.tinder.scarlet.testutils.any import com.tinder.scarlet.testutils.containingText import com.tinder.scarlet.testutils.test -import com.tinder.scarlet.testutils.any import com.tinder.scarlet.websocket.mockwebserver.newWebSocketFactory import com.tinder.scarlet.websocket.okhttp.newWebSocketFactory import com.tinder.scarlet.ws.Receive @@ -225,7 +225,6 @@ internal class GsonMessageAdapterTest { else -> throw IllegalArgumentException("$type is not supported.") } } - } internal interface Service { @@ -244,7 +243,5 @@ internal class GsonMessageAdapterTest { @Send fun sendAnInterface(impl: AnInterface): Boolean } - } - } diff --git a/scarlet-message-adapter-moshi/src/main/java/com/tinder/scarlet/messageadapter/moshi/MoshiMessageAdapter.kt b/scarlet-message-adapter-moshi/src/main/java/com/tinder/scarlet/messageadapter/moshi/MoshiMessageAdapter.kt index e3224f2e..fadded0b 100755 --- a/scarlet-message-adapter-moshi/src/main/java/com/tinder/scarlet/messageadapter/moshi/MoshiMessageAdapter.kt +++ b/scarlet-message-adapter-moshi/src/main/java/com/tinder/scarlet/messageadapter/moshi/MoshiMessageAdapter.kt @@ -83,7 +83,6 @@ class MoshiMessageAdapter private constructor( val serializeNull: Boolean = false, val failOnUnknown: Boolean = false ) - } private companion object { diff --git a/scarlet-message-adapter-moshi/src/test/java/com/tinder/scarlet/messageadapter/moshi/MoshiMessageAdapterTest.kt b/scarlet-message-adapter-moshi/src/test/java/com/tinder/scarlet/messageadapter/moshi/MoshiMessageAdapterTest.kt index eec8a633..107e1040 100644 --- a/scarlet-message-adapter-moshi/src/test/java/com/tinder/scarlet/messageadapter/moshi/MoshiMessageAdapterTest.kt +++ b/scarlet-message-adapter-moshi/src/test/java/com/tinder/scarlet/messageadapter/moshi/MoshiMessageAdapterTest.kt @@ -302,7 +302,8 @@ internal class MoshiMessageAdapterTest { class VerifyJsonQualifierJsonAdapterFactory : JsonAdapter.Factory { override fun create( - type: Type, annotations: Set, + type: Type, + annotations: Set, moshi: Moshi ): JsonAdapter<*>? { for (annotation in annotations) { @@ -381,7 +382,5 @@ internal class MoshiMessageAdapterTest { @NonQualifer fun observeAnnotatedString(): Stream } - } - } diff --git a/scarlet-message-adapter-protobuf/src/test/java/com/tinder/scarlet/messageadapter/protobuf/ProtobufMessageAdapterTest.kt b/scarlet-message-adapter-protobuf/src/test/java/com/tinder/scarlet/messageadapter/protobuf/ProtobufMessageAdapterTest.kt index db627554..fece9868 100644 --- a/scarlet-message-adapter-protobuf/src/test/java/com/tinder/scarlet/messageadapter/protobuf/ProtobufMessageAdapterTest.kt +++ b/scarlet-message-adapter-protobuf/src/test/java/com/tinder/scarlet/messageadapter/protobuf/ProtobufMessageAdapterTest.kt @@ -218,6 +218,5 @@ internal class ProtobufMessageAdapterTest { @Receive fun receiveWrongClassDeserialization(): Stream> } - } } diff --git a/scarlet-stream-adapter-builtin/src/main/java/com/tinder/scarlet/streamadapter/builtin/BuiltInStreamAdapterFactory.kt b/scarlet-stream-adapter-builtin/src/main/java/com/tinder/scarlet/streamadapter/builtin/BuiltInStreamAdapterFactory.kt index 559bffdd..40248412 100644 --- a/scarlet-stream-adapter-builtin/src/main/java/com/tinder/scarlet/streamadapter/builtin/BuiltInStreamAdapterFactory.kt +++ b/scarlet-stream-adapter-builtin/src/main/java/com/tinder/scarlet/streamadapter/builtin/BuiltInStreamAdapterFactory.kt @@ -15,5 +15,4 @@ class BuiltInStreamAdapterFactory : StreamAdapter.Factory { Stream::class.java -> IdentityStreamAdapter() else -> throw IllegalArgumentException("$type is not supported.") } - } diff --git a/scarlet-stream-adapter-builtin/src/main/java/com/tinder/scarlet/streamadapter/builtin/IdentityStreamAdapter.kt b/scarlet-stream-adapter-builtin/src/main/java/com/tinder/scarlet/streamadapter/builtin/IdentityStreamAdapter.kt index 9aaf8c1a..8306a2d3 100644 --- a/scarlet-stream-adapter-builtin/src/main/java/com/tinder/scarlet/streamadapter/builtin/IdentityStreamAdapter.kt +++ b/scarlet-stream-adapter-builtin/src/main/java/com/tinder/scarlet/streamadapter/builtin/IdentityStreamAdapter.kt @@ -10,5 +10,4 @@ import com.tinder.scarlet.StreamAdapter class IdentityStreamAdapter : StreamAdapter> { override fun adapt(stream: Stream): Stream = stream - } diff --git a/scarlet-stream-adapter-builtin/src/test/java/com/tinder/scarlet/streamadapter/builtin/BuiltInStreamAdapterFactoryTest.kt b/scarlet-stream-adapter-builtin/src/test/java/com/tinder/scarlet/streamadapter/builtin/BuiltInStreamAdapterFactoryTest.kt index 7608f8e0..ed56f455 100644 --- a/scarlet-stream-adapter-builtin/src/test/java/com/tinder/scarlet/streamadapter/builtin/BuiltInStreamAdapterFactoryTest.kt +++ b/scarlet-stream-adapter-builtin/src/test/java/com/tinder/scarlet/streamadapter/builtin/BuiltInStreamAdapterFactoryTest.kt @@ -44,5 +44,4 @@ internal class BuiltInStreamAdapterFactoryTest { Collection::class.java ) } - } diff --git a/scarlet-stream-adapter-builtin/src/test/java/com/tinder/scarlet/streamadapter/builtin/IdentityStreamAdapterTest.kt b/scarlet-stream-adapter-builtin/src/test/java/com/tinder/scarlet/streamadapter/builtin/IdentityStreamAdapterTest.kt index 85e1b0d5..cc513e79 100644 --- a/scarlet-stream-adapter-builtin/src/test/java/com/tinder/scarlet/streamadapter/builtin/IdentityStreamAdapterTest.kt +++ b/scarlet-stream-adapter-builtin/src/test/java/com/tinder/scarlet/streamadapter/builtin/IdentityStreamAdapterTest.kt @@ -24,5 +24,4 @@ internal class IdentityStreamAdapterTest { // Then assertThat(adaptedStream).isSameAs(stream) } - } diff --git a/scarlet-stream-adapter-rxjava/src/main/java/com/tinder/scarlet/streamadapter/rxjava/ObservableStreamAdapter.kt b/scarlet-stream-adapter-rxjava/src/main/java/com/tinder/scarlet/streamadapter/rxjava/ObservableStreamAdapter.kt index 7edb9955..5f660619 100644 --- a/scarlet-stream-adapter-rxjava/src/main/java/com/tinder/scarlet/streamadapter/rxjava/ObservableStreamAdapter.kt +++ b/scarlet-stream-adapter-rxjava/src/main/java/com/tinder/scarlet/streamadapter/rxjava/ObservableStreamAdapter.kt @@ -35,5 +35,4 @@ class ObservableStreamAdapter : StreamAdapter> { } } } - } diff --git a/scarlet-stream-adapter-rxjava/src/main/java/com/tinder/scarlet/streamadapter/rxjava/RxJavaStreamAdapterFactory.kt b/scarlet-stream-adapter-rxjava/src/main/java/com/tinder/scarlet/streamadapter/rxjava/RxJavaStreamAdapterFactory.kt index 83653ce7..86a824ca 100755 --- a/scarlet-stream-adapter-rxjava/src/main/java/com/tinder/scarlet/streamadapter/rxjava/RxJavaStreamAdapterFactory.kt +++ b/scarlet-stream-adapter-rxjava/src/main/java/com/tinder/scarlet/streamadapter/rxjava/RxJavaStreamAdapterFactory.kt @@ -18,5 +18,4 @@ class RxJavaStreamAdapterFactory : StreamAdapter.Factory { Observable::class.java -> ObservableStreamAdapter() else -> throw IllegalArgumentException() } - } diff --git a/scarlet-stream-adapter-rxjava2/src/main/java/com/tinder/scarlet/streamadapter/rxjava2/FlowableStreamAdapter.kt b/scarlet-stream-adapter-rxjava2/src/main/java/com/tinder/scarlet/streamadapter/rxjava2/FlowableStreamAdapter.kt index 08b9763a..12c2333b 100644 --- a/scarlet-stream-adapter-rxjava2/src/main/java/com/tinder/scarlet/streamadapter/rxjava2/FlowableStreamAdapter.kt +++ b/scarlet-stream-adapter-rxjava2/src/main/java/com/tinder/scarlet/streamadapter/rxjava2/FlowableStreamAdapter.kt @@ -11,5 +11,4 @@ import io.reactivex.Flowable class FlowableStreamAdapter : StreamAdapter> { override fun adapt(stream: Stream): Flowable = Flowable.fromPublisher(stream) - } diff --git a/scarlet-stream-adapter-rxjava2/src/main/java/com/tinder/scarlet/streamadapter/rxjava2/ObservableStreamAdapter.kt b/scarlet-stream-adapter-rxjava2/src/main/java/com/tinder/scarlet/streamadapter/rxjava2/ObservableStreamAdapter.kt index 09f50a77..5fd5b725 100644 --- a/scarlet-stream-adapter-rxjava2/src/main/java/com/tinder/scarlet/streamadapter/rxjava2/ObservableStreamAdapter.kt +++ b/scarlet-stream-adapter-rxjava2/src/main/java/com/tinder/scarlet/streamadapter/rxjava2/ObservableStreamAdapter.kt @@ -11,5 +11,4 @@ import io.reactivex.Observable class ObservableStreamAdapter : StreamAdapter> { override fun adapt(stream: Stream): Observable = Observable.fromPublisher(stream) - } diff --git a/scarlet-stream-adapter-rxjava2/src/test/java/com/tinder/scarlet/streamadapter/rxjava2/ObservableTest.kt b/scarlet-stream-adapter-rxjava2/src/test/java/com/tinder/scarlet/streamadapter/rxjava2/ObservableTest.kt index 28c36566..07d89dc6 100644 --- a/scarlet-stream-adapter-rxjava2/src/test/java/com/tinder/scarlet/streamadapter/rxjava2/ObservableTest.kt +++ b/scarlet-stream-adapter-rxjava2/src/test/java/com/tinder/scarlet/streamadapter/rxjava2/ObservableTest.kt @@ -140,5 +140,4 @@ class ObservableTest { @Send fun sendBytesAndConfirm(message: ByteArray): Boolean } - } diff --git a/scarlet-websocket-mockwebserver/src/main/java/com/tinder/scarlet/websocket/mockwebserver/MockWebServerOkHttpWebSocketConnectionEstablisher.kt b/scarlet-websocket-mockwebserver/src/main/java/com/tinder/scarlet/websocket/mockwebserver/MockWebServerOkHttpWebSocketConnectionEstablisher.kt index bf2bc157..f1f3bd85 100644 --- a/scarlet-websocket-mockwebserver/src/main/java/com/tinder/scarlet/websocket/mockwebserver/MockWebServerOkHttpWebSocketConnectionEstablisher.kt +++ b/scarlet-websocket-mockwebserver/src/main/java/com/tinder/scarlet/websocket/mockwebserver/MockWebServerOkHttpWebSocketConnectionEstablisher.kt @@ -16,5 +16,4 @@ class MockWebServerOkHttpWebSocketConnectionEstablisher( override fun establishConnection(webSocketListener: WebSocketListener) { mockWebServer.enqueue(MockResponse().withWebSocketUpgrade(webSocketListener)) } - } diff --git a/scarlet-websocket-mockwebserver/src/main/java/com/tinder/scarlet/websocket/mockwebserver/MockWebServerUtils.kt b/scarlet-websocket-mockwebserver/src/main/java/com/tinder/scarlet/websocket/mockwebserver/MockWebServerUtils.kt index 9969265e..a89762a3 100644 --- a/scarlet-websocket-mockwebserver/src/main/java/com/tinder/scarlet/websocket/mockwebserver/MockWebServerUtils.kt +++ b/scarlet-websocket-mockwebserver/src/main/java/com/tinder/scarlet/websocket/mockwebserver/MockWebServerUtils.kt @@ -12,4 +12,3 @@ import okhttp3.mockwebserver.MockWebServer fun MockWebServer.newWebSocketFactory(): WebSocket.Factory = OkHttpWebSocket.Factory(MockWebServerOkHttpWebSocketConnectionEstablisher(this)) - diff --git a/scarlet-websocket-okhttp/src/main/java/com/tinder/scarlet/websocket/okhttp/OkHttpClientWebSocketConnectionEstablisher.kt b/scarlet-websocket-okhttp/src/main/java/com/tinder/scarlet/websocket/okhttp/OkHttpClientWebSocketConnectionEstablisher.kt index 5b901b11..69bb565f 100644 --- a/scarlet-websocket-okhttp/src/main/java/com/tinder/scarlet/websocket/okhttp/OkHttpClientWebSocketConnectionEstablisher.kt +++ b/scarlet-websocket-okhttp/src/main/java/com/tinder/scarlet/websocket/okhttp/OkHttpClientWebSocketConnectionEstablisher.kt @@ -17,5 +17,4 @@ class OkHttpClientWebSocketConnectionEstablisher( val request = requestFactory.createRequest() okHttpClient.newWebSocket(request, webSocketListener) } - } diff --git a/scarlet-websocket-okhttp/src/main/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketEventObserver.kt b/scarlet-websocket-okhttp/src/main/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketEventObserver.kt index f2596bdc..cbc5154e 100644 --- a/scarlet-websocket-okhttp/src/main/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketEventObserver.kt +++ b/scarlet-websocket-okhttp/src/main/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketEventObserver.kt @@ -37,5 +37,4 @@ internal class OkHttpWebSocketEventObserver : WebSocketListener() { override fun onFailure(webSocket: okhttp3.WebSocket, t: Throwable, response: Response?) = processor.onNext(WebSocket.Event.OnConnectionFailed(t)) - } diff --git a/scarlet-websocket-okhttp/src/main/java/com/tinder/scarlet/websocket/okhttp/request/StaticUrlRequestFactory.kt b/scarlet-websocket-okhttp/src/main/java/com/tinder/scarlet/websocket/okhttp/request/StaticUrlRequestFactory.kt index a9b80f14..ff0adf5b 100644 --- a/scarlet-websocket-okhttp/src/main/java/com/tinder/scarlet/websocket/okhttp/request/StaticUrlRequestFactory.kt +++ b/scarlet-websocket-okhttp/src/main/java/com/tinder/scarlet/websocket/okhttp/request/StaticUrlRequestFactory.kt @@ -16,5 +16,4 @@ internal class StaticUrlRequestFactory( override fun createRequest(): Request = Request.Builder() .url(url) .build() - } diff --git a/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketEventObserverTest.kt b/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketEventObserverTest.kt index f35d120a..55bf570a 100644 --- a/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketEventObserverTest.kt +++ b/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketEventObserverTest.kt @@ -51,5 +51,4 @@ internal class OkHttpWebSocketEventObserverTest { WebSocket.Event.OnConnectionFailed(throwable) ) } - } diff --git a/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketIntegrationTest.kt b/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketIntegrationTest.kt index 7452591c..6c4c5089 100644 --- a/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketIntegrationTest.kt +++ b/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketIntegrationTest.kt @@ -233,5 +233,4 @@ internal class OkHttpWebSocketIntegrationTest { @Send fun sendBytesAndConfirm(message: ByteArray): Boolean } - } diff --git a/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketTest.kt b/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketTest.kt index 49b60c37..8c43ab7e 100644 --- a/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketTest.kt +++ b/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketTest.kt @@ -180,5 +180,4 @@ internal class OkHttpWebSocketTest { // Then then(webSocketHolder).should().cancel() } - } diff --git a/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/request/StaticUrlRequestFactoryTest.kt b/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/request/StaticUrlRequestFactoryTest.kt index a1bd9572..6ab17ace 100644 --- a/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/request/StaticUrlRequestFactoryTest.kt +++ b/scarlet-websocket-okhttp/src/test/java/com/tinder/scarlet/websocket/okhttp/request/StaticUrlRequestFactoryTest.kt @@ -21,5 +21,4 @@ internal class StaticUrlRequestFactoryTest { // Then assertThat(request1.url()).isEqualTo(request2.url()) } - } diff --git a/scarlet/src/main/java/com/tinder/scarlet/Scarlet.kt b/scarlet/src/main/java/com/tinder/scarlet/Scarlet.kt index dbe5c893..f84a164f 100644 --- a/scarlet/src/main/java/com/tinder/scarlet/Scarlet.kt +++ b/scarlet/src/main/java/com/tinder/scarlet/Scarlet.kt @@ -199,5 +199,4 @@ class Scarlet internal constructor( private val DEFAULT_SCHEDULER = Schedulers.computation() // TODO same thread option for debugging } } - } diff --git a/scarlet/src/main/java/com/tinder/scarlet/internal/connection/Connection.kt b/scarlet/src/main/java/com/tinder/scarlet/internal/connection/Connection.kt index 321667ab..dd61f9d5 100644 --- a/scarlet/src/main/java/com/tinder/scarlet/internal/connection/Connection.kt +++ b/scarlet/src/main/java/com/tinder/scarlet/internal/connection/Connection.kt @@ -218,5 +218,4 @@ internal class Connection( private fun createSharedLifecycle() = LifecycleRegistry() .apply { lifecycle.subscribe(this) } } - } diff --git a/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/EventMapper.kt b/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/EventMapper.kt index 5a27d25c..233f9ffb 100644 --- a/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/EventMapper.kt +++ b/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/EventMapper.kt @@ -127,7 +127,8 @@ internal sealed class EventMapper { } private fun resolveMessageAdapter( - returnType: ParameterizedType, annotations: Array + returnType: ParameterizedType, + annotations: Array ): MessageAdapter { val receivingType = returnType.getFirstTypeArgument() val messageType = when (receivingType.getRawType()) { @@ -136,7 +137,6 @@ internal sealed class EventMapper { } return messageAdapterResolver.resolve(messageType, annotations) } - } companion object { diff --git a/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/ServiceMethod.kt b/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/ServiceMethod.kt index 5fe4a7e6..16dce50a 100644 --- a/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/ServiceMethod.kt +++ b/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/ServiceMethod.kt @@ -106,5 +106,4 @@ internal sealed class ServiceMethod { private fun Method.getFirstParameterAnnotations(): Array = parameterAnnotations.first() } - } diff --git a/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/ServiceMethodExecutor.kt b/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/ServiceMethodExecutor.kt index a822f8e6..71a08ae0 100644 --- a/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/ServiceMethodExecutor.kt +++ b/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/ServiceMethodExecutor.kt @@ -53,6 +53,5 @@ internal class ServiceMethodExecutor( is Receive -> receiveServiceMethodFactory else -> null } - } } diff --git a/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/StreamAdapterResolver.kt b/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/StreamAdapterResolver.kt index a9fce1df..bc58d0eb 100644 --- a/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/StreamAdapterResolver.kt +++ b/scarlet/src/main/java/com/tinder/scarlet/internal/servicemethod/StreamAdapterResolver.kt @@ -25,5 +25,4 @@ internal class StreamAdapterResolver( val compositeException = CompositeException(*throwables.toTypedArray()) throw IllegalStateException("Cannot resolve stream adapter for type $type.", compositeException) } - } diff --git a/scarlet/src/main/java/com/tinder/scarlet/internal/utils/RuntimePlatform.kt b/scarlet/src/main/java/com/tinder/scarlet/internal/utils/RuntimePlatform.kt index 29724141..1600f086 100644 --- a/scarlet/src/main/java/com/tinder/scarlet/internal/utils/RuntimePlatform.kt +++ b/scarlet/src/main/java/com/tinder/scarlet/internal/utils/RuntimePlatform.kt @@ -12,7 +12,10 @@ internal sealed class RuntimePlatform { open fun isDefaultMethod(method: Method): Boolean = false open fun invokeDefaultMethod( - method: Method, declaringClass: Class<*>, proxy: Any, vararg args: Array? + method: Method, + declaringClass: Class<*>, + proxy: Any, + vararg args: Array? ): Any = throw UnsupportedOperationException() @@ -22,7 +25,10 @@ internal sealed class RuntimePlatform { override fun isDefaultMethod(method: Method): Boolean = method.isDefault override fun invokeDefaultMethod( - method: Method, declaringClass: Class<*>, proxy: Any, vararg args: Array? + method: Method, + declaringClass: Class<*>, + proxy: Any, + vararg args: Array? ): Any { // Because the service interface might not be public, we need to use a MethodHandle lookup // that ignores the visibility of the declaringClass. diff --git a/scarlet/src/main/java/com/tinder/scarlet/lifecycle/DefaultLifecycle.kt b/scarlet/src/main/java/com/tinder/scarlet/lifecycle/DefaultLifecycle.kt index bb0130cb..081e66a3 100644 --- a/scarlet/src/main/java/com/tinder/scarlet/lifecycle/DefaultLifecycle.kt +++ b/scarlet/src/main/java/com/tinder/scarlet/lifecycle/DefaultLifecycle.kt @@ -13,5 +13,4 @@ internal class DefaultLifecycle( init { lifecycleRegistry.onNext(Lifecycle.State.Started) } - } diff --git a/scarlet/src/main/java/com/tinder/scarlet/lifecycle/FlowableLifecycle.kt b/scarlet/src/main/java/com/tinder/scarlet/lifecycle/FlowableLifecycle.kt index e007b882..f065820d 100644 --- a/scarlet/src/main/java/com/tinder/scarlet/lifecycle/FlowableLifecycle.kt +++ b/scarlet/src/main/java/com/tinder/scarlet/lifecycle/FlowableLifecycle.kt @@ -26,5 +26,4 @@ internal class FlowableLifecycle( .map(List>::combine) return FlowableLifecycle(flowable, scheduler) } - } diff --git a/scarlet/src/main/java/com/tinder/scarlet/lifecycle/LifecycleRegistry.kt b/scarlet/src/main/java/com/tinder/scarlet/lifecycle/LifecycleRegistry.kt index 1d96726f..3a4b8962 100644 --- a/scarlet/src/main/java/com/tinder/scarlet/lifecycle/LifecycleRegistry.kt +++ b/scarlet/src/main/java/com/tinder/scarlet/lifecycle/LifecycleRegistry.kt @@ -78,4 +78,3 @@ class LifecycleRegistry internal constructor( } } } - diff --git a/scarlet/src/main/java/com/tinder/scarlet/retry/ExponentialBackoffStrategy.kt b/scarlet/src/main/java/com/tinder/scarlet/retry/ExponentialBackoffStrategy.kt index ee2753a5..98eeac82 100644 --- a/scarlet/src/main/java/com/tinder/scarlet/retry/ExponentialBackoffStrategy.kt +++ b/scarlet/src/main/java/com/tinder/scarlet/retry/ExponentialBackoffStrategy.kt @@ -21,5 +21,4 @@ class ExponentialBackoffStrategy( initialDurationMillis.toDouble() * Math.pow(2.0, retryCount.toDouble()) ) .toLong() - } diff --git a/scarlet/src/main/java/com/tinder/scarlet/retry/ExponentialWithJitterBackoffStrategy.kt b/scarlet/src/main/java/com/tinder/scarlet/retry/ExponentialWithJitterBackoffStrategy.kt index 1f3dfa24..707adb3a 100644 --- a/scarlet/src/main/java/com/tinder/scarlet/retry/ExponentialWithJitterBackoffStrategy.kt +++ b/scarlet/src/main/java/com/tinder/scarlet/retry/ExponentialWithJitterBackoffStrategy.kt @@ -25,5 +25,4 @@ class ExponentialWithJitterBackoffStrategy( private fun Long.withJitter(): Long = (0..this).random() private fun ClosedRange.random() = random.nextInt((endInclusive - start).toInt()) + start - } diff --git a/scarlet/src/main/java/com/tinder/scarlet/retry/LinearBackoffStrategy.kt b/scarlet/src/main/java/com/tinder/scarlet/retry/LinearBackoffStrategy.kt index bfd449ed..8c8792bd 100644 --- a/scarlet/src/main/java/com/tinder/scarlet/retry/LinearBackoffStrategy.kt +++ b/scarlet/src/main/java/com/tinder/scarlet/retry/LinearBackoffStrategy.kt @@ -13,5 +13,4 @@ class LinearBackoffStrategy( } override fun backoffDurationMillisAt(retryCount: Int): Long = durationMillis - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/internal/connection/ConnectionFactoryTest.kt b/scarlet/src/test/java/com/tinder/scarlet/internal/connection/ConnectionFactoryTest.kt index 3e11ff7f..cb938f1f 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/internal/connection/ConnectionFactoryTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/internal/connection/ConnectionFactoryTest.kt @@ -31,5 +31,4 @@ internal class ConnectionFactoryTest { // Then assertThat(connection1.stateManager.lifecycle).isEqualTo(connection2.stateManager.lifecycle) } - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/internal/connection/ConnectionTest.kt b/scarlet/src/test/java/com/tinder/scarlet/internal/connection/ConnectionTest.kt index 1aee4355..c6defdbe 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/internal/connection/ConnectionTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/internal/connection/ConnectionTest.kt @@ -61,5 +61,4 @@ internal class ConnectionTest { // Then then(webSocket).should().send(message) } - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/internal/connection/LifecycleStateSubscriberTest.kt b/scarlet/src/test/java/com/tinder/scarlet/internal/connection/LifecycleStateSubscriberTest.kt index c4b81666..88e7aaa3 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/internal/connection/LifecycleStateSubscriberTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/internal/connection/LifecycleStateSubscriberTest.kt @@ -80,5 +80,4 @@ internal class LifecycleStateSubscriberTest { assertThatExceptionOfType(RuntimeException::class.java) .isThrownBy { flowable.subscribe(lifecycleStateSubscriber) } } - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/internal/connection/WebSocketEventSubscriberTest.kt b/scarlet/src/test/java/com/tinder/scarlet/internal/connection/WebSocketEventSubscriberTest.kt index feec1ebe..ef12033d 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/internal/connection/WebSocketEventSubscriberTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/internal/connection/WebSocketEventSubscriberTest.kt @@ -56,5 +56,4 @@ internal class WebSocketEventSubscriberTest { assertThatExceptionOfType(RuntimeException::class.java) .isThrownBy { flowable.subscribe(webSocketEventSubscriber) } } - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/EventMapperTest.kt b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/EventMapperTest.kt index d8b84615..359ff57d 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/EventMapperTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/EventMapperTest.kt @@ -389,6 +389,5 @@ internal class EventMapperTest { ON_LIFECYCLE_TERMINATED, ON_STATE_CHANGE_TO_DESTROYED ) - } } diff --git a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/MessageAdapterResolverTest.kt b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/MessageAdapterResolverTest.kt index 37e9f1cb..5db8ab7b 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/MessageAdapterResolverTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/MessageAdapterResolverTest.kt @@ -77,5 +77,4 @@ internal class MessageAdapterResolverTest { } .withMessageContaining("Cannot resolve message adapter") } - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ReceiveServiceMethodFactoryTest.kt b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ReceiveServiceMethodFactoryTest.kt index 09567041..c1f21e17 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ReceiveServiceMethodFactoryTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ReceiveServiceMethodFactoryTest.kt @@ -196,5 +196,4 @@ internal class ReceiveServiceMethodFactoryTest { private inline fun param() = arrayOf(T::class.java.onlyMethod(), R::class.java) } } - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ReceiveServiceMethodTest.kt b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ReceiveServiceMethodTest.kt index c1e5e17d..d7177dca 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ReceiveServiceMethodTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ReceiveServiceMethodTest.kt @@ -63,5 +63,4 @@ internal class ReceiveServiceMethodTest { then(eventMapper).should().mapToData(event2) testSubscriber.assertNotTerminated() } - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/SendServiceMethodFactoryTest.kt b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/SendServiceMethodFactoryTest.kt index dd9555eb..fc3ef966 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/SendServiceMethodFactoryTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/SendServiceMethodFactoryTest.kt @@ -140,5 +140,4 @@ internal class SendServiceMethodFactoryTest { private inline fun param() = arrayOf(T::class.java.onlyMethod()) } } - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ServiceMethodExecutorFactoryTest.kt b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ServiceMethodExecutorFactoryTest.kt index 1f2fcd53..ad351c4e 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ServiceMethodExecutorFactoryTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ServiceMethodExecutorFactoryTest.kt @@ -185,5 +185,4 @@ internal class ServiceMethodExecutorFactoryTest { arrayOf(T::class.java, numberOfSendMethods, numberOfReceiveMethods) } } - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ServiceMethodExecutorTest.kt b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ServiceMethodExecutorTest.kt index f0417f51..eaa690ab 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ServiceMethodExecutorTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/internal/servicemethod/ServiceMethodExecutorTest.kt @@ -56,5 +56,4 @@ internal class ServiceMethodExecutorTest { serviceMethodExecutor.execute(notRegisteredMethod, arrayOf()) } } - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/lifecycle/DefaultLifecycleTest.kt b/scarlet/src/test/java/com/tinder/scarlet/lifecycle/DefaultLifecycleTest.kt index 35a70791..8a9cdd64 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/lifecycle/DefaultLifecycleTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/lifecycle/DefaultLifecycleTest.kt @@ -20,5 +20,4 @@ internal class DefaultLifecycleTest { // Then testSubscriber.assertValues(Lifecycle.State.Started) } - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/lifecycle/FlowableLifecycleTest.kt b/scarlet/src/test/java/com/tinder/scarlet/lifecycle/FlowableLifecycleTest.kt index c81068d2..b05d6046 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/lifecycle/FlowableLifecycleTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/lifecycle/FlowableLifecycleTest.kt @@ -46,5 +46,4 @@ class FlowableLifecycleTest { Lifecycle.State.Started ) } - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/lifecycle/LifecycleRegistryTest.kt b/scarlet/src/test/java/com/tinder/scarlet/lifecycle/LifecycleRegistryTest.kt index 96c8988e..a290454b 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/lifecycle/LifecycleRegistryTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/lifecycle/LifecycleRegistryTest.kt @@ -235,5 +235,4 @@ internal class LifecycleRegistryTest { testSubscriber.assertValues(Lifecycle.State.Started, Lifecycle.State.Destroyed) testSubscriber.assertComplete() } - } diff --git a/scarlet/src/test/java/com/tinder/scarlet/retry/ExponentialBackoffStrategyTest.kt b/scarlet/src/test/java/com/tinder/scarlet/retry/ExponentialBackoffStrategyTest.kt index 8975fd20..32ede508 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/retry/ExponentialBackoffStrategyTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/retry/ExponentialBackoffStrategyTest.kt @@ -44,7 +44,6 @@ internal class ExponentialBackoffStrategyTest { private fun param(baseDuration: Long, maxDuration: Long) = arrayOf(baseDuration, maxDuration) } - } @RunWith(Parameterized::class) diff --git a/scarlet/src/test/java/com/tinder/scarlet/retry/ExponentialBackoffWithJitterBackoffStrategyTest.kt b/scarlet/src/test/java/com/tinder/scarlet/retry/ExponentialBackoffWithJitterBackoffStrategyTest.kt index 48cbe234..f715be06 100644 --- a/scarlet/src/test/java/com/tinder/scarlet/retry/ExponentialBackoffWithJitterBackoffStrategyTest.kt +++ b/scarlet/src/test/java/com/tinder/scarlet/retry/ExponentialBackoffWithJitterBackoffStrategyTest.kt @@ -48,7 +48,6 @@ internal class ExponentialBackoffWithJitterBackoffStrategyTest { private fun param(baseDuration: Long, maxDuration: Long) = arrayOf(baseDuration, maxDuration) } - } @RunWith(Parameterized::class) @@ -227,7 +226,10 @@ internal class ExponentialBackoffWithJitterBackoffStrategyTest { ) private fun param( - baseDuration: Long, maxDuration: Long, jitterPercentage: Int, retryCount: Int, + baseDuration: Long, + maxDuration: Long, + jitterPercentage: Int, + retryCount: Int, expectedWaitDuration: Long ) = arrayOf(baseDuration, maxDuration, jitterPercentage, retryCount, expectedWaitDuration) diff --git a/state-machine/src/main/java/com/tinder/statemachine/StateMachine.kt b/state-machine/src/main/java/com/tinder/statemachine/StateMachine.kt index 8f7081ee..33372f52 100644 --- a/state-machine/src/main/java/com/tinder/statemachine/StateMachine.kt +++ b/state-machine/src/main/java/com/tinder/statemachine/StateMachine.kt @@ -158,6 +158,4 @@ class StateMachine private constructor() { fun create(init: Builder.() -> Unit) = Builder().apply(init).build() } - } - From e9c63dfb11f49d217082b5f288699ecf95ceb94d Mon Sep 17 00:00:00 2001 From: zhxnlai Date: Tue, 19 Jun 2018 17:13:25 +0200 Subject: [PATCH 02/27] Update README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 398c48e2..7f2e450e 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ This README is still **WIP**. Please see the [tutorial][tutorial] for more infor Tutorial --- - [Taming WebSocket with Scarlet][tutorial] +- [A talk][slides] at [Conference for Kotliners][kotliners] Usage --- @@ -144,3 +145,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [latest-jar]: https://tinder.jfrog.io/tinder/webapp/#/artifacts/browse/tree/General/libs-release-local/com/tinder/scarlet/scarlet [demo-app]: https://github.com/Tinder/Scarlet/tree/master/demo/src/main/java/com/tinder/app [tutorial]: https://tech.gotinder.com/taming-websocket-with-scarlet/ + [slides]: https://speakerdeck.com/zhxnlai/taming-websocket-with-scarlet + [kotliners]: + https://www.conferenceforkotliners.com/ From 65cf80820a4b60fd90be23bebfff54245e482a87 Mon Sep 17 00:00:00 2001 From: zhxnlai Date: Tue, 19 Jun 2018 17:13:29 +0200 Subject: [PATCH 03/27] Add Circle CI --- .circleci/config.yml | 21 +++++++++++++++++++++ README.md | 1 + 2 files changed, 22 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..fd050e36 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,21 @@ +version: 2 + +jobs: + build: + docker: + - image: circleci/android:api-27-alpha + environment: + TERM: dumb + GRADLE_OPTS: '-Dorg.gradle.jvmargs="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap" -Dorg.gradle.parallel=false -Dorg.gradle.daemon=true' + CIRCLE_TEST_REPORTS: test-reports + resource_class: xlarge + parallelism: 4 + steps: + - checkout + - run: + name: Disable PreDexing + command: echo "disablePreDex" >> gradle.properties + - run: if [ -e ./gradlew ]; then ./gradlew dependencies;else gradle dependencies;fi + - run: ./gradlew test + - run: mkdir -p $CIRCLE_TEST_REPORTS/junit/ + - run: find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \; diff --git a/README.md b/README.md index 7f2e450e..eed5c113 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ Scarlet === +[![CircleCI](https://circleci.com/gh/Tinder/Scarlet.svg?style=svg)](https://circleci.com/gh/Tinder/Scarlet) A Retrofit inspired WebSocket client for Kotlin, Java, and Android. From 66ea808cccb18166cc556463e75c1b8fd13eb805 Mon Sep 17 00:00:00 2001 From: zhxnlai Date: Tue, 19 Jun 2018 17:15:40 +0200 Subject: [PATCH 04/27] Update Group Id --- scarlet-core-internal/build.gradle | 2 +- scarlet-core/build.gradle | 2 +- scarlet-lifecycle-android/build.gradle | 2 +- scarlet-message-adapter-builtin/build.gradle | 2 +- scarlet-message-adapter-gson/build.gradle | 2 +- scarlet-message-adapter-moshi/build.gradle | 2 +- scarlet-message-adapter-protobuf/build.gradle | 2 +- scarlet-stream-adapter-builtin/build.gradle | 2 +- scarlet-stream-adapter-rxjava/build.gradle | 2 +- scarlet-stream-adapter-rxjava2/build.gradle | 2 +- scarlet-test-utils/build.gradle | 2 +- scarlet-websocket-mockwebserver/build.gradle | 2 +- scarlet-websocket-okhttp/build.gradle | 2 +- scarlet/build.gradle | 2 +- state-machine/build.gradle | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/scarlet-core-internal/build.gradle b/scarlet-core-internal/build.gradle index 04341c7f..98ab8041 100644 --- a/scarlet-core-internal/build.gradle +++ b/scarlet-core-internal/build.gradle @@ -27,7 +27,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar diff --git a/scarlet-core/build.gradle b/scarlet-core/build.gradle index 86813d44..3de8323a 100644 --- a/scarlet-core/build.gradle +++ b/scarlet-core/build.gradle @@ -38,7 +38,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar diff --git a/scarlet-lifecycle-android/build.gradle b/scarlet-lifecycle-android/build.gradle index 124d5168..80acb44c 100755 --- a/scarlet-lifecycle-android/build.gradle +++ b/scarlet-lifecycle-android/build.gradle @@ -63,7 +63,7 @@ task sourcesJar(type: Jar) { publishing { publications { aar(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() diff --git a/scarlet-message-adapter-builtin/build.gradle b/scarlet-message-adapter-builtin/build.gradle index 881e6aa2..0527cd6c 100644 --- a/scarlet-message-adapter-builtin/build.gradle +++ b/scarlet-message-adapter-builtin/build.gradle @@ -25,7 +25,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar diff --git a/scarlet-message-adapter-gson/build.gradle b/scarlet-message-adapter-gson/build.gradle index 1a777de9..b174d6b4 100755 --- a/scarlet-message-adapter-gson/build.gradle +++ b/scarlet-message-adapter-gson/build.gradle @@ -46,7 +46,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar diff --git a/scarlet-message-adapter-moshi/build.gradle b/scarlet-message-adapter-moshi/build.gradle index 905d0dee..f7836198 100755 --- a/scarlet-message-adapter-moshi/build.gradle +++ b/scarlet-message-adapter-moshi/build.gradle @@ -51,7 +51,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar diff --git a/scarlet-message-adapter-protobuf/build.gradle b/scarlet-message-adapter-protobuf/build.gradle index 0c7dc4cf..7d905bf3 100755 --- a/scarlet-message-adapter-protobuf/build.gradle +++ b/scarlet-message-adapter-protobuf/build.gradle @@ -45,7 +45,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar diff --git a/scarlet-stream-adapter-builtin/build.gradle b/scarlet-stream-adapter-builtin/build.gradle index 881e6aa2..0527cd6c 100644 --- a/scarlet-stream-adapter-builtin/build.gradle +++ b/scarlet-stream-adapter-builtin/build.gradle @@ -25,7 +25,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar diff --git a/scarlet-stream-adapter-rxjava/build.gradle b/scarlet-stream-adapter-rxjava/build.gradle index f4fbd2b7..1145c482 100755 --- a/scarlet-stream-adapter-rxjava/build.gradle +++ b/scarlet-stream-adapter-rxjava/build.gradle @@ -45,7 +45,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar diff --git a/scarlet-stream-adapter-rxjava2/build.gradle b/scarlet-stream-adapter-rxjava2/build.gradle index 97754282..52f79154 100755 --- a/scarlet-stream-adapter-rxjava2/build.gradle +++ b/scarlet-stream-adapter-rxjava2/build.gradle @@ -45,7 +45,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar diff --git a/scarlet-test-utils/build.gradle b/scarlet-test-utils/build.gradle index d633d7f0..9d7ae68b 100644 --- a/scarlet-test-utils/build.gradle +++ b/scarlet-test-utils/build.gradle @@ -37,7 +37,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar diff --git a/scarlet-websocket-mockwebserver/build.gradle b/scarlet-websocket-mockwebserver/build.gradle index b0c22ae0..d6ab5691 100644 --- a/scarlet-websocket-mockwebserver/build.gradle +++ b/scarlet-websocket-mockwebserver/build.gradle @@ -36,7 +36,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar diff --git a/scarlet-websocket-okhttp/build.gradle b/scarlet-websocket-okhttp/build.gradle index 0b5940ed..af62581d 100644 --- a/scarlet-websocket-okhttp/build.gradle +++ b/scarlet-websocket-okhttp/build.gradle @@ -47,7 +47,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar diff --git a/scarlet/build.gradle b/scarlet/build.gradle index f8895ec9..fc05b06c 100644 --- a/scarlet/build.gradle +++ b/scarlet/build.gradle @@ -53,7 +53,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar diff --git a/state-machine/build.gradle b/state-machine/build.gradle index a48f0bb1..f82245db 100644 --- a/state-machine/build.gradle +++ b/state-machine/build.gradle @@ -23,7 +23,7 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { - groupId 'com.tinder.scarlet' + groupId 'com.tinder' version version artifactId project.getName() artifact sourcesJar From 5feec00afe9ebb82d140c152325e6e794e2af387 Mon Sep 17 00:00:00 2001 From: zhxnlai Date: Tue, 19 Jun 2018 20:10:57 +0200 Subject: [PATCH 05/27] Support Jitpack --- build.gradle | 3 ++- gradle.properties | 2 +- jitpack.yml | 4 ++++ publish-jitpack.sh | 28 ++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 jitpack.yml create mode 100755 publish-jitpack.sh diff --git a/build.gradle b/build.gradle index 55115d54..c3bd162e 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,8 @@ ktlint { allprojects { apply plugin: 'org.kordamp.gradle.stats' apply plugin: "com.jfrog.artifactory" - group = 'com.tinder.scarlet' + // group = 'com.tinder.scarlet' TODO use Bintray + group = 'com.github.tinder' repositories { mavenCentral() diff --git a/gradle.properties b/gradle.properties index de55ab65..a482420b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=0.1.0 +version=0.1.1 diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 00000000..7ce70da2 --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,4 @@ +jdk: + - oraclejdk8 +install: + - ./publish-jitpack.sh diff --git a/publish-jitpack.sh b/publish-jitpack.sh new file mode 100755 index 00000000..4b7dad21 --- /dev/null +++ b/publish-jitpack.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +./gradlew clean + +./gradlew scarlet-core:build scarlet-core:publishToMavenLocal + +./gradlew scarlet-core-internal:build scarlet-core-internal:publishToMavenLocal + +./gradlew state-machine:build state-machine:publishToMavenLocal + +./gradlew scarlet:build scarlet:publishToMavenLocal + +./gradlew scarlet-test-utils:build scarlet-test-utils:publishToMavenLocal + +./gradlew scarlet-message-adapter-builtin:build scarlet-message-adapter-builtin:publishToMavenLocal + +./gradlew scarlet-message-adapter-protobuf:build scarlet-message-adapter-protobuf:publishToMavenLocal + +./gradlew scarlet-stream-adapter-builtin:build scarlet-stream-adapter-builtin:publishToMavenLocal + +./gradlew scarlet-stream-adapter-rxjava2:build scarlet-stream-adapter-rxjava2:publishToMavenLocal + +./gradlew scarlet-websocket-okhttp:build scarlet-websocket-okhttp:publishToMavenLocal + +./gradlew scarlet-websocket-mockwebserver:build scarlet-websocket-mockwebserver:publishToMavenLocal + +./gradlew scarlet-lifecycle-android:assemble scarlet-lifecycle-android:generatePomFileForAarPublication +./gradlew scarlet-lifecycle-android:publishToMavenLocal From 89886842accfbe0fb0e365d4f4c56ce06a4d7cda Mon Sep 17 00:00:00 2001 From: zhxnlai Date: Tue, 19 Jun 2018 20:28:54 +0200 Subject: [PATCH 06/27] Publish all packages --- publish-jitpack.sh | 6 ++++++ publish.sh | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/publish-jitpack.sh b/publish-jitpack.sh index 4b7dad21..54e6920c 100755 --- a/publish-jitpack.sh +++ b/publish-jitpack.sh @@ -16,10 +16,16 @@ ./gradlew scarlet-message-adapter-protobuf:build scarlet-message-adapter-protobuf:publishToMavenLocal +./gradlew scarlet-message-adapter-moshi:build scarlet-message-adapter-moshi:publishToMavenLocal + +./gradlew scarlet-message-adapter-gson:build scarlet-message-adapter-gson:publishToMavenLocal + ./gradlew scarlet-stream-adapter-builtin:build scarlet-stream-adapter-builtin:publishToMavenLocal ./gradlew scarlet-stream-adapter-rxjava2:build scarlet-stream-adapter-rxjava2:publishToMavenLocal +./gradlew scarlet-stream-adapter-rxjava:build scarlet-stream-adapter-rxjava:publishToMavenLocal + ./gradlew scarlet-websocket-okhttp:build scarlet-websocket-okhttp:publishToMavenLocal ./gradlew scarlet-websocket-mockwebserver:build scarlet-websocket-mockwebserver:publishToMavenLocal diff --git a/publish.sh b/publish.sh index da301066..8a715bf3 100755 --- a/publish.sh +++ b/publish.sh @@ -17,10 +17,16 @@ ./gradlew scarlet-message-adapter-builtin:build scarlet-message-adapter-builtin:artifactoryPublish +./gradlew scarlet-message-adapter-gson:build scarlet-message-adapter-gson:artifactoryPublish + +./gradlew scarlet-message-adapter-moshi:build scarlet-message-adapter-moshi:artifactoryPublish + ./gradlew scarlet-message-adapter-protobuf:build scarlet-message-adapter-protobuf:artifactoryPublish ./gradlew scarlet-stream-adapter-builtin:build scarlet-stream-adapter-builtin:artifactoryPublish +./gradlew scarlet-stream-adapter-rxjava:build scarlet-stream-adapter-rxjava:artifactoryPublish + ./gradlew scarlet-stream-adapter-rxjava2:build scarlet-stream-adapter-rxjava2:artifactoryPublish ./gradlew scarlet-websocket-okhttp:build scarlet-websocket-okhttp:artifactoryPublish From 8f5c1fac03aa33659d5e0ae953c9efd230d721a8 Mon Sep 17 00:00:00 2001 From: zhxnlai Date: Tue, 19 Jun 2018 21:16:45 +0200 Subject: [PATCH 07/27] Update README --- README.md | 110 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index eed5c113..2a6d53f3 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ Scarlet === [![CircleCI](https://circleci.com/gh/Tinder/Scarlet.svg?style=svg)](https://circleci.com/gh/Tinder/Scarlet) +[![Release](https://jitpack.io/v/tinder/scarlet.svg)](https://jitpack.io/#tinder/scarlet) A Retrofit inspired WebSocket client for Kotlin, Java, and Android. -This README is still **WIP**. Please see the [tutorial][tutorial] for more information. - Tutorial --- - [Taming WebSocket with Scarlet][tutorial] @@ -13,28 +12,25 @@ Tutorial Usage --- -In this example, we are reading the realtime Bitcoin price from [Gdax WebSocket Feed][gdax-websocket-feed]. +In this example, we read the realtime Bitcoin price from [Gdax WebSocket Feed][gdax-websocket-feed]. For more information, please check out the [demo app][demo-app]. -Declare a WebSocket client using an interface. +Declare a WebSocket client using an interface: ~~~ kotlin interface GdaxService { + @Receive + fun observeOnConnectionOpenedEvent(): Flowable> @Send fun sendSubscribe(subscribe: Subscribe) @Receive fun observeTicker(): Flowable - @Receive - fun observeOnConnectionOpenedEvent(): Flowable> } -val gdaxService = scarlet.create() ~~~ -Use Scarlet to create an implementation. +Use Scarlet to create an implementation: ~~~ kotlin -val okHttpClient = OkHttpClient.Builder().build() - val scarletInstance = Scarlet.Builder() .webSocketFactory(okHttpClient.newWebSocketFactory("wss://ws-feed.gdax.com")) .addMessageAdapterFactory(MoshiMessageAdapter.Factory()) @@ -44,7 +40,9 @@ val scarletInstance = Scarlet.Builder() val gdaxService = scarletInstance.create() ~~~ -Send a `Subscribe` message upon connection open so that the server will start streaming tickers, which contain the latest price. +Send a `Subscribe` message upon connection open and the server will start streaming tickers which contain the latest price. + + ~~~ kotlin val BITCOIN_TICKER_SUBSCRIBE_MESSAGE = Subscribe( productIds = listOf("BTC-USD"), @@ -55,64 +53,72 @@ gdaxService.observeOnConnectionOpenedEvent() .subscribe({ gdaxService.sendSubscribe(BITCOIN_TICKER_SUBSCRIBE_MESSAGE) }) -~~~ -Start observing realtime tickers. -~~~ kotlin gdaxService.observeTicker() .subscribe({ ticker -> Log.d("Bitcoin price is ${ticker.price} at ${ticker.time}") }) ~~~ -### Built-in Plugins -`WebSocket.Factory` -- `OkHttpClient` -- `MockHttpServer` - -`MessageAdapter.Factory` -- moshi -- gson -- protobuf - -`StreamAdapter.Factory` -- RxJava2 -- RxJava1 - -`Lifecycle` -- AndroidLifecycle - -`BackoffStrategy` -- Linear -- Exponential -- ExponentialWithJitter +### Android +Scarlet is driven by a [StateMachine](https://github.com/Tinder/StateMachine). -### Android -TODO: -- `AndroidLifecycle` + - -### State Machine -Scarlet is driven by a [StateMachine](https://github.com/Tinder/StateMachine). -![State Diagram](./example/scarlet-state-machine.png) +TODO Download -------- -**TODO: make the jar public** +While we are working on Bintray support, Scarlet is available via [JitPack](jitpack). -Download [the latest JAR][latest-jar] or grab via Maven: +##### Maven: ```xml + + jitpack.io + https://jitpack.io + - com.tinder.scarlet - scarlet - 0.1.0 + com.github.tinder.scarlet + scarlet + 0.1.2 ``` -or Gradle: + +##### Gradle: ```groovy -implementation 'com.tinder.scarlet:scarlet:0.1.0' +repositories { + // ... + maven { url "https://jitpack.io" } +} + +implementation 'com.github.tinder.scarlet:scarlet:0.1.2' ``` +### Roadmap +`WebSocket.Factory` +- [x] `OkHttpClient` +- [x] `MockHttpServer` + +`MessageAdapter.Factory` +- [x] `moshi` +- [x] `gson` +- [x] `protobuf` +- [ ] `jackson` +- [ ] `simple-xml` + +`StreamAdapter.Factory` +- [x] `RxJava2` +- [x] `RxJava1` +- [ ] `Kotlin Coroutine` + +`Lifecycle` +- [x] `AndroidLifecycle` + +`BackoffStrategy` +- [x] `Linear` +- [x] `Exponential` +- [x] `ExponentialWithJitter` + Copyright --- ~~~ @@ -144,8 +150,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [gdax-websocket-feed]: https://docs.gdax.com/#websocket-feed [latest-jar]: https://tinder.jfrog.io/tinder/webapp/#/artifacts/browse/tree/General/libs-release-local/com/tinder/scarlet/scarlet - [demo-app]: https://github.com/Tinder/Scarlet/tree/master/demo/src/main/java/com/tinder/app + [demo-app]: /demo/src/main/java/com/tinder/app [tutorial]: https://tech.gotinder.com/taming-websocket-with-scarlet/ [slides]: https://speakerdeck.com/zhxnlai/taming-websocket-with-scarlet - [kotliners]: - https://www.conferenceforkotliners.com/ + [kotliners]:https://www.conferenceforkotliners.com/ + [jitpack]: https://jitpack.io/ From 62a0631f6cc7c1abb07a9408befa041ec7ac9845 Mon Sep 17 00:00:00 2001 From: zhxnlai Date: Tue, 19 Jun 2018 21:19:55 +0200 Subject: [PATCH 08/27] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a6d53f3..7c9d83e6 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ repositories { implementation 'com.github.tinder.scarlet:scarlet:0.1.2' ``` -### Roadmap +### Plug-in Roadmap `WebSocket.Factory` - [x] `OkHttpClient` - [x] `MockHttpServer` From e9c6e67a144eaa347950eecf869a6c94135a8fed Mon Sep 17 00:00:00 2001 From: Aaron Weaver Date: Fri, 22 Jun 2018 01:45:36 -0700 Subject: [PATCH 09/27] Adding coroutines adapter and factory + tests --- scarlet-stream-adapter-coroutines/.gitignore | 1 + .../build.gradle | 76 +++++++++ .../CoroutinesStreamAdapterFactory.kt | 19 +++ .../coroutines/ReceiveChannelStreamAdapter.kt | 13 ++ .../coroutines/ReceiveChannelTest.kt | 155 ++++++++++++++++++ 5 files changed, 264 insertions(+) create mode 100644 scarlet-stream-adapter-coroutines/.gitignore create mode 100644 scarlet-stream-adapter-coroutines/build.gradle create mode 100644 scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/CoroutinesStreamAdapterFactory.kt create mode 100644 scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/ReceiveChannelStreamAdapter.kt create mode 100644 scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt diff --git a/scarlet-stream-adapter-coroutines/.gitignore b/scarlet-stream-adapter-coroutines/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/scarlet-stream-adapter-coroutines/.gitignore @@ -0,0 +1 @@ +/build diff --git a/scarlet-stream-adapter-coroutines/build.gradle b/scarlet-stream-adapter-coroutines/build.gradle new file mode 100644 index 00000000..c96f46f3 --- /dev/null +++ b/scarlet-stream-adapter-coroutines/build.gradle @@ -0,0 +1,76 @@ +apply plugin: 'kotlin' +apply plugin: 'java-library' +apply plugin: 'org.jetbrains.dokka' +apply plugin: 'maven-publish' + +dependencies { + api rootProject.ext.kotlinCoroutines + api rootProject.ext.kotlinCoroutinesRxInterop + + implementation project(':scarlet-core') + implementation rootProject.ext.kotlinStdlib + + testImplementation project(':scarlet') + testImplementation project(':scarlet-websocket-mockwebserver') + testImplementation project(':scarlet-test-utils') + testImplementation rootProject.ext.junit + testImplementation rootProject.ext.mockito + testImplementation rootProject.ext.kotlinReflect + testImplementation rootProject.ext.assertJ +} + +kotlin { experimental { coroutines 'enable' } } + +dokka { + outputFormat = 'javadoc' + outputDirectory = "$buildDir/javadoc" +} + +task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource +} + +task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) { + outputFormat = 'javadoc' + outputDirectory = javadoc.destinationDir +} + +task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +artifacts { + archives sourcesJar, javadocJar +} + +publishing { + publications { + mavenJava(MavenPublication) { + groupId 'com.tinder' + version version + artifactId project.getName() + artifact sourcesJar + artifact javadocJar + from components.java + } + } +} + +artifactory { + contextUrl = 'https://tinder.jfrog.io/tinder' + publish { + repository { + repoKey = 'libs-release-local' + username = System.getenv("ARTIFACTORY_USER") + password = System.getenv("ARTIFACTORY_PASSWORD") + maven = true + } + defaults { + publications('mavenJava') + publishArtifacts = true + publishPom = true + } + } +} diff --git a/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/CoroutinesStreamAdapterFactory.kt b/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/CoroutinesStreamAdapterFactory.kt new file mode 100644 index 00000000..1fa69314 --- /dev/null +++ b/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/CoroutinesStreamAdapterFactory.kt @@ -0,0 +1,19 @@ +package com.tinder.streamadapter.coroutines + +import com.tinder.scarlet.StreamAdapter +import com.tinder.scarlet.utils.getRawType +import kotlinx.coroutines.experimental.channels.ReceiveChannel +import java.lang.reflect.Type + +/** + * A [stream adapter factory][StreamAdapter.Factory] that uses ReceiveChannel. + */ +class CoroutinesStreamAdapterFactory : StreamAdapter.Factory { + + override fun create(type: Type): StreamAdapter { + return when (type.getRawType()) { + ReceiveChannel::class.java -> ReceiveChannelStreamAdapter() + else -> throw IllegalArgumentException() + } + } +} \ No newline at end of file diff --git a/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/ReceiveChannelStreamAdapter.kt b/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/ReceiveChannelStreamAdapter.kt new file mode 100644 index 00000000..31313665 --- /dev/null +++ b/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/ReceiveChannelStreamAdapter.kt @@ -0,0 +1,13 @@ +package com.tinder.streamadapter.coroutines + +import com.tinder.scarlet.Stream +import com.tinder.scarlet.StreamAdapter +import kotlinx.coroutines.experimental.channels.ReceiveChannel +import kotlinx.coroutines.experimental.reactive.openSubscription + +class ReceiveChannelStreamAdapter : StreamAdapter> { + + override fun adapt(stream: Stream): ReceiveChannel { + return stream.openSubscription() + } +} \ No newline at end of file diff --git a/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt new file mode 100644 index 00000000..6bcd498f --- /dev/null +++ b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt @@ -0,0 +1,155 @@ +package com.tinder.scarlet.streamadapter.coroutines + +import com.tinder.scarlet.Lifecycle +import com.tinder.scarlet.Scarlet +import com.tinder.scarlet.Stream +import com.tinder.scarlet.WebSocket +import com.tinder.scarlet.lifecycle.LifecycleRegistry +import com.tinder.scarlet.testutils.* +import com.tinder.scarlet.websocket.mockwebserver.newWebSocketFactory +import com.tinder.scarlet.websocket.okhttp.newWebSocketFactory +import com.tinder.scarlet.ws.Receive +import com.tinder.scarlet.ws.Send +import com.tinder.streamadapter.coroutines.CoroutinesStreamAdapterFactory +import kotlinx.coroutines.experimental.* +import kotlinx.coroutines.experimental.channels.* +import kotlinx.coroutines.experimental.reactive.publish +import kotlinx.coroutines.experimental.selects.select +import kotlinx.coroutines.experimental.test.withTestContext +import okhttp3.OkHttpClient +import okhttp3.mockwebserver.MockWebServer +import org.assertj.core.api.Assertions.assertThat +import org.junit.Rule +import org.junit.Test +import java.util.concurrent.TimeUnit + +class ReceiveChannelTest { + + @get:Rule + private val mockWebServer = MockWebServer() + private val serverUrlString by lazy { mockWebServer.url("/").toString() } + + private val serverLifecycleRegistry = LifecycleRegistry() + private lateinit var server: Service + private lateinit var serverEventObserver: TestStreamObserver + + private val clientLifecycleRegistry = LifecycleRegistry() + private lateinit var client: Service + private lateinit var clientEventObserver: TestStreamObserver + + @Test + fun send_givenConnectionIsEstablished_shouldBeReceivedByTheServer() { + runBlocking { + // Given + givenConnectionIsEstablished() + val textMessage1 = "Hello" + val textMessage2 = "Hi" + val bytesMessage1 = "Yo".toByteArray() + val bytesMessage2 = "Sup".toByteArray() + val testTextSubscriber = server.observeText() + val testBytesSubscriber = server.observeBytes() + + // When + client.sendText(textMessage1) + val isSendTextSuccessful = client.sendTextAndConfirm(textMessage2) + client.sendBytes(bytesMessage1) + val isSendBytesSuccessful = client.sendBytesAndConfirm(bytesMessage2) + + // Then + assertThat(isSendTextSuccessful).isTrue() + assertThat(isSendBytesSuccessful).isTrue() + serverEventObserver.awaitValues( + any>(), + any().containingText(textMessage1), + any().containingText(textMessage2), + any().containingBytes(bytesMessage1), + any().containingBytes(bytesMessage2) + ) + + withTestContext { + runBlocking(this) { + assertThat(testTextSubscriber.receiveOrNull()).isEqualTo(textMessage1) + assertThat(testTextSubscriber.receiveOrNull()).isEqualTo(textMessage2) + } + } + + var count = 0 + withTestContext { + runBlocking(this) { + assertThat(testBytesSubscriber.receiveOrNull()).isNotNull() + assertThat(testBytesSubscriber.receiveOrNull()).isNotNull() + } + } + } + } + + private fun givenConnectionIsEstablished() { + createClientAndServer() + serverLifecycleRegistry.onNext(Lifecycle.State.Started) + clientLifecycleRegistry.onNext(Lifecycle.State.Started) + blockUntilConnectionIsEstablish() + } + + private fun createClientAndServer() { + server = createServer() + serverEventObserver = server.observeEvents().test() + client = createClient() + clientEventObserver = client.observeEvents().test() + } + + private fun createServer(): Service { + val webSocketFactory = mockWebServer.newWebSocketFactory() + val scarlet = Scarlet.Builder() + .webSocketFactory(webSocketFactory) + .lifecycle(serverLifecycleRegistry) + .addStreamAdapterFactory(CoroutinesStreamAdapterFactory()) + .build() + return scarlet.create() + } + + private fun createClient(): Service { + val okHttpClient = OkHttpClient.Builder() + .writeTimeout(500, TimeUnit.MILLISECONDS) + .readTimeout(500, TimeUnit.MILLISECONDS) + .build() + val webSocketFactory = okHttpClient.newWebSocketFactory(serverUrlString) + val scarlet = Scarlet.Builder() + .webSocketFactory(webSocketFactory) + .lifecycle(clientLifecycleRegistry) + .addStreamAdapterFactory(CoroutinesStreamAdapterFactory()) + .build() + return scarlet.create() + } + + private fun blockUntilConnectionIsEstablish() { + clientEventObserver.awaitValues( + any>() + ) + serverEventObserver.awaitValues( + any>() + ) + } + + private interface Service { + @Receive + fun observeEvents(): Stream + + @Receive + fun observeText(): ReceiveChannel + + @Receive + fun observeBytes(): ReceiveChannel + + @Send + fun sendText(message: String) + + @Send + fun sendTextAndConfirm(message: String): Boolean + + @Send + fun sendBytes(message: ByteArray) + + @Send + fun sendBytesAndConfirm(message: ByteArray): Boolean + } +} \ No newline at end of file From bc91b169b6523ac6a384b283c791c99527164bb7 Mon Sep 17 00:00:00 2001 From: Aaron Weaver Date: Fri, 22 Jun 2018 01:55:18 -0700 Subject: [PATCH 10/27] Removing unnecessary gitignore file --- scarlet-stream-adapter-coroutines/.gitignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 scarlet-stream-adapter-coroutines/.gitignore diff --git a/scarlet-stream-adapter-coroutines/.gitignore b/scarlet-stream-adapter-coroutines/.gitignore deleted file mode 100644 index 796b96d1..00000000 --- a/scarlet-stream-adapter-coroutines/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build From 6a790d919ffe00c403ce8c3c70fa5cf11d29aa9b Mon Sep 17 00:00:00 2001 From: zhxnlai Date: Fri, 22 Jun 2018 15:31:18 -0700 Subject: [PATCH 11/27] Update header copyright --- demo/src/main/AndroidManifest.xml | 2 +- .../main/java/com/tinder/app/echo/api/BitmapMessageAdapter.kt | 2 +- demo/src/main/java/com/tinder/app/echo/api/EchoService.kt | 2 +- demo/src/main/java/com/tinder/app/echo/domain/AuthStatus.kt | 2 +- .../java/com/tinder/app/echo/domain/AuthStatusRepository.kt | 2 +- demo/src/main/java/com/tinder/app/echo/domain/ChatMessage.kt | 2 +- .../java/com/tinder/app/echo/domain/ChatMessageRepository.kt | 2 +- .../main/java/com/tinder/app/echo/domain/LoggedInLifecycle.kt | 2 +- .../main/java/com/tinder/app/echo/inject/EchoBotComponent.kt | 2 +- demo/src/main/java/com/tinder/app/echo/inject/EchoBotScope.kt | 2 +- .../main/java/com/tinder/app/echo/presenter/EchoBotPresenter.kt | 2 +- demo/src/main/java/com/tinder/app/echo/target/EchoBotTarget.kt | 2 +- demo/src/main/java/com/tinder/app/echo/view/EchoBotFragment.kt | 2 +- demo/src/main/java/com/tinder/app/gdax/api/GdaxService.kt | 2 +- demo/src/main/java/com/tinder/app/gdax/api/MoshiAdapters.kt | 2 +- demo/src/main/java/com/tinder/app/gdax/api/model/ProductId.kt | 2 +- demo/src/main/java/com/tinder/app/gdax/api/model/Subscribe.kt | 2 +- demo/src/main/java/com/tinder/app/gdax/api/model/Ticker.kt | 2 +- demo/src/main/java/com/tinder/app/gdax/domain/Product.kt | 2 +- demo/src/main/java/com/tinder/app/gdax/domain/Transaction.kt | 2 +- .../src/main/java/com/tinder/app/gdax/domain/TransactionBook.kt | 2 +- .../java/com/tinder/app/gdax/domain/TransactionRepository.kt | 2 +- demo/src/main/java/com/tinder/app/gdax/inject/GdaxComponent.kt | 2 +- demo/src/main/java/com/tinder/app/gdax/inject/GdaxScope.kt | 2 +- .../main/java/com/tinder/app/gdax/presenter/GdaxPresenter.kt | 2 +- demo/src/main/java/com/tinder/app/gdax/target/GdaxTarget.kt | 2 +- demo/src/main/java/com/tinder/app/gdax/view/GdaxFragment.kt | 2 +- .../src/main/java/com/tinder/app/root/ScarletDemoApplication.kt | 2 +- .../java/com/tinder/app/root/inject/ApplicationComponent.kt | 2 +- demo/src/main/java/com/tinder/app/root/inject/CommonModule.kt | 2 +- demo/src/main/java/com/tinder/app/root/inject/StethoModule.kt | 2 +- demo/src/main/java/com/tinder/app/root/view/DemoActivity.kt | 2 +- demo/src/main/res/drawable/ic_launcher_background.xml | 2 +- demo/src/main/res/layout/activity_demo.xml | 2 +- demo/src/main/res/layout/fragment_echo_bot.xml | 2 +- demo/src/main/res/layout/fragment_gdax.xml | 2 +- demo/src/main/res/layout/view_event_log.xml | 2 +- demo/src/main/res/mipmap-anydpi-v26/ic_launcher.xml | 2 +- demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml | 2 +- demo/src/main/res/values/colors.xml | 2 +- demo/src/main/res/values/dimens.xml | 2 +- demo/src/main/res/values/strings.xml | 2 +- demo/src/main/res/values/styles.xml | 2 +- .../main/java/com/tinder/scarlet/utils/EmptyStreamObserver.kt | 2 +- .../src/main/java/com/tinder/scarlet/utils/FlowableStream.kt | 2 +- .../src/main/java/com/tinder/scarlet/utils/FlowableUtils.kt | 2 +- .../test/java/com/tinder/scarlet/utils/FlowableStreamTest.kt | 2 +- .../src/main/java/com/tinder/scarlet/Deserialization.kt | 2 +- scarlet-core/src/main/java/com/tinder/scarlet/Lifecycle.kt | 2 +- scarlet-core/src/main/java/com/tinder/scarlet/Message.kt | 2 +- scarlet-core/src/main/java/com/tinder/scarlet/MessageAdapter.kt | 2 +- scarlet-core/src/main/java/com/tinder/scarlet/ShutdownReason.kt | 2 +- scarlet-core/src/main/java/com/tinder/scarlet/Stream.kt | 2 +- scarlet-core/src/main/java/com/tinder/scarlet/StreamAdapter.kt | 2 +- scarlet-core/src/main/java/com/tinder/scarlet/WebSocket.kt | 2 +- .../src/main/java/com/tinder/scarlet/utils/TypeUtils.kt | 2 +- scarlet-core/src/main/java/com/tinder/scarlet/utils/Utils.java | 2 +- .../src/test/java/com/tinder/scarlet/utils/TypeUtilsTest.kt | 2 +- scarlet-lifecycle-android/src/main/AndroidManifest.xml | 2 +- .../com/tinder/scarlet/lifecycle/android/AndroidLifecycle.kt | 2 +- .../scarlet/lifecycle/android/ApplicationResumedLifecycle.kt | 2 +- .../tinder/scarlet/lifecycle/android/ConnectivityOnLifecycle.kt | 2 +- .../scarlet/lifecycle/android/LifecycleOwnerResumedLifecycle.kt | 2 +- .../messageadapter/builtin/BuiltInMessageAdapterFactory.kt | 2 +- .../scarlet/messageadapter/builtin/ByteArrayMessageAdapter.kt | 2 +- .../tinder/scarlet/messageadapter/builtin/TextMessageAdapter.kt | 2 +- .../messageadapter/builtin/BuiltInMessageAdapterFactoryTest.kt | 2 +- .../messageadapter/builtin/ByteArrayMessageAdapterTest.kt | 2 +- .../scarlet/messageadapter/builtin/TextMessageAdapterTest.kt | 2 +- .../tinder/scarlet/messageadapter/gson/GsonMessageAdapter.kt | 2 +- .../scarlet/messageadapter/gson/GsonMessageAdapterTest.kt | 2 +- .../tinder/scarlet/messageadapter/moshi/MoshiMessageAdapter.kt | 2 +- .../scarlet/messageadapter/moshi/MoshiMessageAdapterTest.kt | 2 +- .../scarlet/messageadapter/protobuf/ProtobufMessageAdapter.kt | 2 +- .../com/tinder/scarlet/messageadapter/protobuf/PhoneProtos.java | 2 +- .../messageadapter/protobuf/ProtobufMessageAdapterTest.kt | 2 +- .../streamadapter/builtin/BuiltInStreamAdapterFactory.kt | 2 +- .../scarlet/streamadapter/builtin/IdentityStreamAdapter.kt | 2 +- .../streamadapter/builtin/BuiltInStreamAdapterFactoryTest.kt | 2 +- .../scarlet/streamadapter/builtin/IdentityStreamAdapterTest.kt | 2 +- .../scarlet/streamadapter/rxjava/ObservableStreamAdapter.kt | 2 +- .../scarlet/streamadapter/rxjava/RxJavaStreamAdapterFactory.kt | 2 +- .../com/tinder/scarlet/streamadapter/rxjava/ObservableTest.kt | 2 +- .../scarlet/streamadapter/rxjava2/FlowableStreamAdapter.kt | 2 +- .../scarlet/streamadapter/rxjava2/ObservableStreamAdapter.kt | 2 +- .../streamadapter/rxjava2/RxJava2StreamAdapterFactory.kt | 2 +- .../com/tinder/scarlet/streamadapter/rxjava2/FlowableTest.kt | 2 +- .../com/tinder/scarlet/streamadapter/rxjava2/ObservableTest.kt | 2 +- .../java/com/tinder/scarlet/testutils/TestStreamObserver.kt | 2 +- .../src/main/java/com/tinder/scarlet/testutils/TestUtils.kt | 2 +- .../src/main/java/com/tinder/scarlet/testutils/ValueAssert.kt | 2 +- .../MockWebServerOkHttpWebSocketConnectionEstablisher.kt | 2 +- .../scarlet/websocket/mockwebserver/MockWebServerUtils.kt | 2 +- .../com/tinder/scarlet/websocket/okhttp/OkHttpClientUtils.kt | 2 +- .../okhttp/OkHttpClientWebSocketConnectionEstablisher.kt | 2 +- .../java/com/tinder/scarlet/websocket/okhttp/OkHttpWebSocket.kt | 2 +- .../scarlet/websocket/okhttp/OkHttpWebSocketEventObserver.kt | 2 +- .../tinder/scarlet/websocket/okhttp/OkHttpWebSocketHolder.kt | 2 +- .../tinder/scarlet/websocket/okhttp/request/RequestFactory.kt | 2 +- .../scarlet/websocket/okhttp/request/StaticUrlRequestFactory.kt | 2 +- .../websocket/okhttp/OkHttpWebSocketEventObserverTest.kt | 2 +- .../scarlet/websocket/okhttp/OkHttpWebSocketHolderTest.kt | 2 +- .../scarlet/websocket/okhttp/OkHttpWebSocketIntegrationTest.kt | 2 +- .../com/tinder/scarlet/websocket/okhttp/OkHttpWebSocketTest.kt | 2 +- .../websocket/okhttp/request/StaticUrlRequestFactoryTest.kt | 2 +- scarlet/src/main/java/com/tinder/scarlet/Event.kt | 2 +- scarlet/src/main/java/com/tinder/scarlet/Scarlet.kt | 2 +- scarlet/src/main/java/com/tinder/scarlet/Session.kt | 2 +- scarlet/src/main/java/com/tinder/scarlet/State.kt | 2 +- scarlet/src/main/java/com/tinder/scarlet/internal/Service.kt | 2 +- .../java/com/tinder/scarlet/internal/connection/Connection.kt | 2 +- .../internal/connection/subscriber/LifecycleStateSubscriber.kt | 2 +- .../internal/connection/subscriber/RetryTimerSubscriber.kt | 2 +- .../internal/connection/subscriber/WebSocketEventSubscriber.kt | 2 +- .../com/tinder/scarlet/internal/servicemethod/EventMapper.kt | 2 +- .../scarlet/internal/servicemethod/MessageAdapterResolver.kt | 2 +- .../com/tinder/scarlet/internal/servicemethod/ServiceMethod.kt | 2 +- .../scarlet/internal/servicemethod/ServiceMethodExecutor.kt | 2 +- .../scarlet/internal/servicemethod/StreamAdapterResolver.kt | 2 +- .../java/com/tinder/scarlet/internal/utils/RuntimePlatform.kt | 2 +- .../main/java/com/tinder/scarlet/lifecycle/DefaultLifecycle.kt | 2 +- .../main/java/com/tinder/scarlet/lifecycle/FlowableLifecycle.kt | 2 +- .../main/java/com/tinder/scarlet/lifecycle/LifecycleRegistry.kt | 2 +- .../java/com/tinder/scarlet/lifecycle/LifecycleStateUtils.kt | 2 +- .../src/main/java/com/tinder/scarlet/retry/BackoffStrategy.kt | 2 +- .../java/com/tinder/scarlet/retry/ExponentialBackoffStrategy.kt | 2 +- .../scarlet/retry/ExponentialWithJitterBackoffStrategy.kt | 2 +- .../main/java/com/tinder/scarlet/retry/LinearBackoffStrategy.kt | 2 +- scarlet/src/main/java/com/tinder/scarlet/ws/Receive.java | 2 +- scarlet/src/main/java/com/tinder/scarlet/ws/Send.java | 2 +- scarlet/src/test/java/com/tinder/scarlet/ScarletTest.kt | 2 +- .../test/java/com/tinder/scarlet/internal/ServiceFactoryTest.kt | 2 +- .../src/test/java/com/tinder/scarlet/internal/ServiceTest.kt | 2 +- .../tinder/scarlet/internal/connection/ConnectionFactoryTest.kt | 2 +- .../scarlet/internal/connection/ConnectionStateManagerTest.kt | 2 +- .../com/tinder/scarlet/internal/connection/ConnectionTest.kt | 2 +- .../scarlet/internal/connection/LifecycleStateSubscriberTest.kt | 2 +- .../scarlet/internal/connection/RetryTimerSubscriberTest.kt | 2 +- .../scarlet/internal/connection/WebSocketEventSubscriberTest.kt | 2 +- .../scarlet/internal/servicemethod/EventMapperFactoryTest.kt | 2 +- .../tinder/scarlet/internal/servicemethod/EventMapperTest.kt | 2 +- .../internal/servicemethod/MessageAdapterResolverTest.kt | 2 +- .../internal/servicemethod/ReceiveServiceMethodFactoryTest.kt | 2 +- .../scarlet/internal/servicemethod/ReceiveServiceMethodTest.kt | 2 +- .../internal/servicemethod/SendServiceMethodFactoryTest.kt | 2 +- .../scarlet/internal/servicemethod/SendServiceMethodTest.kt | 2 +- .../internal/servicemethod/ServiceMethodExecutorFactoryTest.kt | 2 +- .../scarlet/internal/servicemethod/ServiceMethodExecutorTest.kt | 2 +- .../scarlet/internal/servicemethod/StreamAdapterResolverTest.kt | 2 +- .../java/com/tinder/scarlet/lifecycle/DefaultLifecycleTest.kt | 2 +- .../java/com/tinder/scarlet/lifecycle/FlowableLifecycleTest.kt | 2 +- .../scarlet/lifecycle/LifecycleRegistryBackpressureTest.kt | 2 +- .../java/com/tinder/scarlet/lifecycle/LifecycleRegistryTest.kt | 2 +- .../com/tinder/scarlet/retry/ExponentialBackoffStrategyTest.kt | 2 +- .../retry/ExponentialBackoffWithJitterBackoffStrategyTest.kt | 2 +- .../java/com/tinder/scarlet/retry/LinearBackoffStrategyTest.kt | 2 +- scarlet/src/test/java/com/tinder/scarlet/utils/ClassUtils.kt | 2 +- .../src/main/java/com/tinder/statemachine/StateMachine.kt | 2 +- .../src/test/java/com/tinder/statemachine/StateMachineTest.kt | 2 +- 159 files changed, 159 insertions(+), 159 deletions(-) diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml index ce97b0d2..b6cadabd 100755 --- a/demo/src/main/AndroidManifest.xml +++ b/demo/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ diff --git a/demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index 4b776554..176e2843 100755 --- a/demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,6 +1,6 @@ diff --git a/demo/src/main/res/values/colors.xml b/demo/src/main/res/values/colors.xml index 496c74c6..eab0c52a 100755 --- a/demo/src/main/res/values/colors.xml +++ b/demo/src/main/res/values/colors.xml @@ -1,6 +1,6 @@ diff --git a/demo/src/main/res/values/dimens.xml b/demo/src/main/res/values/dimens.xml index a92b8340..3e761681 100644 --- a/demo/src/main/res/values/dimens.xml +++ b/demo/src/main/res/values/dimens.xml @@ -1,6 +1,6 @@ diff --git a/demo/src/main/res/values/strings.xml b/demo/src/main/res/values/strings.xml index ebd1197e..8e09dfe4 100755 --- a/demo/src/main/res/values/strings.xml +++ b/demo/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ diff --git a/demo/src/main/res/values/styles.xml b/demo/src/main/res/values/styles.xml index 796cf1ae..34343ba1 100755 --- a/demo/src/main/res/values/styles.xml +++ b/demo/src/main/res/values/styles.xml @@ -1,5 +1,5 @@ diff --git a/scarlet-core-internal/src/main/java/com/tinder/scarlet/utils/EmptyStreamObserver.kt b/scarlet-core-internal/src/main/java/com/tinder/scarlet/utils/EmptyStreamObserver.kt index 7a4dfb58..6127a1ae 100644 --- a/scarlet-core-internal/src/main/java/com/tinder/scarlet/utils/EmptyStreamObserver.kt +++ b/scarlet-core-internal/src/main/java/com/tinder/scarlet/utils/EmptyStreamObserver.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ package com.tinder.scarlet.utils diff --git a/scarlet-core-internal/src/main/java/com/tinder/scarlet/utils/FlowableStream.kt b/scarlet-core-internal/src/main/java/com/tinder/scarlet/utils/FlowableStream.kt index 52e227c0..1cc810c2 100644 --- a/scarlet-core-internal/src/main/java/com/tinder/scarlet/utils/FlowableStream.kt +++ b/scarlet-core-internal/src/main/java/com/tinder/scarlet/utils/FlowableStream.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ package com.tinder.scarlet.utils diff --git a/scarlet-core-internal/src/main/java/com/tinder/scarlet/utils/FlowableUtils.kt b/scarlet-core-internal/src/main/java/com/tinder/scarlet/utils/FlowableUtils.kt index f9c735bd..c36de72c 100644 --- a/scarlet-core-internal/src/main/java/com/tinder/scarlet/utils/FlowableUtils.kt +++ b/scarlet-core-internal/src/main/java/com/tinder/scarlet/utils/FlowableUtils.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ @file:JvmName("FlowableUtils") diff --git a/scarlet-core-internal/src/test/java/com/tinder/scarlet/utils/FlowableStreamTest.kt b/scarlet-core-internal/src/test/java/com/tinder/scarlet/utils/FlowableStreamTest.kt index 7f4e2b71..a31d0e05 100644 --- a/scarlet-core-internal/src/test/java/com/tinder/scarlet/utils/FlowableStreamTest.kt +++ b/scarlet-core-internal/src/test/java/com/tinder/scarlet/utils/FlowableStreamTest.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ package com.tinder.scarlet.utils diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/Deserialization.kt b/scarlet-core/src/main/java/com/tinder/scarlet/Deserialization.kt index 23e7c480..421d2717 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/Deserialization.kt +++ b/scarlet-core/src/main/java/com/tinder/scarlet/Deserialization.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ package com.tinder.scarlet diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/Lifecycle.kt b/scarlet-core/src/main/java/com/tinder/scarlet/Lifecycle.kt index c0952d95..23fc04f6 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/Lifecycle.kt +++ b/scarlet-core/src/main/java/com/tinder/scarlet/Lifecycle.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ package com.tinder.scarlet diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/Message.kt b/scarlet-core/src/main/java/com/tinder/scarlet/Message.kt index aa751d0e..2fe20369 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/Message.kt +++ b/scarlet-core/src/main/java/com/tinder/scarlet/Message.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ package com.tinder.scarlet diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/MessageAdapter.kt b/scarlet-core/src/main/java/com/tinder/scarlet/MessageAdapter.kt index 9fe7dab4..5a72ce1a 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/MessageAdapter.kt +++ b/scarlet-core/src/main/java/com/tinder/scarlet/MessageAdapter.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ package com.tinder.scarlet diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/ShutdownReason.kt b/scarlet-core/src/main/java/com/tinder/scarlet/ShutdownReason.kt index 7f8f89f5..3434ac21 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/ShutdownReason.kt +++ b/scarlet-core/src/main/java/com/tinder/scarlet/ShutdownReason.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ package com.tinder.scarlet diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/Stream.kt b/scarlet-core/src/main/java/com/tinder/scarlet/Stream.kt index ea206e1d..347dd75f 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/Stream.kt +++ b/scarlet-core/src/main/java/com/tinder/scarlet/Stream.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ package com.tinder.scarlet diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/StreamAdapter.kt b/scarlet-core/src/main/java/com/tinder/scarlet/StreamAdapter.kt index ca128731..8a1947fe 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/StreamAdapter.kt +++ b/scarlet-core/src/main/java/com/tinder/scarlet/StreamAdapter.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ package com.tinder.scarlet diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/WebSocket.kt b/scarlet-core/src/main/java/com/tinder/scarlet/WebSocket.kt index 40103adb..9449def1 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/WebSocket.kt +++ b/scarlet-core/src/main/java/com/tinder/scarlet/WebSocket.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ package com.tinder.scarlet diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/utils/TypeUtils.kt b/scarlet-core/src/main/java/com/tinder/scarlet/utils/TypeUtils.kt index e302d2ed..1c130124 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/utils/TypeUtils.kt +++ b/scarlet-core/src/main/java/com/tinder/scarlet/utils/TypeUtils.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ @file:JvmName("TypeUtils") diff --git a/scarlet-core/src/main/java/com/tinder/scarlet/utils/Utils.java b/scarlet-core/src/main/java/com/tinder/scarlet/utils/Utils.java index cdf74d50..2073db34 100644 --- a/scarlet-core/src/main/java/com/tinder/scarlet/utils/Utils.java +++ b/scarlet-core/src/main/java/com/tinder/scarlet/utils/Utils.java @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ /* diff --git a/scarlet-core/src/test/java/com/tinder/scarlet/utils/TypeUtilsTest.kt b/scarlet-core/src/test/java/com/tinder/scarlet/utils/TypeUtilsTest.kt index 7c987af4..718ed28c 100644 --- a/scarlet-core/src/test/java/com/tinder/scarlet/utils/TypeUtilsTest.kt +++ b/scarlet-core/src/test/java/com/tinder/scarlet/utils/TypeUtilsTest.kt @@ -1,5 +1,5 @@ /* - * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + * © 2018 Match Group, LLC. */ package com.tinder.scarlet.utils diff --git a/scarlet-lifecycle-android/src/main/AndroidManifest.xml b/scarlet-lifecycle-android/src/main/AndroidManifest.xml index 4e2a5928..a9871764 100755 --- a/scarlet-lifecycle-android/src/main/AndroidManifest.xml +++ b/scarlet-lifecycle-android/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ Date: Fri, 22 Jun 2018 23:53:54 -0700 Subject: [PATCH 12/27] Commiting dependency changes + removing redundant test code --- dependencies.gradle | 2 ++ .../scarlet/streamadapter/coroutines/ReceiveChannelTest.kt | 3 --- settings.gradle | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 87031947..4baa997c 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -19,6 +19,8 @@ ext { rxAndroid = 'io.reactivex.rxjava2:rxandroid:2.0.1' rxKotlin = 'io.reactivex.rxjava2:rxkotlin:2.1.0' rxJava1 = 'io.reactivex:rxjava:1.3.4' + kotlinCoroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.23.3" + kotlinCoroutinesRxInterop = "org.jetbrains.kotlinx:kotlinx-coroutines-reactive:0.23.3" stetho = 'com.facebook.stetho:stetho:1.5.0' stethoOkHttp = 'com.facebook.stetho:stetho-okhttp3:1.5.0' diff --git a/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt index 6bcd498f..4c9bad33 100644 --- a/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt +++ b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt @@ -13,8 +13,6 @@ import com.tinder.scarlet.ws.Send import com.tinder.streamadapter.coroutines.CoroutinesStreamAdapterFactory import kotlinx.coroutines.experimental.* import kotlinx.coroutines.experimental.channels.* -import kotlinx.coroutines.experimental.reactive.publish -import kotlinx.coroutines.experimental.selects.select import kotlinx.coroutines.experimental.test.withTestContext import okhttp3.OkHttpClient import okhttp3.mockwebserver.MockWebServer @@ -73,7 +71,6 @@ class ReceiveChannelTest { } } - var count = 0 withTestContext { runBlocking(this) { assertThat(testBytesSubscriber.receiveOrNull()).isNotNull() diff --git a/settings.gradle b/settings.gradle index 083d08d2..a2d468d9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -12,5 +12,6 @@ include ':scarlet-message-adapter-protobuf' include ':scarlet-message-adapter-gson' include ':scarlet-stream-adapter-rxjava' include ':scarlet-stream-adapter-rxjava2' +include ':scarlet-stream-adapter-coroutines' include ':scarlet-lifecycle-android' include ':demo' From b32f4e3392fb459edb71c56965c70c8488d0215d Mon Sep 17 00:00:00 2001 From: Aaron Weaver Date: Sat, 23 Jun 2018 00:54:48 -0700 Subject: [PATCH 13/27] Refactoring tests --- .../coroutines/ReceiveChannelTest.kt | 86 +++++++++---------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt index 4c9bad33..0115028d 100644 --- a/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt +++ b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt @@ -1,9 +1,6 @@ package com.tinder.scarlet.streamadapter.coroutines -import com.tinder.scarlet.Lifecycle -import com.tinder.scarlet.Scarlet -import com.tinder.scarlet.Stream -import com.tinder.scarlet.WebSocket +import com.tinder.scarlet.* import com.tinder.scarlet.lifecycle.LifecycleRegistry import com.tinder.scarlet.testutils.* import com.tinder.scarlet.websocket.mockwebserver.newWebSocketFactory @@ -13,7 +10,8 @@ import com.tinder.scarlet.ws.Send import com.tinder.streamadapter.coroutines.CoroutinesStreamAdapterFactory import kotlinx.coroutines.experimental.* import kotlinx.coroutines.experimental.channels.* -import kotlinx.coroutines.experimental.test.withTestContext +import kotlinx.coroutines.experimental.reactive.asPublisher +import kotlinx.coroutines.experimental.selects.select import okhttp3.OkHttpClient import okhttp3.mockwebserver.MockWebServer import org.assertj.core.api.Assertions.assertThat @@ -37,46 +35,46 @@ class ReceiveChannelTest { @Test fun send_givenConnectionIsEstablished_shouldBeReceivedByTheServer() { + // Given + givenConnectionIsEstablished() + val textMessage1 = "Hello" + val textMessage2 = "Hi" + val bytesMessage1 = "Yo".toByteArray() + val bytesMessage2 = "Sup".toByteArray() + val testTextSubscriber = server.observeText() + val testBytesSubscriber = server.observeBytes() + + // When + client.sendText(textMessage1) + val isSendTextSuccessful = client.sendTextAndConfirm(textMessage2) + client.sendBytes(bytesMessage1) + val isSendBytesSuccessful = client.sendBytesAndConfirm(bytesMessage2) + + // Then + assertThat(isSendTextSuccessful).isTrue() + assertThat(isSendBytesSuccessful).isTrue() + serverEventObserver.awaitValues( + any>(), + any().containingText(textMessage1), + any().containingText(textMessage2), + any().containingBytes(bytesMessage1), + any().containingBytes(bytesMessage2) + ) + runBlocking { - // Given - givenConnectionIsEstablished() - val textMessage1 = "Hello" - val textMessage2 = "Hi" - val bytesMessage1 = "Yo".toByteArray() - val bytesMessage2 = "Sup".toByteArray() - val testTextSubscriber = server.observeText() - val testBytesSubscriber = server.observeBytes() - - // When - client.sendText(textMessage1) - val isSendTextSuccessful = client.sendTextAndConfirm(textMessage2) - client.sendBytes(bytesMessage1) - val isSendBytesSuccessful = client.sendBytesAndConfirm(bytesMessage2) - - // Then - assertThat(isSendTextSuccessful).isTrue() - assertThat(isSendBytesSuccessful).isTrue() - serverEventObserver.awaitValues( - any>(), - any().containingText(textMessage1), - any().containingText(textMessage2), - any().containingBytes(bytesMessage1), - any().containingBytes(bytesMessage2) - ) - - withTestContext { - runBlocking(this) { - assertThat(testTextSubscriber.receiveOrNull()).isEqualTo(textMessage1) - assertThat(testTextSubscriber.receiveOrNull()).isEqualTo(textMessage2) - } - } - - withTestContext { - runBlocking(this) { - assertThat(testBytesSubscriber.receiveOrNull()).isNotNull() - assertThat(testBytesSubscriber.receiveOrNull()).isNotNull() - } - } + assertThat(testTextSubscriber.receiveOrNull()).isEqualTo(textMessage1) + assertThat(testTextSubscriber.receiveOrNull()).isEqualTo(textMessage2) + val textTimeoutResult = withTimeoutOrNull(10, TimeUnit.MILLISECONDS, { + testTextSubscriber.receiveOrNull() + }) + assertThat(textTimeoutResult).isNull() + + assertThat(testBytesSubscriber.receiveOrNull()).isEqualTo(bytesMessage1) + assertThat(testBytesSubscriber.receiveOrNull()).isEqualTo(bytesMessage2) + val byteTimeoutResult = withTimeoutOrNull(10, TimeUnit.MILLISECONDS, { + testBytesSubscriber.receiveOrNull() + }) + assertThat(byteTimeoutResult).isNull() } } From 36d9017921e3932118519c4e08e17d40e70d4b9b Mon Sep 17 00:00:00 2001 From: Aaron Weaver Date: Sat, 23 Jun 2018 01:19:49 -0700 Subject: [PATCH 14/27] Removing unnecessary timeout additions in tests --- .../streamadapter/coroutines/ReceiveChannelTest.kt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt index 0115028d..b4094ba1 100644 --- a/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt +++ b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt @@ -53,6 +53,7 @@ class ReceiveChannelTest { // Then assertThat(isSendTextSuccessful).isTrue() assertThat(isSendBytesSuccessful).isTrue() + serverEventObserver.awaitValues( any>(), any().containingText(textMessage1), @@ -64,17 +65,9 @@ class ReceiveChannelTest { runBlocking { assertThat(testTextSubscriber.receiveOrNull()).isEqualTo(textMessage1) assertThat(testTextSubscriber.receiveOrNull()).isEqualTo(textMessage2) - val textTimeoutResult = withTimeoutOrNull(10, TimeUnit.MILLISECONDS, { - testTextSubscriber.receiveOrNull() - }) - assertThat(textTimeoutResult).isNull() assertThat(testBytesSubscriber.receiveOrNull()).isEqualTo(bytesMessage1) assertThat(testBytesSubscriber.receiveOrNull()).isEqualTo(bytesMessage2) - val byteTimeoutResult = withTimeoutOrNull(10, TimeUnit.MILLISECONDS, { - testBytesSubscriber.receiveOrNull() - }) - assertThat(byteTimeoutResult).isNull() } } From e80624c2aa2e83e0451db7276992e58811567572 Mon Sep 17 00:00:00 2001 From: Aaron Weaver Date: Sat, 23 Jun 2018 01:27:29 -0700 Subject: [PATCH 15/27] Running ktlint and performing more cleanup --- .../coroutines/ReceiveChannelStreamAdapter.kt | 4 +--- .../coroutines/ReceiveChannelTest.kt | 17 +++++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/ReceiveChannelStreamAdapter.kt b/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/ReceiveChannelStreamAdapter.kt index 31313665..786f89b1 100644 --- a/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/ReceiveChannelStreamAdapter.kt +++ b/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/ReceiveChannelStreamAdapter.kt @@ -7,7 +7,5 @@ import kotlinx.coroutines.experimental.reactive.openSubscription class ReceiveChannelStreamAdapter : StreamAdapter> { - override fun adapt(stream: Stream): ReceiveChannel { - return stream.openSubscription() - } + override fun adapt(stream: Stream) = stream.openSubscription() } \ No newline at end of file diff --git a/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt index b4094ba1..a4a9d84b 100644 --- a/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt +++ b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt @@ -1,17 +1,22 @@ package com.tinder.scarlet.streamadapter.coroutines -import com.tinder.scarlet.* +import com.tinder.scarlet.Lifecycle +import com.tinder.scarlet.Scarlet +import com.tinder.scarlet.Stream +import com.tinder.scarlet.WebSocket import com.tinder.scarlet.lifecycle.LifecycleRegistry -import com.tinder.scarlet.testutils.* +import com.tinder.scarlet.testutils.TestStreamObserver +import com.tinder.scarlet.testutils.any +import com.tinder.scarlet.testutils.test +import com.tinder.scarlet.testutils.containingText +import com.tinder.scarlet.testutils.containingBytes import com.tinder.scarlet.websocket.mockwebserver.newWebSocketFactory import com.tinder.scarlet.websocket.okhttp.newWebSocketFactory import com.tinder.scarlet.ws.Receive import com.tinder.scarlet.ws.Send import com.tinder.streamadapter.coroutines.CoroutinesStreamAdapterFactory -import kotlinx.coroutines.experimental.* -import kotlinx.coroutines.experimental.channels.* -import kotlinx.coroutines.experimental.reactive.asPublisher -import kotlinx.coroutines.experimental.selects.select +import kotlinx.coroutines.experimental.runBlocking +import kotlinx.coroutines.experimental.channels.ReceiveChannel import okhttp3.OkHttpClient import okhttp3.mockwebserver.MockWebServer import org.assertj.core.api.Assertions.assertThat From 86bfdd769003290442bfd4155f75dd9017b80e64 Mon Sep 17 00:00:00 2001 From: Aaron Weaver Date: Sat, 23 Jun 2018 01:28:48 -0700 Subject: [PATCH 16/27] Changing test channel variable names to accurately reflect type --- .../streamadapter/coroutines/ReceiveChannelTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt index a4a9d84b..bf74362c 100644 --- a/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt +++ b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt @@ -46,8 +46,8 @@ class ReceiveChannelTest { val textMessage2 = "Hi" val bytesMessage1 = "Yo".toByteArray() val bytesMessage2 = "Sup".toByteArray() - val testTextSubscriber = server.observeText() - val testBytesSubscriber = server.observeBytes() + val testTextChannel = server.observeText() + val testBytesChannel = server.observeBytes() // When client.sendText(textMessage1) @@ -68,11 +68,11 @@ class ReceiveChannelTest { ) runBlocking { - assertThat(testTextSubscriber.receiveOrNull()).isEqualTo(textMessage1) - assertThat(testTextSubscriber.receiveOrNull()).isEqualTo(textMessage2) + assertThat(testTextChannel.receiveOrNull()).isEqualTo(textMessage1) + assertThat(testTextChannel.receiveOrNull()).isEqualTo(textMessage2) - assertThat(testBytesSubscriber.receiveOrNull()).isEqualTo(bytesMessage1) - assertThat(testBytesSubscriber.receiveOrNull()).isEqualTo(bytesMessage2) + assertThat(testBytesChannel.receiveOrNull()).isEqualTo(bytesMessage1) + assertThat(testBytesChannel.receiveOrNull()).isEqualTo(bytesMessage2) } } From 5f9fc5cd98f974602df456f550626171135df20c Mon Sep 17 00:00:00 2001 From: Aaron Weaver Date: Mon, 25 Jun 2018 19:09:33 -0700 Subject: [PATCH 17/27] Adding copyright to file headers + Updating Readme + Fixing dependencies convention --- README.md | 2 +- dependencies.gradle | 4 ++-- .../coroutines/CoroutinesStreamAdapterFactory.kt | 4 ++++ .../streamadapter/coroutines/ReceiveChannelStreamAdapter.kt | 4 ++++ .../scarlet/streamadapter/coroutines/ReceiveChannelTest.kt | 4 ++++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7c9d83e6..603c3db3 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ implementation 'com.github.tinder.scarlet:scarlet:0.1.2' `StreamAdapter.Factory` - [x] `RxJava2` - [x] `RxJava1` -- [ ] `Kotlin Coroutine` +- [x] `Kotlin Coroutine` `Lifecycle` - [x] `AndroidLifecycle` diff --git a/dependencies.gradle b/dependencies.gradle index 4baa997c..5f757027 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -19,8 +19,8 @@ ext { rxAndroid = 'io.reactivex.rxjava2:rxandroid:2.0.1' rxKotlin = 'io.reactivex.rxjava2:rxkotlin:2.1.0' rxJava1 = 'io.reactivex:rxjava:1.3.4' - kotlinCoroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.23.3" - kotlinCoroutinesRxInterop = "org.jetbrains.kotlinx:kotlinx-coroutines-reactive:0.23.3" + kotlinCoroutines = 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.23.3' + kotlinCoroutinesRxInterop = 'org.jetbrains.kotlinx:kotlinx-coroutines-reactive:0.23.3' stetho = 'com.facebook.stetho:stetho:1.5.0' stethoOkHttp = 'com.facebook.stetho:stetho-okhttp3:1.5.0' diff --git a/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/CoroutinesStreamAdapterFactory.kt b/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/CoroutinesStreamAdapterFactory.kt index 1fa69314..85816d4b 100644 --- a/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/CoroutinesStreamAdapterFactory.kt +++ b/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/CoroutinesStreamAdapterFactory.kt @@ -1,3 +1,7 @@ +/* + * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + */ + package com.tinder.streamadapter.coroutines import com.tinder.scarlet.StreamAdapter diff --git a/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/ReceiveChannelStreamAdapter.kt b/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/ReceiveChannelStreamAdapter.kt index 786f89b1..0cbe36be 100644 --- a/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/ReceiveChannelStreamAdapter.kt +++ b/scarlet-stream-adapter-coroutines/src/main/java/com/tinder/streamadapter/coroutines/ReceiveChannelStreamAdapter.kt @@ -1,3 +1,7 @@ +/* + * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + */ + package com.tinder.streamadapter.coroutines import com.tinder.scarlet.Stream diff --git a/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt index bf74362c..e39d44aa 100644 --- a/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt +++ b/scarlet-stream-adapter-coroutines/src/test/java/com/tinder/scarlet/streamadapter/coroutines/ReceiveChannelTest.kt @@ -1,3 +1,7 @@ +/* + * © 2013 - 2018 Tinder, Inc., ALL RIGHTS RESERVED + */ + package com.tinder.scarlet.streamadapter.coroutines import com.tinder.scarlet.Lifecycle From b803f8fa11e336cafe07c2629442ee3c4c15adf1 Mon Sep 17 00:00:00 2001 From: zhxnlai Date: Tue, 26 Jun 2018 07:31:37 -0700 Subject: [PATCH 18/27] Prepare release 0.1.3 --- README.md | 2 +- publish-jitpack.sh | 2 ++ publish.sh | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 603c3db3..8d2a5301 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ While we are working on Bintray support, Scarlet is available via [JitPack](jitp com.github.tinder.scarlet scarlet - 0.1.2 + 0.1.3 ``` diff --git a/publish-jitpack.sh b/publish-jitpack.sh index 54e6920c..17d1c71e 100755 --- a/publish-jitpack.sh +++ b/publish-jitpack.sh @@ -26,6 +26,8 @@ ./gradlew scarlet-stream-adapter-rxjava:build scarlet-stream-adapter-rxjava:publishToMavenLocal +./gradlew scarlet-stream-adapter-coroutines:build scarlet-stream-adapter-coroutines:publishToMavenLocal + ./gradlew scarlet-websocket-okhttp:build scarlet-websocket-okhttp:publishToMavenLocal ./gradlew scarlet-websocket-mockwebserver:build scarlet-websocket-mockwebserver:publishToMavenLocal diff --git a/publish.sh b/publish.sh index 8a715bf3..8901706a 100755 --- a/publish.sh +++ b/publish.sh @@ -29,6 +29,8 @@ ./gradlew scarlet-stream-adapter-rxjava2:build scarlet-stream-adapter-rxjava2:artifactoryPublish +./gradlew scarlet-stream-adapter-coroutines:build scarlet-stream-adapter-coroutines:artifactoryPublish + ./gradlew scarlet-websocket-okhttp:build scarlet-websocket-okhttp:artifactoryPublish ./gradlew scarlet-websocket-mockwebserver:build scarlet-websocket-mockwebserver:artifactoryPublish From 75a6378a6631255e4d6fe56ef84cc1c6e74d73c9 Mon Sep 17 00:00:00 2001 From: Aaron He Date: Sun, 1 Jul 2018 11:37:03 -0700 Subject: [PATCH 19/27] Add missing `ACCESS_NETWORK_STATE` permission --- scarlet-lifecycle-android/src/main/AndroidManifest.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scarlet-lifecycle-android/src/main/AndroidManifest.xml b/scarlet-lifecycle-android/src/main/AndroidManifest.xml index 4e2a5928..768d30fd 100755 --- a/scarlet-lifecycle-android/src/main/AndroidManifest.xml +++ b/scarlet-lifecycle-android/src/main/AndroidManifest.xml @@ -3,4 +3,7 @@ --> + package="com.tinder.scarlet.lifecycle.android"> + + + From 078d5b180def0cceec7ad4a59f039491820be771 Mon Sep 17 00:00:00 2001 From: Aaron He Date: Sun, 1 Jul 2018 11:43:02 -0700 Subject: [PATCH 20/27] Gradle and ktlint update * Gradle -> 4.8.1 * ktlint -> 0.24.0 * ktlint Gradle plugin -> 4.1.0 --- build.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 968d6076..f1ec1b90 100644 --- a/build.gradle +++ b/build.gradle @@ -18,11 +18,11 @@ buildscript { } plugins { - id 'org.jlleitschuh.gradle.ktlint' version '4.0.0' + id 'org.jlleitschuh.gradle.ktlint' version '4.1.0' } ktlint { - version = '0.23.1' + version = '0.24.0' } subprojects { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1b3c553d..f86d95ae 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip From f18f8afb95903db7cd1b26fca0ff9c28f918958d Mon Sep 17 00:00:00 2001 From: Zhixuan Lai Date: Mon, 9 Jul 2018 10:24:07 -0700 Subject: [PATCH 21/27] Update gradle.properties --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index a482420b..49bc55ca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=0.1.1 +version=0.1.4 From 83918b55832ac4e0044ac244b38af200b00251fc Mon Sep 17 00:00:00 2001 From: Zhixuan Lai Date: Mon, 9 Jul 2018 10:26:54 -0700 Subject: [PATCH 22/27] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8d2a5301..6a76f90c 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ gdaxService.observeTicker() ~~~ ### Android -Scarlet is driven by a [StateMachine](https://github.com/Tinder/StateMachine). +Scarlet is driven by a [StateMachine][state-machine]. @@ -69,7 +69,7 @@ TODO Download -------- -While we are working on Bintray support, Scarlet is available via [JitPack](jitpack). +While we are working on Bintray support, Scarlet is available via [JitPack][jitpack]. ##### Maven: ```xml @@ -153,5 +153,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [demo-app]: /demo/src/main/java/com/tinder/app [tutorial]: https://tech.gotinder.com/taming-websocket-with-scarlet/ [slides]: https://speakerdeck.com/zhxnlai/taming-websocket-with-scarlet - [kotliners]:https://www.conferenceforkotliners.com/ - [jitpack]: https://jitpack.io/ + [kotliners]: https://www.conferenceforkotliners.com/ + [state-machine]: https://github.com/Tinder/StateMachine + [jitpack]: https://jitpack.io/#tinder/scarlet From abca79051832f567a376b37f0907fe5d0155c10e Mon Sep 17 00:00:00 2001 From: Zhixuan Lai Date: Mon, 9 Jul 2018 10:28:21 -0700 Subject: [PATCH 23/27] Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6a76f90c..4b3bddf1 100644 --- a/README.md +++ b/README.md @@ -74,24 +74,24 @@ While we are working on Bintray support, Scarlet is available via [JitPack][jitp ##### Maven: ```xml - jitpack.io - https://jitpack.io + jitpack.io + https://jitpack.io - com.github.tinder.scarlet - scarlet - 0.1.3 + com.github.tinder.scarlet + scarlet + 0.1.4 ``` ##### Gradle: ```groovy repositories { - // ... - maven { url "https://jitpack.io" } + // ... + maven { url "https://jitpack.io" } } -implementation 'com.github.tinder.scarlet:scarlet:0.1.2' +implementation 'com.github.tinder.scarlet:scarlet:0.1.4' ``` ### Plug-in Roadmap From bfad3f6a4394a16babed66495963ea21033ebc3c Mon Sep 17 00:00:00 2001 From: zhxnlai Date: Thu, 12 Jul 2018 18:10:13 -0700 Subject: [PATCH 24/27] Update kotlin version --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index a8fd5e4c..c695c0b5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.2.10' + ext.kotlin_version = '1.2.51' ext.dokka_version = '0.9.16' repositories { google() @@ -37,4 +37,4 @@ subprojects { } } -apply from: rootProject.file('dependencies.gradle') \ No newline at end of file +apply from: rootProject.file('dependencies.gradle') From be745bd686e99966fd0560286599894c532e637f Mon Sep 17 00:00:00 2001 From: zhxnlai Date: Mon, 16 Jul 2018 15:17:43 -0700 Subject: [PATCH 25/27] Update dependencies --- dependencies.gradle | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 5f757027..122469c4 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -15,9 +15,9 @@ ext { multiDex = 'com.android.support:multidex:1.0.2' reactiveStreams = 'org.reactivestreams:reactive-streams:1.0.2' - rxJava = 'io.reactivex.rxjava2:rxjava:2.1.6' - rxAndroid = 'io.reactivex.rxjava2:rxandroid:2.0.1' - rxKotlin = 'io.reactivex.rxjava2:rxkotlin:2.1.0' + rxJava = 'io.reactivex.rxjava2:rxjava:2.1.16' + rxAndroid = 'io.reactivex.rxjava2:rxandroid:2.0.2' + rxKotlin = 'io.reactivex.rxjava2:rxkotlin:2.2.0' rxJava1 = 'io.reactivex:rxjava:1.3.4' kotlinCoroutines = 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.23.3' kotlinCoroutinesRxInterop = 'org.jetbrains.kotlinx:kotlinx-coroutines-reactive:0.23.3' @@ -26,8 +26,11 @@ ext { stethoOkHttp = 'com.facebook.stetho:stetho-okhttp3:1.5.0' moshi = 'com.squareup.moshi:moshi-kotlin:1.5.0' + moshiCodeGen = 'com.squareup.moshi:moshi-kotlin-codegen:1.6.0' gson = 'com.google.code.gson:gson:2.8.2' protobuf = 'com.google.protobuf:protobuf-java:3.4.0' + jacksonDatabind = 'com.fasterxml.jackson.core:jackson-databind:2.9.5' + jsonPatch = 'com.github.fge:json-patch:1.9' dagger = 'com.google.dagger:dagger:2.12' daggerCompiler = 'com.google.dagger:dagger-compiler:2.12' @@ -39,16 +42,17 @@ ext { jodaTime = 'joda-time:joda-time:2.9.9' glide = 'com.github.bumptech.glide:glide:4.5.0' - okHttp = 'com.squareup.okhttp3:okhttp:3.8.1' - okHttpLoggingInterceptor = 'com.squareup.okhttp3:logging-interceptor:3.8.1' + okHttp = 'com.squareup.okhttp3:okhttp:3.11.0' + okHttpLoggingInterceptor = 'com.squareup.okhttp3:logging-interceptor:3.11.0' okio = 'com.squareup.okio:okio:1.13.0' - mockWebServer = 'com.squareup.okhttp3:mockwebserver:3.8.1' + mockWebServer = 'com.squareup.okhttp3:mockwebserver:3.11.0' timber = 'com.jakewharton.timber:timber:4.6.0' + okSse = 'com.github.heremaps:oksse:0.9.0' junit = 'junit:junit:4.12' - mockito = 'com.nhaarman:mockito-kotlin-kt1.1:1.5.0' + mockito = 'com.nhaarman:mockito-kotlin-kt1.1:1.6.0' assertJ = 'org.assertj:assertj-core:3.8.0' - kotlinStdlib = "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" + kotlinStdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" kotlinReflect = "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" } From 30baf7b802f40ba9d8ce20e27cbc9076d3782554 Mon Sep 17 00:00:00 2001 From: zhxnlai Date: Mon, 16 Jul 2018 15:29:47 -0700 Subject: [PATCH 26/27] Unwrap optional --- .../java/com/tinder/app/echo/domain/AuthStatusRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/src/main/java/com/tinder/app/echo/domain/AuthStatusRepository.kt b/demo/src/main/java/com/tinder/app/echo/domain/AuthStatusRepository.kt index 1a0ea09f..4ec16515 100644 --- a/demo/src/main/java/com/tinder/app/echo/domain/AuthStatusRepository.kt +++ b/demo/src/main/java/com/tinder/app/echo/domain/AuthStatusRepository.kt @@ -14,7 +14,7 @@ class AuthStatusRepository @Inject constructor() { private val authStatusProcessor = BehaviorProcessor.createDefault(AuthStatus.LOGGED_IN) - fun getAuthStatus(): AuthStatus = authStatusProcessor.value + fun getAuthStatus(): AuthStatus = authStatusProcessor.value!! fun observeAuthStatus(): Flowable = authStatusProcessor From 7395f469dbc70ea0bfd343ee1cc3ea48a1de91ba Mon Sep 17 00:00:00 2001 From: Vishesh Vadhera Date: Thu, 9 Aug 2018 00:28:48 +0530 Subject: [PATCH 27/27] Replace escaped string literals with raw ones in gson and moshi adapter tests --- .../gson/GsonMessageAdapterTest.kt | 4 ++-- .../moshi/MoshiMessageAdapterTest.kt | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scarlet-message-adapter-gson/src/test/java/com/tinder/scarlet/messageadapter/gson/GsonMessageAdapterTest.kt b/scarlet-message-adapter-gson/src/test/java/com/tinder/scarlet/messageadapter/gson/GsonMessageAdapterTest.kt index 526c8fad..e0e7c18a 100644 --- a/scarlet-message-adapter-gson/src/test/java/com/tinder/scarlet/messageadapter/gson/GsonMessageAdapterTest.kt +++ b/scarlet-message-adapter-gson/src/test/java/com/tinder/scarlet/messageadapter/gson/GsonMessageAdapterTest.kt @@ -52,7 +52,7 @@ internal class GsonMessageAdapterTest { // Given givenConnectionIsEstablished() val data = AnImplementation("value") - val expectedString = "{\"name\":\"value\"}" + val expectedString = """{"name":"value"}""" val serverAnImplementationObserver = server.observeAnImplementation().test() // When @@ -72,7 +72,7 @@ internal class GsonMessageAdapterTest { // Given givenConnectionIsEstablished() val data = AnImplementation("value") - val expectedString = "{\"name\":\"value\"}" + val expectedString = """{"name":"value"}""" val serverAnImplementationObserver = server.observeAnImplementation().test() // When diff --git a/scarlet-message-adapter-moshi/src/test/java/com/tinder/scarlet/messageadapter/moshi/MoshiMessageAdapterTest.kt b/scarlet-message-adapter-moshi/src/test/java/com/tinder/scarlet/messageadapter/moshi/MoshiMessageAdapterTest.kt index eec8a633..f0d9dc59 100644 --- a/scarlet-message-adapter-moshi/src/test/java/com/tinder/scarlet/messageadapter/moshi/MoshiMessageAdapterTest.kt +++ b/scarlet-message-adapter-moshi/src/test/java/com/tinder/scarlet/messageadapter/moshi/MoshiMessageAdapterTest.kt @@ -53,7 +53,7 @@ internal class MoshiMessageAdapterTest { // Given givenConnectionIsEstablished() val data = AnImplementation("value") - val expectedSerializedData = "{\"name\":\"value\"}" + val expectedSerializedData = """{"name":"value"}""" val serverAnImplementationObserver = server.observeAnImplementation().test() // When @@ -75,7 +75,7 @@ internal class MoshiMessageAdapterTest { // Given givenConnectionIsEstablished() val data = AnImplementation("value") - val expectedSerializedData = "{\"name\":\"value\"}" + val expectedSerializedData = """{"name":"value"}""" val serverAnImplementationObserver = server.observeAnImplementation().test() // When @@ -97,7 +97,7 @@ internal class MoshiMessageAdapterTest { // Given givenConnectionIsEstablished() val data = "value" - val expectedSerializedData = "\"qualified!\"" + val expectedSerializedData = """"qualified!"""" val expectedDeserializedSerializedData = "it worked!" val serverAnnotatedStringObserver = server.observeAnnotatedString().test() @@ -119,7 +119,7 @@ internal class MoshiMessageAdapterTest { fun sendRawString_givenJsonIsMalformed_andFactoryIsLenient_shouldBeReceivedByTheServer() { // Given givenConnectionIsEstablished(Factory.Config(lenient = true)) - val malformedJson = "{\"name\":value}" + val malformedJson = """{"name":value}""" val serverAnImplementationObserver = server.observeAnImplementation().test() // When @@ -139,7 +139,7 @@ internal class MoshiMessageAdapterTest { fun sendRawString_givenJsonIsMalformed_andFactoryIsNotLenient_shouldNotBeReceivedByTheServer() { // Given givenConnectionIsEstablished() - val malformedJson = "{\"name\":value}" + val malformedJson = """{"name":value}""" val serverAnImplementationObserver = server.observeAnImplementation().test() // When @@ -177,7 +177,7 @@ internal class MoshiMessageAdapterTest { fun sendRawString_givenJsonHasUnknownKeys_andFactoryFailsOnUnknown_shouldNotBeReceivedByTheServer() { // Given givenConnectionIsEstablished(Factory.Config(lenient = true, serializeNull = true, failOnUnknown = true)) - val jsonWithUnknownKeys = "{\"taco\":\"delicious\"}" + val jsonWithUnknownKeys = """{"taco":"delicious"}""" val serverAnImplementationObserver = server.observeAnImplementation().test() // When @@ -197,7 +197,7 @@ internal class MoshiMessageAdapterTest { givenConnectionIsEstablished(Factory.Config()) val jsonWithUtf8Bom = Buffer() .write(ByteString.decodeHex("EFBBBF")) - .writeUtf8("{\"name\":\"value\"}") + .writeUtf8("""{"name":"value"}""") .readByteString() .toByteArray() val serverAnImplementationObserver = server.observeAnImplementation().test() @@ -221,7 +221,7 @@ internal class MoshiMessageAdapterTest { givenConnectionIsEstablished(Factory.Config()) val jsonWithUtf16Bom = Buffer() .write(ByteString.decodeHex("FEFF")) - .writeString("{\"name\":\"value\"}", Charset.forName("UTF-16")) + .writeString("""{"name":"value"}""", Charset.forName("UTF-16")) .readByteString() .toByteArray() val serverAnImplementationObserver = server.observeAnImplementation().test() @@ -307,7 +307,7 @@ internal class MoshiMessageAdapterTest { ): JsonAdapter<*>? { for (annotation in annotations) { assert(annotation.annotationClass.java.isAnnotationPresent(JsonQualifier::class.java)) { - "Non-@JsonQualifier annotation: " + annotation + "Non-@JsonQualifier annotation: $annotation" } } return null @@ -350,7 +350,7 @@ internal class MoshiMessageAdapterTest { if (string == "qualified!") { return "it worked!" } - throw AssertionError("Found: " + string) + throw AssertionError("Found: $string") } }