Skip to content

Commit

Permalink
#931: UserBusinessService test for delete user by id
Browse files Browse the repository at this point in the history
  • Loading branch information
clean-coder committed Jul 30, 2024
1 parent 687b5d1 commit c36b2db
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean isUserOwnerOfKeyResults(long id) {

public void deleteEntityById(long id) {
// TODO check Role
userBusinessService.deleteUser(id);
userBusinessService.deleteEntityById(id);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public List<User> createUsers(List<User> userList) {
}

@Transactional
public void deleteUser(long id) {
public void deleteEntityById(long id) {
validationService.validateOnDelete(id);
userPersistenceService.deleteById(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,19 @@ class UserBusinessServiceTest {

@BeforeEach
void setUp() {
User userAlice = User.Builder.builder().withId(2L).withFirstname("Alice").withLastname("Wunderland")
.withEmail("[email protected]").build();

User userBob = User.Builder.builder().withId(9L).withFirstname("Bob").withLastname("Baumeister")
.withEmail("[email protected]").build();
User userAlice = User.Builder.builder() //
.withId(2L) //
.withFirstname("Alice") //
.withLastname("Wunderland") //
.withEmail("[email protected]") //
.build();

User userBob = User.Builder.builder() //
.withId(9L) //
.withFirstname("Bob") //
.withLastname("Baumeister") //
.withEmail("[email protected]") //
.build();

userList = Arrays.asList(userAlice, userBob);
}
Expand Down Expand Up @@ -162,4 +170,11 @@ void setOkrChampion_shouldNotThrowExceptionIfSecondLastOkrChampIsRemoved() {
verify(userPersistenceService, times(1)).save(user);
assertFalse(user.isOkrChampion());
}

@Test
void shouldDeleteUser() {
userBusinessService.deleteEntityById(23L);

verify(userPersistenceService, times(1)).deleteById(23L);
}
}

0 comments on commit c36b2db

Please sign in to comment.