@Test
public void testThatSecuritiesAreGroupedIntoClassifications()
{
Client client = new Client();
Taxonomy taxonomy = new TaxonomyBuilder() //
.addClassification("debt") //
.addClassification("equity") //
.addClassification("realestate") //
.addTo(client);
Security a = new SecurityBuilder() //
.addPrice("2010-01-01", 1000) //
.assign(taxonomy, "debt") //
.addTo(client);
Security c = new SecurityBuilder() //
.addPrice("2010-01-01", 1200) //
.assign(taxonomy, "equity") //
.addTo(client);
Security d = new SecurityBuilder() //
.addPrice("2010-01-01", 1200) //
.assign(taxonomy, "equity") //
.addTo(client);
Portfolio portfolio = new PortfolioBuilder() //
.inbound_delivery(a, "2010-01-01", 1000000, 10000) //
.inbound_delivery(c, "2010-01-01", 1000000, 12000) //
.inbound_delivery(d, "2010-01-01", 1000000, 12000) //
.addTo(client);
PortfolioSnapshot snapshot = PortfolioSnapshot.create(portfolio, new DateTime("2010-01-01").toDate());
assertNotNull(snapshot);
GroupByTaxonomy grouping = snapshot.groupByTaxonomy(taxonomy);
AssetCategory debt = grouping.byClassification(taxonomy.getClassificationById("debt"));
assertThat(debt.getValuation(), is(10000L));
assertThat(debt.getPositions().size(), is(1));
AssetCategory stocks = grouping.byClassification(taxonomy.getClassificationById("equity"));
assertThat(stocks.getValuation(), is(24000L));
assertThat(stocks.getPositions().size(), is(2));
AssetCategory realEstate = grouping.byClassification(taxonomy.getClassificationById("realestate"));
assertThat(realEstate, nullValue());
}