### Question:
AbstractDAOGenericInvoiceImpl extends AbstractDAO<TInterface, TEntity> implements AbstractDAOGenericInvoice<TInterface> { @SuppressWarnings("unchecked") @Override public TInterface getLatestInvoiceFromSeries(String series, String businessUID) { JPABusinessEntity business = this.queryBusiness(businessUID).findOne(); if (business == null) { throw new BillyRuntimeException("No Business found for id: " + businessUID); } QueryIterator<JPAGenericInvoiceEntity> invoiceIterator = this.queryInvoice(series, business).orderBy().seriesNumber.desc().findIterate(); return (TInterface) (invoiceIterator.hasNext() ? invoiceIterator.next() : null); }  @SuppressWarnings("unchecked") @Override TInterface getLatestInvoiceFromSeries(String series, String businessUID);  }### Answer:
@Test public void getLatestInvoiceFromSeries() { GenericInvoiceEntity invoice = AbstractDAOGenericInvoiceImplTest.genericInvoiceDAO.getLatestInvoiceFromSeries( AbstractDAOGenericInvoiceImplTest.rightSeries, AbstractDAOGenericInvoiceImplTest.rightBusinessUid.toString()); Assert.assertEquals(invoice.getUID(), AbstractDAOGenericInvoiceImplTest.latestInvoiceUid); }
@Test public void getLatestInvoiceFromSeries_noBusiness() { this.expectedException.expect(BillyRuntimeException.class); GenericInvoiceEntity invoice = AbstractDAOGenericInvoiceImplTest.genericInvoiceDAO.getLatestInvoiceFromSeries( AbstractDAOGenericInvoiceImplTest.rightSeries, AbstractDAOGenericInvoiceImplTest.wrongBusinessUid.toString()); }
@Test public void getLatestInvoiceFromSeries_wrongSeries() { GenericInvoiceEntity invoice = AbstractDAOGenericInvoiceImplTest.genericInvoiceDAO.getLatestInvoiceFromSeries( AbstractDAOGenericInvoiceImplTest.wrongSeries, AbstractDAOGenericInvoiceImplTest.rightBusinessUid.toString()); Assert.assertEquals(invoice, null); }
@Test public void getLatestInvoiceFromSeries_wrongBusiness() { this.expectedException.expect(BillyRuntimeException.class); GenericInvoiceEntity invoice = AbstractDAOGenericInvoiceImplTest.genericInvoiceDAO.getLatestInvoiceFromSeries( AbstractDAOGenericInvoiceImplTest.rightSeries, AbstractDAOGenericInvoiceImplTest.wrongBusinessUid.toString()); }