### Question:
DAOInvoiceSeriesImpl extends AbstractDAO<InvoiceSeriesEntity, JPAInvoiceSeriesEntity> implements DAOInvoiceSeries { @Override public InvoiceSeriesEntity getSeries(String series, String businessUID, LockModeType lockMode) { QJPAInvoiceSeriesEntity querySeries = this.queryInvoiceSeries(series, businessUID); if (lockMode == LockModeType.WRITE || lockMode == LockModeType.PESSIMISTIC_WRITE) { querySeries = querySeries.forUpdate(); } return querySeries.findOne(); }  @Override InvoiceSeriesEntity getEntityInstance(); @Override InvoiceSeriesEntity getSeries(String series, String businessUID, LockModeType lockMode);  }### Answer:
@Test public void getSeries() { InvoiceSeriesEntity series = DAOInvoiceSeriesImplTest.daoInvoiceSeriesImpl.getSeries( DAOInvoiceSeriesImplTest.rightSeries, DAOInvoiceSeriesImplTest.rightBusinessUid.toString(), null); Assert.assertEquals(series.getUID(), DAOInvoiceSeriesImplTest.invoiceSeriesUid); }
@Test public void getSeries_wrongSeriesId() { InvoiceSeriesEntity series = DAOInvoiceSeriesImplTest.daoInvoiceSeriesImpl.getSeries( DAOInvoiceSeriesImplTest.wrongSeries, DAOInvoiceSeriesImplTest.rightBusinessUid.toString(), null); Assert.assertEquals(series, null); }
@Test public void getSeries_wrongBusinessId() { InvoiceSeriesEntity series = DAOInvoiceSeriesImplTest.daoInvoiceSeriesImpl.getSeries( DAOInvoiceSeriesImplTest.rightSeries, DAOInvoiceSeriesImplTest.wrongBusinessUid.toString(), null); Assert.assertEquals(series, null); }
@Test public void getSeries_concurrent_deadlock() { Ebean.beginTransaction(); InvoiceSeriesEntity series = DAOInvoiceSeriesImplTest.daoInvoiceSeriesImpl.getSeries(DAOInvoiceSeriesImplTest.rightSeries, DAOInvoiceSeriesImplTest.rightBusinessUid.toString(), LockModeType.PESSIMISTIC_WRITE); long threadTimeout = 1000; long millis = System.currentTimeMillis(); Thread concurrentThread = new Thread() { @Override public void run() { Ebean.beginTransaction(); InvoiceSeriesEntity series = DAOInvoiceSeriesImplTest.daoInvoiceSeriesImpl.getSeries(DAOInvoiceSeriesImplTest.rightSeries, DAOInvoiceSeriesImplTest.rightBusinessUid.toString(), LockModeType.PESSIMISTIC_WRITE); Ebean.commitTransaction(); } }; concurrentThread.start(); try { concurrentThread.join(threadTimeout); } catch (InterruptedException e) { e.printStackTrace(); } long diff = System.currentTimeMillis() - millis; Ebean.commitTransaction(); Assert.assertEquals(diff >= threadTimeout, true); }