@Before
 public void setUp() {
   // called before each test.
   documentRepositoryImpl = new DocumentRepositoryImpl();
   documentDao = mock(DocumentDao.class);
   documentRepositoryImpl.setDocumentDao(documentDao);
 }
  @SuppressWarnings("unchecked")
  @Test(expected = NonUniqueResultException.class)
  public void testFindUniqueCaseMultiple() {
    when(documentDao.findUnique(any(Document.class), any(SearchParameters.class)))
        .thenThrow(NonUniqueResultException.class);

    documentRepositoryImpl.findUnique(new Document());
  }
  @Test
  public void testFindUniqueCaseUnique() {
    Document unique = new Document();

    when(documentDao.findUnique(any(Document.class), any(SearchParameters.class)))
        .thenReturn(unique);

    Document result = documentRepositoryImpl.findUnique(new Document());

    assertThat(result).isNotNull();
    verify(documentDao, times(1)).findUnique(any(Document.class), any(SearchParameters.class));
  }