@Test public void canReadStatementsFile() throws IOException { PolicyAccountRepository policyAccountRepository = new MockPolicyAccountRepository(); InPaymentRegistrationService inPaymentRegistrationService = new InPaymentRegistrationService(policyAccountRepository); PolicyAccount account231232132131 = policyAccountRepository.findByPolicyAccountNumber("231232132131").get(); assertEquals(BigDecimal.ZERO, account231232132131.balanceAt(LocalDate.of(2019,12,31))); File testData = createTestData(); inPaymentRegistrationService.registerInPayments(testData.getParent(), LocalDate.of(2018, Month.AUGUST, 2)); testData.delete(); assertEquals(new BigDecimal("10.21"), account231232132131.balanceAt(LocalDate.of(2019,12,31))); }
@Transactional public void registerInPayments(String directory, LocalDate date) { BankStatementFile fileToImport = new BankStatementFile(directory, date); if (!fileToImport.exists()) { return; } List<BankStatement> bankStatements = fileToImport.read(); bankStatements.forEach(this::registerInPayment); fileToImport.markProcessed(); }
InPaymentRegistrationService { @Transactional public void registerInPayments(String directory, LocalDate date) { BankStatementFile fileToImport = new BankStatementFile(directory, date); if (!fileToImport.exists()) { return; } List<BankStatement> bankStatements = fileToImport.read(); bankStatements.forEach(this::registerInPayment); fileToImport.markProcessed(); } }
InPaymentRegistrationService { @Transactional public void registerInPayments(String directory, LocalDate date) { BankStatementFile fileToImport = new BankStatementFile(directory, date); if (!fileToImport.exists()) { return; } List<BankStatement> bankStatements = fileToImport.read(); bankStatements.forEach(this::registerInPayment); fileToImport.markProcessed(); }  }
InPaymentRegistrationService { @Transactional public void registerInPayments(String directory, LocalDate date) { BankStatementFile fileToImport = new BankStatementFile(directory, date); if (!fileToImport.exists()) { return; } List<BankStatement> bankStatements = fileToImport.read(); bankStatements.forEach(this::registerInPayment); fileToImport.markProcessed(); }  @Transactional void registerInPayments(String directory, LocalDate date); }
InPaymentRegistrationService { @Transactional public void registerInPayments(String directory, LocalDate date) { BankStatementFile fileToImport = new BankStatementFile(directory, date); if (!fileToImport.exists()) { return; } List<BankStatement> bankStatements = fileToImport.read(); bankStatements.forEach(this::registerInPayment); fileToImport.markProcessed(); }  @Transactional void registerInPayments(String directory, LocalDate date);  }