Last active
October 26, 2015 20:05
-
-
Save martkoehler/f9e45ab5d69f7d5d5b77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void findCustomer() { | |
Customer customer = mock(Customer.class); | |
CustomerRepository repository = mock(CustomerRepository.class); | |
CustomerService service = new CustomerService(repository); | |
when(repository.find(anyLong())).thenReturn(customer); | |
service.find(1L); | |
verify(repository, times(1)).find(anyLong()); | |
verifyNoMoreInteractions(repository); | |
} | |
@Test(expected = NoResultException.class) | |
public void findCustomerWithoutResult() { | |
CustomerRepository repository = mock(CustomerRepository.class); | |
CustomerService service = new CustomerService(repository); | |
doThrow(NoResultException.class).when(repository).find(anyLong()); | |
service.find(1L); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment