### Question:
CustomerStatementReader implements ItemReader<Statement> { public Statement read() throws Exception, UnexpectedInputException, ParseException { Customer customer = customerReader.read(); if(customer == null) { return null; } else { Statement statement = new Statement(); statement.setCustomer(customer); statement.setSecurityTotal(tickerDao.getTotalValueForCustomer(customer.getId())); statement.setStocks(tickerDao.getStocksForCustomer(customer.getId())); return statement; } }  Statement read(); void setCustomerReader(ItemReader<Customer> customerReader); void setTickerDao(TickerDao tickerDao);  }### Answer:
@Test public void testReadNoCustomers() throws Exception { assertNull(reader.read()); }
@SuppressWarnings("serial") @Test public void testReadWithCustomer() throws Exception { Customer customer = new Customer(); customer.setId(5l); when(customerReader.read()).thenReturn(customer); when(tickerDao.getTotalValueForCustomer(5l)).thenReturn( new BigDecimal("500.00")); when(tickerDao.getStocksForCustomer(5l)).thenReturn( new ArrayList<Transaction>() { { add(new Transaction()); } }); Statement result = reader.read(); assertEquals(customer, result.getCustomer()); assertEquals(500.00, result.getSecurityTotal().doubleValue(), 0); assertEquals(1, result.getStocks().size()); }