private Security assertSecurity(List<Item> results) { Optional<Item> item = results.stream().filter(i -> i instanceof SecurityItem).findFirst(); assertThat(item.isPresent(), is(true)); Security security = ((SecurityItem) item.get()).getSecurity(); assertThat(security.getIsin(), is("DE000BASF111")); assertThat(security.getWkn(), is("BASF11")); assertThat(security.getName(), is("BASF SE")); assertThat(security.getCurrencyCode(), is(CurrencyUnit.EUR)); return security; }
@Test public void testErtragsgutschrift2() throws IOException { DeutscheBankPDFExctractor extractor = new DeutscheBankPDFExctractor(new Client()) { @Override String strip(File file) throws IOException { return from(file.getName()); } }; List<Exception> errors = new ArrayList<Exception>(); List<Item> results = extractor.extract(Arrays.asList(new File("DeutscheBankErtragsgutschrift2.txt")), errors); assertThat(errors, empty()); assertThat(results.size(), is(2)); new AssertImportActions().check(results, CurrencyUnit.EUR); // check security Security security = results.stream().filter(i -> i instanceof SecurityItem).findFirst().get().getSecurity(); assertThat(security.getName(), is("ISHS-MSCI N. AMERIC.UCITS ETF BE.SH.(DT.ZT.)")); assertThat(security.getIsin(), is("DE000A0J2060")); assertThat(security.getWkn(), is("A0J206")); assertThat(security.getCurrencyCode(), is("USD")); // check transaction Optional<Item> item = results.stream().filter(i -> i instanceof TransactionItem).findFirst(); assertThat(item.isPresent(), is(true)); assertThat(item.get().getSubject(), instanceOf(AccountTransaction.class)); AccountTransaction transaction = (AccountTransaction) item.get().getSubject(); assertThat(transaction.getType(), is(AccountTransaction.Type.DIVIDENDS)); assertThat(transaction.getSecurity(), is(security)); assertThat(transaction.getDate(), is(LocalDate.parse("2015-03-24"))); assertThat(transaction.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 16_17L))); assertThat(transaction.getShares(), is(Values.Share.factorize(123))); Optional<Unit> grossValue = transaction.getUnit(Unit.Type.GROSS_VALUE); assertThat(grossValue.isPresent(), is(true)); assertThat(grossValue.get().getAmount(), is(Money.of("EUR", 16_17L))); assertThat(grossValue.get().getForex(), is(Money.of("USD", 17_38L))); assertThat( grossValue.get().getExchangeRate().doubleValue(), IsCloseTo.closeTo(0.930578, 0.000001)); }