@Bean public PaymentLogService paymentLogService() { return new PaymentLogService(); } }
@Bean public InvestorService investorService(InvestorRepository investorRepository) { return new InvestorService(investorRepository); }
private BigInteger getTotalRemainingTomics() { return getTotalTomicsAmount().subtract(saleTierService.getTotalTomicsSold()); }
@Test public void testGetInvestorByEmail() { try { Investor investorFromDb = investorService.getInvestorByEmail("test@test.com"); assertEquals(investor, investorFromDb); } catch(InvestorNotFoundException e) { fail(e.getMessage()); } } }
private SaleTier createAndSaveSaleTier(int tierNo, Date startDate, Date endDate, BigDecimal discount, BigInteger tomicsMax, boolean hasDynamicDuration, boolean hasDynamicMax) { SaleTier t = new SaleTier( tierNo, "test tier " + tierNo, startDate, endDate, discount, BigInteger.ZERO, tomicsMax, hasDynamicDuration, hasDynamicMax); return saleTierService.saveTransactionless(t); }
private Investor createInvestor() { try { return investorService.getInvestorByEmail(INVESTOR_EMAIL); } catch (InvestorNotFoundException e) { return investorService.saveTransactionless( new Investor(new java.util.Date(), INVESTOR_EMAIL, "token", "walletAddress", "payInEtherPublicKey", "payInBitcoinPublicKey", "refundEtherAddress", "refundBitcoinAddress", "ipAddress")); } }
@Test public void testAddKeyPairsIfNotPresent_New() { KeyPairs k1 = new KeyPairs("testPublicBtc", "testPublicEth", true); Optional<KeyPairs> resultFind = keyPairsRepositoryService.findByPublicBtc("testPublicBtc"); assertFalse(resultFind.isPresent()); boolean result1 = keyPairsRepositoryService.addKeyPairsIfNotPresent(k1); assertTrue(result1); }
private static boolean allBTCAreUnique(int uniqueEntries, List<KeyPairs> keyPairsList) { return keyPairsList.stream().filter(distinctKeyPair(KeyPairs::getPublicBtc)).count() == uniqueEntries; }
@Bean public EligibleForRefundService eligibleForRefundService() { return new EligibleForRefundService(); }
@Bean public SaleTierService saleTierService() { return new SaleTierService(); }
private Investor createAndSaveInvestor(ECKey key) { return investorService.saveTransactionless(buildInvestor(key)); }
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public PaymentLog createRefundEntryForPaymentLogAndCommit( PaymentLog paymentLog, RefundReason reason) throws RefundEntryAlreadyExistsException { paymentLog = createRefundEntryForAmount(paymentLog, reason, paymentLog.getCryptocurrencyAmount(), paymentLog.getUsdAmount()); return paymentLogService.updateProcessedDateAndSave(paymentLog); }
@Override public Investor getAssociatedInvestor() throws MissingTransactionInformationException { try { return getInvestorService().getInvestorByBitcoinAddress(getReceivingAddress()); } catch (MissingTransactionInformationException e) { throw e; } catch (Exception e) { throw new MissingTransactionInformationException("Couldn't fetch associated investor.", e); } }
@Override public Investor getAssociatedInvestor() throws MissingTransactionInformationException { try { return getInvestorService().getInvestorByEthereumAddress(getReceivingAddress()); } catch (MissingTransactionInformationException e) { throw e; } catch (Exception e) { throw new MissingTransactionInformationException("Couldn't fetch associated investor.", e); } }
@Transactional(propagation = Propagation.REQUIRED) public PaymentLog createNewPaymentLog(TransactionAdapter tx, TransactionStatus transactionStatus) throws MissingTransactionInformationException { try { return paymentLogService.save(new PaymentLog( tx.getTransactionId(), tx.getCurrencyType(), transactionStatus)); } catch (DataIntegrityViolationException e) { // The payment log was probably created by another instance just now. // This is not an error because the other instance will process the transaction. return null; } }
private PaymentLog createRefundEntryForAmount( PaymentLog paymentLog, RefundReason reason, BigInteger cryptocurrencyAmount, BigDecimal usdAmount) throws RefundEntryAlreadyExistsException { EligibleForRefund refund = eligibleForRefundService.save( new EligibleForRefund(reason, cryptocurrencyAmount, usdAmount, paymentLog.getCurrency(), paymentLog.getInvestor(), paymentLog.getTransactionId())); paymentLog.setEligibleForRefund(refund); return paymentLog; }
private void createAndSaveTier() { Date from = Date.from(Instant.EPOCH); Date to = new Date(); BigInteger tomics = monitorService.convertTokensToTomics(new BigDecimal(1000L)) .toBigInteger(); saleTierService.saveTransactionless( new SaleTier(4, "4", from, to, new BigDecimal("0.0"), BigInteger.ZERO, tomics, true, false)); }
@Bean public PaymentLogService paymentLogService() { return new PaymentLogService(); }
@Bean public InvestorService investorService(InvestorRepository investorRepository) { return new InvestorService(investorRepository); }
private static boolean allETHAreUnique(int uniqueEntries, List<KeyPairs> keyPairsList) { return keyPairsList.stream().filter(distinctKeyPair(KeyPairs::getPublicEth)).count() == uniqueEntries; }