@Test public void save() { TokenInfoDto token = TokenInfoDtoMother.fnd(); PendingFundCommand command = PendingFundCommand.builder() .amount("1.2") .description("description") .fromAddress("0x0") .tokenAddress(token.getAddress()) .platform(Platform.GITHUB) .platformId("FundRequest|FR|area51|FR|12") .transactionId("0x3") .build(); when(tokenInfoService.getTokenInfo(token.getAddress())).thenReturn(token); Principal davyvanroy = PrincipalMother.davyvanroy(); pendingFundService.save(davyvanroy, command); ArgumentCaptor<PendingFund> pendingFundArgumentCaptor = ArgumentCaptor.forClass(PendingFund.class); verify(pendingFundRepository).save(pendingFundArgumentCaptor.capture()); PendingFund pendingFund = pendingFundArgumentCaptor.getValue(); assertThat(pendingFund.getAmount()).isEqualTo(new BigInteger("1200000000000000000")); assertThat(pendingFund.getTokenAddress()).isEqualTo(command.getTokenAddress()); assertThat(pendingFund.getDescription()).isEqualTo(command.getDescription()); assertThat(pendingFund.getTransactionHash()).isEqualTo(command.getTransactionId()); assertThat(pendingFund.getFromAddress()).isEqualTo(command.getFromAddress()); assertThat(pendingFund.getUserId()).isEqualTo(davyvanroy.getName()); }
@Transactional public void save(final Principal principal, final PendingFundCommand command) { final IssueInformation issueInformation = githubLinkParser.parseIssue(command.getPlatformId()); final PendingFund pf = PendingFund.builder() .amount(toWei(command)) .description(command.getDescription()) .fromAddress(command.getFromAddress()) .tokenAddress(command.getTokenAddress()) .transactionhash(command.getTransactionId()) .issueInformation(issueInformation) .userId(principal == null ? null : principal.getName()) .build(); pendingFundRepository.save(pf); }
PendingFundService { @Transactional public void save(final Principal principal, final PendingFundCommand command) { final IssueInformation issueInformation = githubLinkParser.parseIssue(command.getPlatformId()); final PendingFund pf = PendingFund.builder() .amount(toWei(command)) .description(command.getDescription()) .fromAddress(command.getFromAddress()) .tokenAddress(command.getTokenAddress()) .transactionhash(command.getTransactionId()) .issueInformation(issueInformation) .userId(principal == null ? null : principal.getName()) .build(); pendingFundRepository.save(pf); } }
PendingFundService { @Transactional public void save(final Principal principal, final PendingFundCommand command) { final IssueInformation issueInformation = githubLinkParser.parseIssue(command.getPlatformId()); final PendingFund pf = PendingFund.builder() .amount(toWei(command)) .description(command.getDescription()) .fromAddress(command.getFromAddress()) .tokenAddress(command.getTokenAddress()) .transactionhash(command.getTransactionId()) .issueInformation(issueInformation) .userId(principal == null ? null : principal.getName()) .build(); pendingFundRepository.save(pf); } PendingFundService(final PendingFundRepository pendingFundRepository,
                              final GithubPlatformIdParser githubLinkParser,
                              final Mappers mappers,
                              final TokenInfoService tokenInfoService); }
PendingFundService { @Transactional public void save(final Principal principal, final PendingFundCommand command) { final IssueInformation issueInformation = githubLinkParser.parseIssue(command.getPlatformId()); final PendingFund pf = PendingFund.builder() .amount(toWei(command)) .description(command.getDescription()) .fromAddress(command.getFromAddress()) .tokenAddress(command.getTokenAddress()) .transactionhash(command.getTransactionId()) .issueInformation(issueInformation) .userId(principal == null ? null : principal.getName()) .build(); pendingFundRepository.save(pf); } PendingFundService(final PendingFundRepository pendingFundRepository,
                              final GithubPlatformIdParser githubLinkParser,
                              final Mappers mappers,
                              final TokenInfoService tokenInfoService); @Transactional(readOnly = true) List<PendingFund> findAll(); @Transactional void save(final Principal principal, final PendingFundCommand command); @Transactional void removePendingFund(final String transactionHash); @Transactional void removePendingFund(final PendingFund pendingFund); @Transactional(readOnly = true) List<PendingFundDto> findByUser(final Principal principal); }
PendingFundService { @Transactional public void save(final Principal principal, final PendingFundCommand command) { final IssueInformation issueInformation = githubLinkParser.parseIssue(command.getPlatformId()); final PendingFund pf = PendingFund.builder() .amount(toWei(command)) .description(command.getDescription()) .fromAddress(command.getFromAddress()) .tokenAddress(command.getTokenAddress()) .transactionhash(command.getTransactionId()) .issueInformation(issueInformation) .userId(principal == null ? null : principal.getName()) .build(); pendingFundRepository.save(pf); } PendingFundService(final PendingFundRepository pendingFundRepository,
                              final GithubPlatformIdParser githubLinkParser,
                              final Mappers mappers,
                              final TokenInfoService tokenInfoService); @Transactional(readOnly = true) List<PendingFund> findAll(); @Transactional void save(final Principal principal, final PendingFundCommand command); @Transactional void removePendingFund(final String transactionHash); @Transactional void removePendingFund(final PendingFund pendingFund); @Transactional(readOnly = true) List<PendingFundDto> findByUser(final Principal principal);  }