RecipientServiceImpl implements RecipientService { @Override public Recipient findByAccountName(String accountName) { Assert.hasLength(accountName); return repository.findByAccountName(accountName); }  @Override Recipient findByAccountName(String accountName); @Override Recipient save(String accountName, Recipient recipient); @Override List<Recipient> findReadyToNotify(NotificationType type); @Override void markNotified(NotificationType type, Recipient recipient);  }
@Test public void shouldFindByAccountName() { Recipient recipient = new Recipient(); recipient.setAccountName("test"); when(repository.findByAccountName(recipient.getAccountName())).thenReturn(recipient); Recipient found = recipientService.findByAccountName(recipient.getAccountName()); assertEquals(recipient, found); }
@Test(expected = IllegalArgumentException.class) public void shouldFailToFindRecipientWhenAccountNameIsEmpty() { recipientService.findByAccountName(""); }
@Test(expectedExceptions = IllegalArgumentException.class) public void shouldFailToFindRecipientWhenAccountNameIsEmpty() { recipientService.findByAccountName(""); }