@Before public void setupClient() { client = new Client(); account = new Account(); client.addAccount(account); portfolio = new Portfolio(); client.addPortfolio(portfolio); security = new Security(); client.addSecurity(security); }
@Test public void testThatNotTheSamePortfolioIsMatched() { Portfolio second = new Portfolio(); client.addPortfolio(second); portfolio.addTransaction( new PortfolioTransaction( Dates.today(), security, // PortfolioTransaction.Type.TRANSFER_IN, 1, 3, 1)); PortfolioTransaction umatched = new PortfolioTransaction( Dates.today(), security, // PortfolioTransaction.Type.TRANSFER_OUT, 1, 3, 1); portfolio.addTransaction(umatched); second.addTransaction( new PortfolioTransaction( Dates.today(), security, // PortfolioTransaction.Type.TRANSFER_OUT, 1, 3, 1)); List<Issue> issues = new CrossEntryCheck().execute(client); assertThat(issues.size(), is(1)); assertThat(issues.get(0), is(MissingPortfolioTransferIssue.class)); assertThat(portfolio.getTransactions(), hasItem(umatched)); assertThat(second.getTransactions().get(0).getCrossEntry(), notNullValue()); assertThat( second.getTransactions().get(0).getType(), is(PortfolioTransaction.Type.TRANSFER_OUT)); applyFixes(client, issues); }
@Test public void testThatAccountTransactionsWithoutSecurity() { Portfolio second = new Portfolio(); client.addPortfolio(second); account.addTransaction( new AccountTransaction( Dates.today(), null, // AccountTransaction.Type.BUY, 1)); List<Issue> issues = new CrossEntryCheck().execute(client); assertThat(issues.size(), is(1)); assertThat(issues.get(0).getAvailableFixes().get(0), is(DeleteTransactionFix.class)); applyFixes(client, issues); ClientSnapshot.create(client, Dates.today()); }