Search in sources :

Example 21 with Classification

use of name.abuchen.portfolio.model.Classification in project portfolio by buchen.

the class ClassificationTestCase method testCase6_Account30Account80.

@Test
public void testCase6_Account30Account80() {
    Taxonomy case1 = client.getTaxonomies().stream().filter(t -> "case_6".equals(t.getName())).findAny().orElseThrow(IllegalArgumentException::new);
    // check performance of 'subcategory'
    Classification ccategory = case1.getAllClassifications().stream().filter(c -> "category".equals(c.getName())).findAny().orElseThrow(IllegalArgumentException::new);
    Client categoryClient = new ClientClassificationFilter(ccategory).filter(client);
    List<PortfolioTransaction> txp = categoryClient.getPortfolios().stream().flatMap(p -> p.getTransactions().stream()).collect(Collectors.toList());
    assertThat(txp, hasSize(0));
    List<AccountTransaction> txa = categoryClient.getAccounts().stream().filter(a -> "Konto 1".equals(a.getName())).flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-02T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(2397.60 * 0.3)))))));
    // check that transfer between two accounts is created
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-25T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.TRANSFER_IN)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(100 * 0.3)))))));
    txa = categoryClient.getAccounts().stream().filter(a -> "Konto 2".equals(a.getName())).flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-25T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.TRANSFER_OUT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(100 * 0.3)))))));
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-25T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(100 * 0.5)))))));
    // create index
    List<Exception> warnings = new ArrayList<>();
    PerformanceIndex index_subcategory = PerformanceIndex.forClassification(client, converter, ccategory, interval, warnings);
    assertThat(warnings.isEmpty(), is(true));
    assertThat(index_subcategory.getTotals()[index_subcategory.getTotals().length - 1], is(Values.Amount.factorize(802.34)));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) BeforeClass(org.junit.BeforeClass) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) LocalDateTime(java.time.LocalDateTime) Classification(name.abuchen.portfolio.model.Classification) ArrayList(java.util.ArrayList) TestCurrencyConverter(name.abuchen.portfolio.TestCurrencyConverter) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Assert.assertThat(org.junit.Assert.assertThat) ClientClassificationFilter(name.abuchen.portfolio.snapshot.filter.ClientClassificationFilter) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) ClientFactory(name.abuchen.portfolio.model.ClientFactory) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) Taxonomy(name.abuchen.portfolio.model.Taxonomy) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) Test(org.junit.Test) Security(name.abuchen.portfolio.model.Security) Collectors(java.util.stream.Collectors) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) PerformanceIndex(name.abuchen.portfolio.snapshot.PerformanceIndex) List(java.util.List) LocalDate(java.time.LocalDate) Taxonomy(name.abuchen.portfolio.model.Taxonomy) ArrayList(java.util.ArrayList) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) PerformanceIndex(name.abuchen.portfolio.snapshot.PerformanceIndex) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) ClientClassificationFilter(name.abuchen.portfolio.snapshot.filter.ClientClassificationFilter) Classification(name.abuchen.portfolio.model.Classification) Client(name.abuchen.portfolio.model.Client) Test(org.junit.Test)

Example 22 with Classification

use of name.abuchen.portfolio.model.Classification in project portfolio by buchen.

the class ClassificationTestCase method testCase10_Security30Account100_SecuritySold.

@Test
public void testCase10_Security30Account100_SecuritySold() {
    Taxonomy case10 = client.getTaxonomies().stream().filter(t -> "case_10".equals(t.getName())).findAny().orElseThrow(IllegalArgumentException::new);
    // check performance of 'subcategory'
    Classification ccategory = case10.getAllClassifications().stream().filter(c -> "category".equals(c.getName())).findAny().orElseThrow(IllegalArgumentException::new);
    Client categoryClient = new ClientClassificationFilter(ccategory).filter(client);
    List<PortfolioTransaction> txp = categoryClient.getPortfolios().stream().flatMap(p -> p.getTransactions().stream()).collect(Collectors.toList());
    assertThat(txp, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-10T00:00"))), // 
    hasProperty("type", is(PortfolioTransaction.Type.SELL)), // 
    hasProperty("shares", is(Values.Share.factorize(74.8 * 0.3d))), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(698.36 * 0.3d)))))));
    List<AccountTransaction> txa = categoryClient.getAccounts().stream().flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-10T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.SELL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(698.36 * 0.3)))))));
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-10T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.DEPOSIT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(688.36 - (698.36 * 0.3))))))));
    // create index
    List<Exception> warnings = new ArrayList<>();
    PerformanceIndex index_subcategory = PerformanceIndex.forClassification(client, converter, ccategory, interval, warnings);
    assertThat(warnings.isEmpty(), is(true));
    assertThat(index_subcategory.getTotals()[index_subcategory.getTotals().length - 1], is(Values.Amount.factorize(534.86)));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) BeforeClass(org.junit.BeforeClass) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) LocalDateTime(java.time.LocalDateTime) Classification(name.abuchen.portfolio.model.Classification) ArrayList(java.util.ArrayList) TestCurrencyConverter(name.abuchen.portfolio.TestCurrencyConverter) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Assert.assertThat(org.junit.Assert.assertThat) ClientClassificationFilter(name.abuchen.portfolio.snapshot.filter.ClientClassificationFilter) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) ClientFactory(name.abuchen.portfolio.model.ClientFactory) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) Taxonomy(name.abuchen.portfolio.model.Taxonomy) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) Test(org.junit.Test) Security(name.abuchen.portfolio.model.Security) Collectors(java.util.stream.Collectors) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) PerformanceIndex(name.abuchen.portfolio.snapshot.PerformanceIndex) List(java.util.List) LocalDate(java.time.LocalDate) Taxonomy(name.abuchen.portfolio.model.Taxonomy) ArrayList(java.util.ArrayList) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) PerformanceIndex(name.abuchen.portfolio.snapshot.PerformanceIndex) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) ClientClassificationFilter(name.abuchen.portfolio.snapshot.filter.ClientClassificationFilter) Classification(name.abuchen.portfolio.model.Classification) Client(name.abuchen.portfolio.model.Client) Test(org.junit.Test)

Example 23 with Classification

use of name.abuchen.portfolio.model.Classification in project portfolio by buchen.

the class ClassificationTestCase method testCase3_Security30Account50.

@Test
public void testCase3_Security30Account50() {
    Taxonomy case1 = client.getTaxonomies().stream().filter(t -> "case_3".equals(t.getName())).findAny().orElseThrow(IllegalArgumentException::new);
    // check performance of 'subcategory'
    Classification subcategory = case1.getAllClassifications().stream().filter(c -> "subcategory".equals(c.getName())).findAny().orElseThrow(IllegalArgumentException::new);
    Client subcategoryClient = new ClientClassificationFilter(subcategory).filter(client);
    List<PortfolioTransaction> txp = subcategoryClient.getPortfolios().stream().flatMap(p -> p.getTransactions().stream()).collect(Collectors.toList());
    assertThat(txp, hasSize(1));
    assertThat(txp, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-02T00:00"))), // 
    hasProperty("type", is(PortfolioTransaction.Type.BUY)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(2397.60 * 0.3d)))))));
    List<AccountTransaction> txa = subcategoryClient.getAccounts().stream().flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-02T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.BUY)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(2397.60 * 0.3d)))))));
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-02T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(2397.60 * 0.2d)))))));
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-01T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(1019.80 / 2d)))))));
    // check that dividend is included without taxes
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-10T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.DIVIDENDS)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(24.44 * 0.3d)))))));
    // check correction for dividend payment (w/o taxes and only 50%)
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-10T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.DEPOSIT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(19.44 / 2 - 24.44 * 0.3d)))))));
    // create index
    List<Exception> warnings = new ArrayList<>();
    PerformanceIndex index_subcategory = PerformanceIndex.forClassification(client, converter, subcategory, interval, warnings);
    assertThat(warnings.isEmpty(), is(true));
    assertThat(index_subcategory.getTotals()[index_subcategory.getTotals().length - 1], is(Values.Amount.factorize(1391.40)));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) BeforeClass(org.junit.BeforeClass) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) LocalDateTime(java.time.LocalDateTime) Classification(name.abuchen.portfolio.model.Classification) ArrayList(java.util.ArrayList) TestCurrencyConverter(name.abuchen.portfolio.TestCurrencyConverter) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Assert.assertThat(org.junit.Assert.assertThat) ClientClassificationFilter(name.abuchen.portfolio.snapshot.filter.ClientClassificationFilter) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) ClientFactory(name.abuchen.portfolio.model.ClientFactory) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) Taxonomy(name.abuchen.portfolio.model.Taxonomy) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) Test(org.junit.Test) Security(name.abuchen.portfolio.model.Security) Collectors(java.util.stream.Collectors) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) PerformanceIndex(name.abuchen.portfolio.snapshot.PerformanceIndex) List(java.util.List) LocalDate(java.time.LocalDate) Taxonomy(name.abuchen.portfolio.model.Taxonomy) ArrayList(java.util.ArrayList) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) PerformanceIndex(name.abuchen.portfolio.snapshot.PerformanceIndex) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) ClientClassificationFilter(name.abuchen.portfolio.snapshot.filter.ClientClassificationFilter) Classification(name.abuchen.portfolio.model.Classification) Client(name.abuchen.portfolio.model.Client) Test(org.junit.Test)

Example 24 with Classification

use of name.abuchen.portfolio.model.Classification in project portfolio by buchen.

the class ClassificationTestCase method testCase12_ForexAccountOut100_AccountIn50.

@Test
public void testCase12_ForexAccountOut100_AccountIn50() {
    Taxonomy case12 = client.getTaxonomies().stream().filter(t -> "case_12".equals(t.getName())).findAny().orElseThrow(IllegalArgumentException::new);
    // check performance of 'subcategory'
    Classification ccategory = case12.getAllClassifications().stream().filter(c -> "category".equals(c.getName())).findAny().orElseThrow(IllegalArgumentException::new);
    Client categoryClient = new ClientClassificationFilter(ccategory).filter(client);
    List<PortfolioTransaction> txp = categoryClient.getPortfolios().stream().flatMap(p -> p.getTransactions().stream()).collect(Collectors.toList());
    assertThat(txp, hasSize(0));
    List<AccountTransaction> txa = categoryClient.getAccounts().stream().filter(a -> "Account Forex".equals(a.getName())).flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
    // check cash transfers
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-17T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.TRANSFER_OUT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.USD, Values.Amount.factorize(50)))))));
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-17T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.USD, Values.Amount.factorize(50)))))));
    txa = categoryClient.getAccounts().stream().filter(a -> "Konto 3".equals(a.getName())).flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2012-01-17T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.TRANSFER_IN)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(78.19 * 0.5d)))))));
    // create index
    List<Exception> warnings = new ArrayList<>();
    PerformanceIndex index_subcategory = PerformanceIndex.forClassification(client, converter, ccategory, interval, warnings);
    assertThat(warnings.isEmpty(), is(true));
    // 343.42 EUR (Konto 3 EUR)
    // 423.52 USD / 1.2141 (exchange rate in TestCurrencyConverter)
    assertThat(index_subcategory.getTotals()[index_subcategory.getTotals().length - 1], is(// 
    Values.Amount.factorize(343.42) + Values.Amount.factorize(423.52 / 1.2141)));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) BeforeClass(org.junit.BeforeClass) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) LocalDateTime(java.time.LocalDateTime) Classification(name.abuchen.portfolio.model.Classification) ArrayList(java.util.ArrayList) TestCurrencyConverter(name.abuchen.portfolio.TestCurrencyConverter) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Assert.assertThat(org.junit.Assert.assertThat) ClientClassificationFilter(name.abuchen.portfolio.snapshot.filter.ClientClassificationFilter) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) ClientFactory(name.abuchen.portfolio.model.ClientFactory) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) Taxonomy(name.abuchen.portfolio.model.Taxonomy) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) Test(org.junit.Test) Security(name.abuchen.portfolio.model.Security) Collectors(java.util.stream.Collectors) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) PerformanceIndex(name.abuchen.portfolio.snapshot.PerformanceIndex) List(java.util.List) LocalDate(java.time.LocalDate) Taxonomy(name.abuchen.portfolio.model.Taxonomy) ArrayList(java.util.ArrayList) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) PerformanceIndex(name.abuchen.portfolio.snapshot.PerformanceIndex) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) ClientClassificationFilter(name.abuchen.portfolio.snapshot.filter.ClientClassificationFilter) Classification(name.abuchen.portfolio.model.Classification) Client(name.abuchen.portfolio.model.Client) Test(org.junit.Test)

Example 25 with Classification

use of name.abuchen.portfolio.model.Classification in project portfolio by buchen.

the class SecurityTaxAndFeeAccountTransactionsTestCase method checkTaxonomyWihtSecurityAndAccountAssignment.

@Test
public void checkTaxonomyWihtSecurityAndAccountAssignment() {
    // if account and security are both classified, only the tax
    // transactions are converted to deposits or removals
    Taxonomy case3 = client.getTaxonomies().stream().filter(t -> "case_full_classification_adidas_with_account".equals(t.getName())).findAny().orElseThrow(IllegalArgumentException::new);
    Classification classification = case3.getAllClassifications().stream().filter(c -> "category_security".equals(c.getName())).findAny().orElseThrow(IllegalArgumentException::new);
    Client filteredClient = new ClientClassificationFilter(classification).filter(client);
    List<AccountTransaction> txa1 = filteredClient.getAccounts().stream().flatMap(a1 -> a1.getTransactions().stream()).collect(Collectors.toList());
    // expect 7 transactions: the original 6 plus the removal of the taxes
    // as
    // part of the buy
    assertThat(txa1.size(), is(7));
    // check for additional transactions
    assertThat(txa1, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2017-01-09T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.FEES)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(10.0)))))));
    assertThat(txa1, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2017-01-10T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.FEES_REFUND)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(5.0)))))));
    assertThat(txa1, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2017-01-11T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(25.0)))))));
    assertThat(txa1, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2017-01-12T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.DEPOSIT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(5.0)))))));
    // if the account is fully classified, but the security only partially,
    // there must be offset transactions to make sure that the balance of
    // the account remains correct
    Taxonomy case4 = client.getTaxonomies().stream().filter(t -> "case_partial_classification_adidas_with_account".equals(t.getName())).findAny().orElseThrow(IllegalArgumentException::new);
    classification = case4.getAllClassifications().stream().filter(c -> "category_security".equals(c.getName())).findAny().orElseThrow(IllegalArgumentException::new);
    filteredClient = new ClientClassificationFilter(classification).filter(client);
    List<AccountTransaction> txa = filteredClient.getAccounts().stream().flatMap(a -> a.getTransactions().stream()).collect(Collectors.toList());
    // expect 9 transactions: the original 6 plus the removal of the fees as
    // part of the buy + partial transactions to offset fees
    assertThat(txa.size(), is(9));
    // check for additional transactions
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2017-01-09T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.FEES)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(5)))))));
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2017-01-09T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.REMOVAL)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(5)))))));
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2017-01-10T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.FEES_REFUND)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(2.5)))))));
    assertThat(txa, hasItem(allOf(// 
    hasProperty("dateTime", is(LocalDateTime.parse("2017-01-10T00:00"))), // 
    hasProperty("type", is(AccountTransaction.Type.DEPOSIT)), hasProperty("monetaryAmount", is(Money.of(CurrencyUnit.EUR, Values.Amount.factorize(2.5)))))));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) BeforeClass(org.junit.BeforeClass) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) LocalDateTime(java.time.LocalDateTime) Classification(name.abuchen.portfolio.model.Classification) ArrayList(java.util.ArrayList) TestCurrencyConverter(name.abuchen.portfolio.TestCurrencyConverter) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Assert.assertThat(org.junit.Assert.assertThat) ClientClassificationFilter(name.abuchen.portfolio.snapshot.filter.ClientClassificationFilter) SecurityPerformanceSnapshot(name.abuchen.portfolio.snapshot.security.SecurityPerformanceSnapshot) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) ClientFactory(name.abuchen.portfolio.model.ClientFactory) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) Taxonomy(name.abuchen.portfolio.model.Taxonomy) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) IOException(java.io.IOException) Test(org.junit.Test) Security(name.abuchen.portfolio.model.Security) PortfolioClientFilter(name.abuchen.portfolio.snapshot.filter.PortfolioClientFilter) SecurityPerformanceRecord(name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord) Collectors(java.util.stream.Collectors) PerformanceIndex(name.abuchen.portfolio.snapshot.PerformanceIndex) List(java.util.List) LocalDate(java.time.LocalDate) ClientSecurityFilter(name.abuchen.portfolio.snapshot.filter.ClientSecurityFilter) IsCloseTo.closeTo(org.hamcrest.number.IsCloseTo.closeTo) ClientSnapshot(name.abuchen.portfolio.snapshot.ClientSnapshot) Taxonomy(name.abuchen.portfolio.model.Taxonomy) ClientClassificationFilter(name.abuchen.portfolio.snapshot.filter.ClientClassificationFilter) Classification(name.abuchen.portfolio.model.Classification) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Client(name.abuchen.portfolio.model.Client) Test(org.junit.Test)

Aggregations

Classification (name.abuchen.portfolio.model.Classification)36 ArrayList (java.util.ArrayList)21 TestCurrencyConverter (name.abuchen.portfolio.TestCurrencyConverter)20 Client (name.abuchen.portfolio.model.Client)20 Taxonomy (name.abuchen.portfolio.model.Taxonomy)20 Test (org.junit.Test)20 IOException (java.io.IOException)18 Security (name.abuchen.portfolio.model.Security)17 PerformanceIndex (name.abuchen.portfolio.snapshot.PerformanceIndex)17 Collectors (java.util.stream.Collectors)16 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)16 ClientFactory (name.abuchen.portfolio.model.ClientFactory)16 CurrencyUnit (name.abuchen.portfolio.money.CurrencyUnit)16 LocalDate (java.time.LocalDate)15 LocalDateTime (java.time.LocalDateTime)15 List (java.util.List)15 Money (name.abuchen.portfolio.money.Money)15 Values (name.abuchen.portfolio.money.Values)15 ReportingPeriod (name.abuchen.portfolio.snapshot.ReportingPeriod)15 ClientClassificationFilter (name.abuchen.portfolio.snapshot.filter.ClientClassificationFilter)15