Skip to content

Commit

Permalink
test: Fix more Sonar test whines (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
gazbert committed Nov 14, 2024
1 parent de5a44a commit 76eb7d1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,21 @@ void whenGetCalledThenReturnExchangeConfig() {
assertThat(exchangeConfig.getName()).isEqualTo(EXCHANGE_NAME);
assertThat(exchangeConfig.getAdapter()).isEqualTo(EXCHANGE_ADAPTER);

assertThat(exchangeConfig.getAuthenticationConfig().get(API_KEY_CONFIG_ITEM_KEY))
.isEqualTo(API_KEY_CONFIG_ITEM_VALUE);
assertThat(exchangeConfig.getAuthenticationConfig().get(SECRET_CONFIG_ITEM_KEY))
.isEqualTo(SECRET_CONFIG_ITEM_VALUE);
assertThat(exchangeConfig.getAuthenticationConfig())
.containsEntry(API_KEY_CONFIG_ITEM_KEY, API_KEY_CONFIG_ITEM_VALUE);
assertThat(exchangeConfig.getAuthenticationConfig())
.containsEntry(SECRET_CONFIG_ITEM_KEY, SECRET_CONFIG_ITEM_VALUE);

assertThat(exchangeConfig.getNetworkConfig().getConnectionTimeout())
.isEqualTo(CONNECTION_TIMEOUT);
assertThat(exchangeConfig.getNetworkConfig().getNonFatalErrorCodes())
.isEqualTo(NON_FATAL_ERROR_CODES);
assertThat(exchangeConfig.getNetworkConfig().getNonFatalErrorMessages())
.isEqualTo(NON_FATAL_ERROR_MESSAGES);
assertThat(exchangeConfig.getOtherConfig().get(BUY_FEE_CONFIG_ITEM_KEY))
.isEqualTo(BUY_FEE_CONFIG_ITEM_VALUE);
assertThat(exchangeConfig.getOtherConfig().get(SELL_FEE_CONFIG_ITEM_KEY))
.isEqualTo(SELL_FEE_CONFIG_ITEM_VALUE);
assertThat(exchangeConfig.getOtherConfig())
.containsEntry(BUY_FEE_CONFIG_ITEM_KEY, BUY_FEE_CONFIG_ITEM_VALUE);
assertThat(exchangeConfig.getOtherConfig())
.containsEntry(SELL_FEE_CONFIG_ITEM_KEY, SELL_FEE_CONFIG_ITEM_VALUE);

EasyMock.verify(configurationManager);
}
Expand All @@ -133,21 +133,21 @@ void whenSaveCalledThenExpectRepositoryToSaveItAndReturnSavedExchangeConfig() {
assertThat(savedExchangeConfig.getName()).isEqualTo(EXCHANGE_NAME);
assertThat(savedExchangeConfig.getAdapter()).isEqualTo(EXCHANGE_ADAPTER);

assertThat(savedExchangeConfig.getAuthenticationConfig().get(API_KEY_CONFIG_ITEM_KEY))
.isEqualTo(API_KEY_CONFIG_ITEM_VALUE);
assertThat(savedExchangeConfig.getAuthenticationConfig().get(SECRET_CONFIG_ITEM_KEY))
.isEqualTo(SECRET_CONFIG_ITEM_VALUE);
assertThat(savedExchangeConfig.getAuthenticationConfig())
.containsEntry(API_KEY_CONFIG_ITEM_KEY, API_KEY_CONFIG_ITEM_VALUE);
assertThat(savedExchangeConfig.getAuthenticationConfig())
.containsEntry(SECRET_CONFIG_ITEM_KEY, SECRET_CONFIG_ITEM_VALUE);

assertThat(savedExchangeConfig.getNetworkConfig().getConnectionTimeout())
.isEqualTo(CONNECTION_TIMEOUT);
assertThat(savedExchangeConfig.getNetworkConfig().getNonFatalErrorCodes())
.isEqualTo(NON_FATAL_ERROR_CODES);
assertThat(savedExchangeConfig.getNetworkConfig().getNonFatalErrorMessages())
.isEqualTo(NON_FATAL_ERROR_MESSAGES);
assertThat(savedExchangeConfig.getOtherConfig().get(BUY_FEE_CONFIG_ITEM_KEY))
.isEqualTo(BUY_FEE_CONFIG_ITEM_VALUE);
assertThat(savedExchangeConfig.getOtherConfig().get(SELL_FEE_CONFIG_ITEM_KEY))
.isEqualTo(SELL_FEE_CONFIG_ITEM_VALUE);
assertThat(savedExchangeConfig.getOtherConfig())
.containsEntry(BUY_FEE_CONFIG_ITEM_KEY, BUY_FEE_CONFIG_ITEM_VALUE);
assertThat(savedExchangeConfig.getOtherConfig())
.containsEntry(SELL_FEE_CONFIG_ITEM_KEY, SELL_FEE_CONFIG_ITEM_VALUE);

EasyMock.verify(configurationManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void whenFindAllCalledThenExpectServiceToReturnAllMarketConfigs() {
new MarketConfigYamlRepository(configurationManager);
final List<MarketConfig> marketConfigItems = marketConfigRepository.findAll();

assertThat(marketConfigItems.size()).isEqualTo(2);
assertThat(marketConfigItems).hasSize(2);

assertThat(marketConfigItems.get(0).getId()).isEqualTo(MARKET_1_ID);
assertThat(marketConfigItems.get(0).getName()).isEqualTo(MARKET_1_NAME);
Expand Down Expand Up @@ -181,7 +181,7 @@ void whenSaveCalledWithUnknownIdThenReturnEmptyMarketConfig() {
final MarketConfig marketConfig =
marketConfigRepository.save(someExternalMarketConfigWithUnknownId());

assertThat(marketConfig).isEqualTo(null);
assertThat(marketConfig).isNull();
EasyMock.verify(configurationManager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
import static org.junit.jupiter.api.Assertions.assertNull;

import com.gazbert.bxbot.datastore.yaml.ConfigurationManager;
import com.gazbert.bxbot.datastore.yaml.strategy.StrategiesType;
Expand Down Expand Up @@ -159,7 +158,7 @@ void whenFindByIdCalledWithUnknownIdThenReturnNullStrategyConfig() {
new StrategyConfigYamlRepository(configurationManager);
final StrategyConfig strategyConfig = strategyConfigRepository.findById(UNKNOWN_STRAT_ID);

assertNull(strategyConfig);
assertThat(strategyConfig).isNull();
EasyMock.verify(configurationManager);
}

Expand Down Expand Up @@ -213,7 +212,7 @@ void whenSaveCalledWithUnknownIdThenReturnEmptyStrategyConfig() {
final StrategyConfig strategyConfig =
strategyConfigRepository.save(someExternalStrategyConfigWithUnknownId());

assertNull(strategyConfig);
assertThat(strategyConfig).isNull();
EasyMock.verify(configurationManager);
}

Expand Down Expand Up @@ -293,7 +292,7 @@ void whenDeleteCalledWithUnknownIdThenReturnEmptyStrategyConfig() {
new StrategyConfigYamlRepository(configurationManager);
final StrategyConfig strategyConfig = strategyConfigRepository.delete(UNKNOWN_STRAT_ID);

assertNull(strategyConfig);
assertThat(strategyConfig).isNull();
EasyMock.verify(configurationManager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void whenCanTokenBeRefreshedCalledWithValidTokenThenExpectReturnFalse() {

// Valid as token created after password last changed
final boolean canBeRefreshed = jwtUtils.canTokenBeRefreshed(tokenClaims, DateUtil.yesterday());
assertThat(canBeRefreshed).isEqualTo(true);
assertThat(canBeRefreshed).isTrue();
}

// ------------------------------------------------------------------------
Expand Down

0 comments on commit 76eb7d1

Please sign in to comment.