use of name.abuchen.portfolio.snapshot.ClientPerformanceSnapshot.Category in project portfolio by buchen.
the class ClientPerformanceSnapshotTest method testDepositPlusInterest.
@Test
public void testDepositPlusInterest() {
Client client = new Client();
Account account = new Account();
account.addTransaction(new AccountTransaction(LocalDateTime.of(2010, Month.JANUARY, 1, 0, 0), CurrencyUnit.EUR, 1000_00, null, AccountTransaction.Type.DEPOSIT));
account.addTransaction(new AccountTransaction(LocalDateTime.of(2011, Month.JUNE, 1, 0, 0), CurrencyUnit.EUR, 50_00, null, AccountTransaction.Type.INTEREST));
client.addAccount(account);
CurrencyConverter converter = new TestCurrencyConverter();
ClientPerformanceSnapshot snapshot = new ClientPerformanceSnapshot(client, converter, startDate, endDate);
assertNotNull(snapshot);
assertNotNull(snapshot.getStartClientSnapshot());
assertEquals(startDate, snapshot.getStartClientSnapshot().getTime());
assertNotNull(snapshot.getEndClientSnapshot());
assertEquals(endDate, snapshot.getEndClientSnapshot().getTime());
List<Category> categories = snapshot.getCategories();
assertNotNull(categories);
assertThat(categories.size(), is(ClientPerformanceSnapshot.CategoryType.values().length));
assertThat(snapshot.getValue(CategoryType.INITIAL_VALUE), is(Money.of(CurrencyUnit.EUR, 1000_00)));
assertThat(snapshot.getValue(CategoryType.EARNINGS), is(Money.of(CurrencyUnit.EUR, 50_00)));
assertThat(snapshot.getValue(CategoryType.FINAL_VALUE), is(Money.of(CurrencyUnit.EUR, 1050_00)));
assertThat(snapshot.getAbsoluteDelta(), is(snapshot.getValue(CategoryType.FINAL_VALUE).subtract(snapshot.getValue(CategoryType.TRANSFERS)).subtract(snapshot.getValue(CategoryType.INITIAL_VALUE))));
}
Aggregations