@Test public void whenFindByIdCalledWithUnknownIdThenReturnNullMarketConfig() { expect(ConfigurationManager.loadConfig(eq(MarketsType.class), eq(MARKETS_CONFIG_YAML_FILENAME))) .andReturn(allTheInternalMarketsConfig()); PowerMock.replayAll(); final MarketConfigRepository marketConfigRepository = new MarketConfigYamlRepository(); final MarketConfig marketConfig = marketConfigRepository.findById(UNKNOWN_MARKET_ID); assertThat(marketConfig).isNull(); PowerMock.verifyAll(); }
@Override public MarketConfig findById(String id) { LOG.info(() -> "Fetching Market config for id: " + id); final MarketsType marketsType = ConfigurationManager.loadConfig(MarketsType.class, MARKETS_CONFIG_YAML_FILENAME); return adaptInternalToExternalConfig( marketsType.getMarkets().stream() .filter(item -> item.getId().equals(id)) .distinct() .collect(Collectors.toList())); }
MarketConfigYamlRepository implements MarketConfigRepository { @Override public MarketConfig findById(String id) { LOG.info(() -> "Fetching Market config for id: " + id); final MarketsType marketsType = ConfigurationManager.loadConfig(MarketsType.class, MARKETS_CONFIG_YAML_FILENAME); return adaptInternalToExternalConfig( marketsType.getMarkets().stream() .filter(item -> item.getId().equals(id)) .distinct() .collect(Collectors.toList())); } }
MarketConfigYamlRepository implements MarketConfigRepository { @Override public MarketConfig findById(String id) { LOG.info(() -> "Fetching Market config for id: " + id); final MarketsType marketsType = ConfigurationManager.loadConfig(MarketsType.class, MARKETS_CONFIG_YAML_FILENAME); return adaptInternalToExternalConfig( marketsType.getMarkets().stream() .filter(item -> item.getId().equals(id)) .distinct() .collect(Collectors.toList())); }  }
MarketConfigYamlRepository implements MarketConfigRepository { @Override public MarketConfig findById(String id) { LOG.info(() -> "Fetching Market config for id: " + id); final MarketsType marketsType = ConfigurationManager.loadConfig(MarketsType.class, MARKETS_CONFIG_YAML_FILENAME); return adaptInternalToExternalConfig( marketsType.getMarkets().stream() .filter(item -> item.getId().equals(id)) .distinct() .collect(Collectors.toList())); }  @Override List<MarketConfig> findAll(); @Override MarketConfig findById(String id); @Override MarketConfig save(MarketConfig config); @Override MarketConfig delete(String id); }
MarketConfigYamlRepository implements MarketConfigRepository { @Override public MarketConfig findById(String id) { LOG.info(() -> "Fetching Market config for id: " + id); final MarketsType marketsType = ConfigurationManager.loadConfig(MarketsType.class, MARKETS_CONFIG_YAML_FILENAME); return adaptInternalToExternalConfig( marketsType.getMarkets().stream() .filter(item -> item.getId().equals(id)) .distinct() .collect(Collectors.toList())); }  @Override List<MarketConfig> findAll(); @Override MarketConfig findById(String id); @Override MarketConfig save(MarketConfig config); @Override MarketConfig delete(String id);  }