use of name.abuchen.portfolio.TaxonomyBuilder in project portfolio by buchen.
the class GroupByTaxonomyTest method testSecuritiesWithPartialAssignment.
@SuppressWarnings("null")
@Test
public void testSecuritiesWithPartialAssignment() {
Client client = new Client();
Taxonomy taxonomy = //
new TaxonomyBuilder().addClassification(//
"debt").addTo(client);
Security a = //
new SecurityBuilder().addPrice("2010-01-01", //
Values.Quote.factorize(10)).assign(taxonomy, "debt", //
Classification.ONE_HUNDRED_PERCENT / 2).addTo(client);
Portfolio portfolio = //
new PortfolioBuilder().inbound_delivery(a, "2010-01-01", Values.Share.factorize(10), //
10000).addTo(client);
LocalDate date = LocalDate.parse("2010-01-01");
PortfolioSnapshot snapshot = PortfolioSnapshot.create(portfolio, new TestCurrencyConverter(), date);
assertNotNull(snapshot);
GroupByTaxonomy grouping = snapshot.groupByTaxonomy(taxonomy);
assertThat(grouping.asList().size(), is(2));
AssetCategory debt = grouping.byClassification(taxonomy.getClassificationById("debt"));
assertThat(debt.getValuation(), is(Money.of(CurrencyUnit.EUR, 50_00)));
assertThat(debt.getPositions().size(), is(1));
AssetCategory unassigned = null;
for (AssetCategory category : grouping.asList()) if (category.getClassification().getId().equals(Classification.UNASSIGNED_ID))
unassigned = category;
assertThat(unassigned, notNullValue());
assertThat(unassigned.getValuation(), is(Money.of(CurrencyUnit.EUR, 50_00)));
assertThat(unassigned.getPositions().size(), is(1));
}
use of name.abuchen.portfolio.TaxonomyBuilder in project portfolio by buchen.
the class GroupByTaxonomyTest method testThatPartialAssignmentsAreSeparated.
@Test
public void testThatPartialAssignmentsAreSeparated() {
Client client = new Client();
Taxonomy taxonomy = //
new TaxonomyBuilder().addClassification(//
"debt").addClassification(//
"equity").addTo(client);
Security a = //
new SecurityBuilder().addPrice("2010-01-01", //
Values.Quote.factorize(10)).assign(taxonomy, "debt", //
Classification.ONE_HUNDRED_PERCENT / 2).assign(taxonomy, "equity", //
Classification.ONE_HUNDRED_PERCENT / 2).addTo(client);
Portfolio portfolio = //
new PortfolioBuilder().inbound_delivery(a, "2010-01-01", Values.Share.factorize(10), //
10000).addTo(client);
LocalDate date = LocalDate.parse("2010-01-01");
PortfolioSnapshot snapshot = PortfolioSnapshot.create(portfolio, new TestCurrencyConverter(), date);
assertNotNull(snapshot);
GroupByTaxonomy grouping = snapshot.groupByTaxonomy(taxonomy);
AssetCategory debt = grouping.byClassification(taxonomy.getClassificationById("debt"));
assertThat(debt.getValuation(), is(Money.of(CurrencyUnit.EUR, 50_00)));
assertThat(debt.getPositions().size(), is(1));
AssetCategory equity = grouping.byClassification(taxonomy.getClassificationById("equity"));
assertThat(equity.getValuation(), is(Money.of(CurrencyUnit.EUR, 50_00)));
assertThat(equity.getPositions().size(), is(1));
}
Aggregations