Skip to content

Commit

Permalink
chore: Update deleteUser method to handle non-existent users earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
djangbahevans committed Aug 1, 2024
1 parent f7bdd57 commit e184a67
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ void updateUser_shouldThrowResourceNotFoundException_whenUserDoesNotExist() {
@Test
void deleteUser_shouldDeleteUser_whenNoPortfoliosExist() throws ResourceNotFoundException {
when(portfolioRepository.findByUserId(1L)).thenReturn(Collections.emptyList());
when(userRepository.findById(1L)).thenReturn(Optional.of(user));

userService.deleteUser(1L);

Expand All @@ -171,6 +172,7 @@ void deleteUser_shouldMarkUserAsPendingDelete_whenPortfoliosExist() throws Excep
void deleteUser_shouldThrowUserDeletionException_whenNatsServiceFails() throws Exception {
Portfolio portfolio = new Portfolio();
when(portfolioRepository.findByUserId(1L)).thenReturn(Collections.singletonList(portfolio));
when(userRepository.findById(1L)).thenReturn(Optional.of(user));
doThrow(new JsonProcessingException("Error") {
}).when(natsService).publish(any(Event.class), any());

Expand Down

0 comments on commit e184a67

Please sign in to comment.