Skip to content

Commit

Permalink
feat: convert exchangeVendor from to enum class to data class using s…
Browse files Browse the repository at this point in the history
…tatic fields
  • Loading branch information
traeper committed Jul 3, 2019
1 parent aed0e42 commit 5627851
Show file tree
Hide file tree
Showing 35 changed files with 178 additions and 140 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.njkim.reactivecrypto.binance;

import com.njkim.reactivecrypto.core.common.model.ExchangeVendor;
import com.njkim.reactivecrypto.core.common.model.currency.Currency;
import com.njkim.reactivecrypto.core.common.model.currency.CurrencyPair;
import com.njkim.reactivecrypto.core.common.model.order.OrderBook;
import com.njkim.reactivecrypto.core.common.model.order.TickData;
Expand Down Expand Up @@ -29,7 +30,7 @@ public void binance_tick_data_subscribe() {
assertThat(tickData.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(tickData.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BINANCE);
.isEqualTo(ExchangeVendor.BINANCE);
assertThat(tickData.getPrice())
.isGreaterThan(BigDecimal.ZERO);
assertThat(tickData.getQuantity())
Expand All @@ -51,7 +52,7 @@ public void binance_orderBook_subscribe() {
assertThat(orderBook.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(orderBook.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BINANCE);
.isEqualTo(ExchangeVendor.BINANCE);
assertThat(orderBook.getAsks())
.isNotEmpty();
assertThat(orderBook.getBids())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ class BinanceWebsocketClientTest {
// when
val tickData = binanceWebsocketClient.blockFirst(Duration.ofSeconds(10))!!
log.info { tickData }
log.info { tickData.exchangeVendor.toString() }

// then
Assertions.assertThat(tickData).isNotNull
Assertions.assertThat(tickData.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(tickData.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BINANCE)
.isEqualTo(ExchangeVendor.BINANCE)
Assertions.assertThat(tickData.price)
.isGreaterThan(BigDecimal.ZERO)
Assertions.assertThat(tickData.quantity)
Expand All @@ -50,7 +51,7 @@ class BinanceWebsocketClientTest {
Assertions.assertThat(orderBook.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(orderBook.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BINANCE)
.isEqualTo(ExchangeVendor.BINANCE)
Assertions.assertThat(orderBook.asks)
.isNotEmpty
Assertions.assertThat(orderBook.bids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void bithumb_tick_data_subscribe() {
assertThat(tickData.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(tickData.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITHUMB);
.isEqualTo(ExchangeVendor.BITHUMB);
assertThat(tickData.getPrice())
.isGreaterThan(BigDecimal.ZERO);
assertThat(tickData.getQuantity())
Expand All @@ -41,7 +41,7 @@ public void bithumb_tick_data_subscribe() {
assertThat(tickData.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(tickData.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITHUMB);
.isEqualTo(ExchangeVendor.BITHUMB);
assertThat(tickData.getPrice())
.isGreaterThan(BigDecimal.ZERO);
assertThat(tickData.getQuantity())
Expand All @@ -66,7 +66,7 @@ public void bithumb_orderBook_subscribe() {
assertThat(orderBook.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(orderBook.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITHUMB);
.isEqualTo(ExchangeVendor.BITHUMB);
assertThat(orderBook.getAsks())
.isNotEmpty();
assertThat(orderBook.getBids())
Expand All @@ -93,7 +93,7 @@ public void bithumb_orderBook_subscribe() {
assertThat(orderBook.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(orderBook.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITHUMB);
.isEqualTo(ExchangeVendor.BITHUMB);
assertThat(orderBook.getAsks())
.isNotEmpty();
assertThat(orderBook.getBids())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BithumbWebsocketClientTest {
Assertions.assertThat(targetCurrencyPairs.contains(it.currencyPair))
.isTrue()
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITHUMB)
.isEqualTo(ExchangeVendor.BITHUMB)
Assertions.assertThat(it.price)
.isGreaterThan(BigDecimal.ZERO)
Assertions.assertThat(it.quantity)
Expand All @@ -42,7 +42,7 @@ class BithumbWebsocketClientTest {
Assertions.assertThat(targetCurrencyPairs.contains(it.currencyPair))
.isTrue()
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITHUMB)
.isEqualTo(ExchangeVendor.BITHUMB)
Assertions.assertThat(it.price)
.isGreaterThan(BigDecimal.ZERO)
Assertions.assertThat(it.quantity)
Expand All @@ -68,7 +68,7 @@ class BithumbWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITHUMB)
.isEqualTo(ExchangeVendor.BITHUMB)
Assertions.assertThat(it.asks)
.isNotEmpty
Assertions.assertThat(it.bids)
Expand All @@ -95,7 +95,7 @@ class BithumbWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITHUMB)
.isEqualTo(ExchangeVendor.BITHUMB)
Assertions.assertThat(it.asks)
.isNotEmpty
Assertions.assertThat(it.bids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void tick_data_subscribe() {
assertThat(tickData.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(tickData.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITMAX);
.isEqualTo(ExchangeVendor.BITMAX);
assertThat(tickData.getPrice())
.isGreaterThan(BigDecimal.ZERO);
assertThat(tickData.getQuantity())
Expand All @@ -57,7 +57,7 @@ public void tick_data_subscribe() {
assertThat(tickData.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(tickData.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITMAX);
.isEqualTo(ExchangeVendor.BITMAX);
assertThat(tickData.getPrice())
.isGreaterThan(BigDecimal.ZERO);
assertThat(tickData.getQuantity())
Expand All @@ -82,7 +82,7 @@ public void bitmax_orderBook_subscribe() {
assertThat(orderBook.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(orderBook.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITMAX);
.isEqualTo(ExchangeVendor.BITMAX);
assertThat(orderBook.getAsks())
.isNotEmpty();
assertThat(orderBook.getBids())
Expand All @@ -109,7 +109,7 @@ public void bitmax_orderBook_subscribe() {
assertThat(orderBook.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(orderBook.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITMAX);
.isEqualTo(ExchangeVendor.BITMAX);
assertThat(orderBook.getAsks())
.isNotEmpty();
assertThat(orderBook.getBids())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BitmaxWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITMAX)
.isEqualTo(ExchangeVendor.BITMAX)
Assertions.assertThat(it.price)
.isGreaterThan(BigDecimal.ZERO)
Assertions.assertThat(it.quantity)
Expand All @@ -55,7 +55,7 @@ class BitmaxWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITMAX)
.isEqualTo(ExchangeVendor.BITMAX)
Assertions.assertThat(it.price)
.isGreaterThan(BigDecimal.ZERO)
Assertions.assertThat(it.quantity)
Expand Down Expand Up @@ -83,7 +83,7 @@ class BitmaxWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITMAX)
.isEqualTo(ExchangeVendor.BITMAX)
Assertions.assertThat(it.asks)
.isNotEmpty
Assertions.assertThat(it.bids)
Expand Down Expand Up @@ -112,7 +112,7 @@ class BitmaxWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITMAX)
.isEqualTo(ExchangeVendor.BITMAX)
Assertions.assertThat(it.asks)
.isNotEmpty
Assertions.assertThat(it.bids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void bitmex_tick_data_subscribe() {
assertThat(tickData.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(tickData.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITMEX);
.isEqualTo(ExchangeVendor.BITMEX);
assertThat(tickData.getPrice())
.isGreaterThan(BigDecimal.ZERO);
assertThat(tickData.getQuantity())
Expand All @@ -57,7 +57,7 @@ public void bitmex_tick_data_subscribe() {
assertThat(tickData.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(tickData.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITMEX);
.isEqualTo(ExchangeVendor.BITMEX);
assertThat(tickData.getPrice())
.isGreaterThan(BigDecimal.ZERO);
assertThat(tickData.getQuantity())
Expand All @@ -82,7 +82,7 @@ public void bitmex_orderBook_subscribe() {
assertThat(orderBook.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(orderBook.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITMEX);
.isEqualTo(ExchangeVendor.BITMEX);
assertThat(orderBook.getAsks())
.isNotEmpty();
assertThat(orderBook.getBids())
Expand All @@ -109,7 +109,7 @@ public void bitmex_orderBook_subscribe() {
assertThat(orderBook.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(orderBook.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITMEX);
.isEqualTo(ExchangeVendor.BITMEX);
assertThat(orderBook.getAsks())
.isNotEmpty();
assertThat(orderBook.getBids())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BitmexWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITMEX)
.isEqualTo(ExchangeVendor.BITMEX)
Assertions.assertThat(it.price)
.isGreaterThan(BigDecimal.ZERO)
Assertions.assertThat(it.quantity)
Expand All @@ -54,7 +54,7 @@ class BitmexWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITMEX)
.isEqualTo(ExchangeVendor.BITMEX)
Assertions.assertThat(it.price)
.isGreaterThan(BigDecimal.ZERO)
Assertions.assertThat(it.quantity)
Expand All @@ -80,7 +80,7 @@ class BitmexWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITMEX)
.isEqualTo(ExchangeVendor.BITMEX)
Assertions.assertThat(it.asks)
.isNotEmpty
Assertions.assertThat(it.bids)
Expand All @@ -107,7 +107,7 @@ class BitmexWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITMEX)
.isEqualTo(ExchangeVendor.BITMEX)
Assertions.assertThat(it.asks)
.isNotEmpty
Assertions.assertThat(it.bids)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void tick_data_subscribe() {
assertThat(tickData.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(tickData.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITSTAMP);
.isEqualTo(ExchangeVendor.BITSTAMP);
assertThat(tickData.getPrice())
.isGreaterThan(BigDecimal.ZERO);
assertThat(tickData.getQuantity())
Expand All @@ -58,7 +58,7 @@ public void tick_data_subscribe() {
assertThat(tickData.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(tickData.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITSTAMP);
.isEqualTo(ExchangeVendor.BITSTAMP);
assertThat(tickData.getPrice())
.isGreaterThan(BigDecimal.ZERO);
assertThat(tickData.getQuantity())
Expand All @@ -83,7 +83,7 @@ public void orderBook_subscribe() {
assertThat(orderBook.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(orderBook.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITSTAMP);
.isEqualTo(ExchangeVendor.BITSTAMP);
assertThat(orderBook.getAsks())
.isNotEmpty();
assertThat(orderBook.getBids())
Expand All @@ -110,7 +110,7 @@ public void orderBook_subscribe() {
assertThat(orderBook.getCurrencyPair())
.isEqualTo(targetCurrencyPair);
assertThat(orderBook.getExchangeVendor())
.isEqualByComparingTo(ExchangeVendor.BITSTAMP);
.isEqualTo(ExchangeVendor.BITSTAMP);
assertThat(orderBook.getAsks())
.isNotEmpty();
assertThat(orderBook.getBids())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BitstampWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITSTAMP)
.isEqualTo(ExchangeVendor.BITSTAMP)
Assertions.assertThat(it.price)
.isGreaterThan(BigDecimal.ZERO)
Assertions.assertThat(it.quantity)
Expand All @@ -54,7 +54,7 @@ class BitstampWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITSTAMP)
.isEqualTo(ExchangeVendor.BITSTAMP)
Assertions.assertThat(it.price)
.isGreaterThan(BigDecimal.ZERO)
Assertions.assertThat(it.quantity)
Expand All @@ -80,7 +80,7 @@ class BitstampWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITSTAMP)
.isEqualTo(ExchangeVendor.BITSTAMP)
Assertions.assertThat(it.asks)
.isNotEmpty
Assertions.assertThat(it.bids)
Expand All @@ -107,7 +107,7 @@ class BitstampWebsocketClientTest {
Assertions.assertThat(it.currencyPair)
.isEqualTo(targetCurrencyPair)
Assertions.assertThat(it.exchangeVendor)
.isEqualByComparingTo(ExchangeVendor.BITSTAMP)
.isEqualTo(ExchangeVendor.BITSTAMP)
Assertions.assertThat(it.asks)
.isNotEmpty
Assertions.assertThat(it.bids)
Expand Down

0 comments on commit 5627851

Please sign in to comment.