@Test void testNoDuplicates() throws Exception { String platform = "GITHUB"; String platformId = "FundRequest|FR|area51|FR|3"; when(tokenWhitelistPreconditionContract.amountOftokens().send().intValue()).thenReturn(3); when(tokenWhitelistPreconditionContract.token(BigInteger.valueOf(0))).thenReturn(Optional.of("FND")); when(tokenWhitelistPreconditionContract.token(BigInteger.valueOf(1))).thenReturn(Optional.of("ZRX")); when(tokenWhitelistPreconditionContract.token(BigInteger.valueOf(2))).thenReturn(Optional.of("ZRX")); when(tokenInfoService.getTokenInfo("FND")).thenReturn(TokenInfoDto.builder().symbol("FND").address("FND").build()); when(tokenInfoService.getTokenInfo("ZRX")).thenReturn(TokenInfoDto.builder().symbol("ZRX").address("ZRX").build()); when(tokenWhitelistPreconditionContract.isValid(platform, platformId, "FND")).thenReturn(true); when(tokenWhitelistPreconditionContract.isValid(platform, platformId, "ZRX")).thenReturn(true); List<TokenInfoDto> possibleTokens = fundRequestContractsService.getAllPossibleTokens(platform, platformId); assertThat(possibleTokens.stream().map(TokenInfoDto::getSymbol).collect(Collectors.toList())).containsExactly("FND", "ZRX"); }
@Cacheable(value = "possible_tokens", keyGenerator = "getAllPossibleTokensKeyGenerator") public List<TokenInfoDto> getAllPossibleTokens(final String platform, final String platformId) { return checkNotEmpty(getAllPossibleTokens().stream() .filter(token -> tokenWhitelistPreconditionContract.isValid(platform, platformId, token.getAddress())) .collect(Collectors.toList())); }
FundRequestContractsService { @Cacheable(value = "possible_tokens", keyGenerator = "getAllPossibleTokensKeyGenerator") public List<TokenInfoDto> getAllPossibleTokens(final String platform, final String platformId) { return checkNotEmpty(getAllPossibleTokens().stream() .filter(token -> tokenWhitelistPreconditionContract.isValid(platform, platformId, token.getAddress())) .collect(Collectors.toList())); } }
FundRequestContractsService { @Cacheable(value = "possible_tokens", keyGenerator = "getAllPossibleTokensKeyGenerator") public List<TokenInfoDto> getAllPossibleTokens(final String platform, final String platformId) { return checkNotEmpty(getAllPossibleTokens().stream() .filter(token -> tokenWhitelistPreconditionContract.isValid(platform, platformId, token.getAddress())) .collect(Collectors.toList())); } FundRequestContractsService(final FundRequestContract fundRequestContract,
                                       final TokenWhitelistPreconditionContract tokenWhitelistPreconditionContract,
                                       final Web3j web3j,
                                       final TokenInfoService tokenInfoService); }
FundRequestContractsService { @Cacheable(value = "possible_tokens", keyGenerator = "getAllPossibleTokensKeyGenerator") public List<TokenInfoDto> getAllPossibleTokens(final String platform, final String platformId) { return checkNotEmpty(getAllPossibleTokens().stream() .filter(token -> tokenWhitelistPreconditionContract.isValid(platform, platformId, token.getAddress())) .collect(Collectors.toList())); } FundRequestContractsService(final FundRequestContract fundRequestContract,
                                       final TokenWhitelistPreconditionContract tokenWhitelistPreconditionContract,
                                       final Web3j web3j,
                                       final TokenInfoService tokenInfoService); FundRepositoryContract fundRepository(); ClaimRepositoryContract claimRepository(); @PostConstruct void init(); @Cacheable(value = "possible_tokens", keyGenerator = "getAllPossibleTokensKeyGenerator") List<TokenInfoDto> getAllPossibleTokens(final String platform, final String platformId); }
FundRequestContractsService { @Cacheable(value = "possible_tokens", keyGenerator = "getAllPossibleTokensKeyGenerator") public List<TokenInfoDto> getAllPossibleTokens(final String platform, final String platformId) { return checkNotEmpty(getAllPossibleTokens().stream() .filter(token -> tokenWhitelistPreconditionContract.isValid(platform, platformId, token.getAddress())) .collect(Collectors.toList())); } FundRequestContractsService(final FundRequestContract fundRequestContract,
                                       final TokenWhitelistPreconditionContract tokenWhitelistPreconditionContract,
                                       final Web3j web3j,
                                       final TokenInfoService tokenInfoService); FundRepositoryContract fundRepository(); ClaimRepositoryContract claimRepository(); @PostConstruct void init(); @Cacheable(value = "possible_tokens", keyGenerator = "getAllPossibleTokensKeyGenerator") List<TokenInfoDto> getAllPossibleTokens(final String platform, final String platformId);  }