Skip to content

Instantly share code, notes, and snippets.

@yusufcakal
Created October 24, 2020 22:56
Show Gist options
  • Save yusufcakal/efc678b704478c7f9a5853ee924c6940 to your computer and use it in GitHub Desktop.
Save yusufcakal/efc678b704478c7f9a5853ee924c6940 to your computer and use it in GitHub Desktop.
@Test(expected = AddressUpdateException.class)
public void shouldNotUpdateAddressAndDoNotSendNotificationWhenAddressIdIsWrong() {
AddressUpdateRequest addressUpdateRequest = AddressUpdateRequestBuilder.anAddressUpdateRequestBuilder()
.id(1L)
.build();
when(addressRepository.findById(1L)).thenReturn(Optional.empty());
try {
addressService.update(addressUpdateRequest);
} catch (AddressUpdateException ex) {
verify(addressRepository).findById(1L);
throw ex;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment