use of name.abuchen.portfolio.datatransfer.Extractor.Item in project portfolio by buchen.
the class CSVPortfolioTransactionExtractorTest method testRequiredFieldDate.
@Test
public void testRequiredFieldDate() {
Client client = new Client();
CSVExtractor extractor = new CSVPortfolioTransactionExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(0, Arrays.<String[]>asList(new String[] { "", "DE0007164600", "", "", "SAP SE", "100", "EUR", "11", "", "", "", "", "1,9", "BUY", "Notiz" }), buildField2Column(extractor), errors);
assertThat(results, empty());
assertThat(errors.size(), is(1));
}
use of name.abuchen.portfolio.datatransfer.Extractor.Item in project portfolio by buchen.
the class CSVPortfolioTransactionExtractorTest method testBuyTransaction.
@Test
public void testBuyTransaction() throws ParseException {
Client client = new Client();
Security security = new Security();
security.setTickerSymbol("SAP.DE");
client.addSecurity(security);
CSVExtractor extractor = new CSVPortfolioTransactionExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(0, Arrays.<String[]>asList(new String[] { "2013-01-02", "DE0007164600", "SAP.DE", "", "SAP SE", "100", "EUR", "11", "", "", "", "", "1,9", "BUY", "Notiz" }), buildField2Column(extractor), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.EUR);
BuySellEntry entry = (BuySellEntry) results.stream().filter(i -> i instanceof BuySellEntryItem).findAny().get().getSubject();
PortfolioTransaction t = entry.getPortfolioTransaction();
assertThat(t.getType(), is(PortfolioTransaction.Type.BUY));
assertThat(t.getMonetaryAmount(), is(Money.of(CurrencyUnit.EUR, 100_00)));
assertThat(t.getNote(), is("Notiz"));
assertThat(t.getDateTime(), is(LocalDateTime.parse("2013-01-02T00:00")));
assertThat(t.getShares(), is(Values.Share.factorize(1.9)));
assertThat(t.getSecurity(), is(security));
assertThat(t.getUnitSum(Unit.Type.FEE), is(Money.of("EUR", 11_00)));
assertThat(t.getUnit(Unit.Type.TAX).isPresent(), is(false));
AccountTransaction at = entry.getAccountTransaction();
assertThat(at.getType(), is(AccountTransaction.Type.BUY));
assertThat(at.getUnitSum(Unit.Type.FEE), is(Money.of("EUR", 0)));
}
use of name.abuchen.portfolio.datatransfer.Extractor.Item in project portfolio by buchen.
the class CSVSecurityExtractorTest method testSecurityCreation.
@Test
public void testSecurityCreation() throws ParseException {
Client client = new Client();
CSVExtractor extractor = new CSVSecurityExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(0, Arrays.<String[]>asList(new String[] { "DE0007164600", "716460", "SAP.DE", "SAP SE", "EUR", "Notiz" }), buildField2Column(extractor), errors);
assertThat(errors, empty());
assertThat(results.size(), is(1));
new AssertImportActions().check(results, CurrencyUnit.EUR);
Security security = results.stream().filter(i -> i instanceof SecurityItem).findAny().get().getSecurity();
assertThat(security.getName(), is("SAP SE"));
assertThat(security.getIsin(), is("DE0007164600"));
assertThat(security.getWkn(), is("716460"));
assertThat(security.getTickerSymbol(), is("SAP.DE"));
assertThat(security.getCurrencyCode(), is("EUR"));
assertThat(security.getNote(), is("Notiz"));
}
use of name.abuchen.portfolio.datatransfer.Extractor.Item in project portfolio by buchen.
the class CSVSecurityPriceExtractorTest method testErrorIfAmountIsMissing.
@Test
public void testErrorIfAmountIsMissing() throws ParseException {
Client client = new Client();
CSVExtractor extractor = new CSVSecurityPriceExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(0, //
Arrays.<String[]>asList(new String[] { "2015-01-01", "" }), buildField2Column(extractor), errors);
assertThat(errors.size(), is(1));
assertThat(results, empty());
}
use of name.abuchen.portfolio.datatransfer.Extractor.Item in project portfolio by buchen.
the class CSVSecurityPriceExtractorTest method testErrorIfDateIsMissing.
@Test
public void testErrorIfDateIsMissing() throws ParseException {
Client client = new Client();
CSVExtractor extractor = new CSVSecurityPriceExtractor(client);
List<Exception> errors = new ArrayList<Exception>();
List<Item> results = extractor.extract(0, //
Arrays.<String[]>asList(new String[] { "", "14,20" }), buildField2Column(extractor), errors);
assertThat(errors.size(), is(1));
assertThat(results, empty());
}
Aggregations