File tree 2 files changed +36
-1
lines changed
reactive-crypto-binance/src/test/kotlin/com/njkim/reactivecrypto/binance
reactive-crypto-core/src/main/kotlin/com/njkim/reactivecrypto/core
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2019 namjug-kim
3
+ *
4
+ * LINE Corporation licenses this file to you under the Apache License,
5
+ * version 2.0 (the "License"); you may not use this file except in compliance
6
+ * with the License. You may obtain a copy of the License at:
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ * License for the specific language governing permissions and limitations
14
+ * under the License.
15
+ */
16
+
1
17
package com.njkim.reactivecrypto.binance
2
18
3
19
import com.njkim.reactivecrypto.core.ExchangeClientFactory
@@ -15,4 +31,13 @@ class ExchangeClientFactoryTest {
15
31
assertThat(exchangeWebsocketClient).isInstanceOf(ExchangeWebsocketClient ::class .java)
16
32
assertThat(exchangeWebsocketClient).isExactlyInstanceOf(BinanceWebsocketClient ::class .java)
17
33
}
18
- }
34
+
35
+ @Test
36
+ fun `create binance websocket client using string` () {
37
+ val exchangeWebsocketClient = ExchangeClientFactory .websocket(" BINANCE" )
38
+
39
+ assertThat(exchangeWebsocketClient).isNotNull
40
+ assertThat(exchangeWebsocketClient).isInstanceOf(ExchangeWebsocketClient ::class .java)
41
+ assertThat(exchangeWebsocketClient).isExactlyInstanceOf(BinanceWebsocketClient ::class .java)
42
+ }
43
+ }
Original file line number Diff line number Diff line change @@ -25,6 +25,16 @@ import kotlin.reflect.full.createInstance
25
25
26
26
class ExchangeClientFactory {
27
27
companion object {
28
+ init {
29
+ ExchangeVendor .values()
30
+ .forEach { exchangeVendor ->
31
+ ReactiveCryptoPlugins .customClientFactory
32
+ .addHttpCustomFactory(exchangeVendor.name) { http(exchangeVendor) }
33
+ ReactiveCryptoPlugins .customClientFactory
34
+ .addWsCustomFactory(exchangeVendor.name) { websocket(exchangeVendor) }
35
+ }
36
+ }
37
+
28
38
@JvmStatic
29
39
fun websocket (exchangeVendor : ExchangeVendor ): ExchangeWebsocketClient {
30
40
return websocket(exchangeVendor.websocketClientName)
You can’t perform that action at this time.
0 commit comments