@SuppressWarnings("unchecked") @Test(expected = NonUniqueResultException.class) public void findUniqueThrowsExeptionWhenNonUniqueResult() { when(currencyDao.findUnique(any(Currency.class), any(SearchParameters.class))) .thenThrow(NonUniqueResultException.class); currencyRepository.findUnique(new Currency()); }
@Test public void findUnique() { Currency unique = new Currency(); when(currencyDao.findUnique(any(Currency.class), any(SearchParameters.class))) .thenReturn(unique); Currency result = currencyRepository.findUnique(new Currency()); assertThat(result).isNotNull(); verify(currencyDao, times(1)).findUnique(any(Currency.class), any(SearchParameters.class)); }