GroupedDetailImportContextTest.java 文件源码

java
阅读 36 收藏 0 点赞 0 评论 0

项目:finances 作者:
@Test
public void populatesTransaction() throws Exception {
    final ByteArrayInputStream inputStream = new ByteArrayInputStream("".getBytes());
    final Payee payee = new Payee();
    final Account account = new Account();
    Security security = new Security();
    when(importFile.getAccount()).thenReturn(account);
    when(importFile.parse(inputStream)).thenReturn(singletonList(
            ImmutableListMultimap.of(dateField, "01/15/1990", payeeField, PAYEE_NAME, securityField, SECURITY_NAME)));
    ImportContext context = new GroupedDetailImportContext(importFile, payeeMapper, securityMapper, categoryMapper);
    when(payeeMapper.get(PAYEE_NAME)).thenReturn(payee);
    when(securityMapper.get(SECURITY_NAME)).thenReturn(security);

    List<Transaction> transactions = context.parseTransactions(inputStream);

    assertThat(transactions).hasSize(1);
    assertThat(transactions.get(0).getAccount()).isSameAs(account);
    assertThat(transactions.get(0).getDate()).isEqualTo(new SimpleDateFormat("yyyy/MM/dd").parse("1990/01/15"));
    assertThat(transactions.get(0).getPayee()).isSameAs(payee);
    assertThat(transactions.get(0).getSecurity()).isSameAs(security);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号