Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #21

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private UserDTO buildValidatedUserDTO(
UserDTO userDTO = new UserDTO();
userDTO.setEmail(updateConsultantDTO.getEmail());
userDTO.setUsername(consultant.getUsername());
userDTO.setTenantId(consultant.getTenantId());

this.userAccountInputValidator.validateUserDTO(userDTO);
return userDTO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.caritas.cob.userservice.api.admin.service.consultant.update;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
Expand All @@ -21,6 +22,7 @@
import org.jeasy.random.EasyRandom;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
Expand Down Expand Up @@ -52,6 +54,7 @@ public class ConsultantUpdateServiceTest {
@Test
public void updateConsultant_Should_callServicesCorrectly_When_givenConsultantDataIsValid() {
Consultant consultant = new EasyRandom().nextObject(Consultant.class);
consultant.setTenantId(1L);
when(this.consultantService.getConsultant(any())).thenReturn(Optional.of(consultant));
UpdateAdminConsultantDTO updateConsultant =
new EasyRandom().nextObject(UpdateAdminConsultantDTO.class);
Expand All @@ -62,12 +65,14 @@ public void updateConsultant_Should_callServicesCorrectly_When_givenConsultantDa
verify(this.keycloakService, Mockito.never())
.updateRole(consultant.getId(), UserRole.GROUP_CHAT_CONSULTANT.getValue());

ArgumentCaptor<UserDTO> userDTOArgumentCaptor = ArgumentCaptor.forClass(UserDTO.class);
verify(this.keycloakService, times(1))
.updateUserData(
eq(consultant.getId()),
any(UserDTO.class),
userDTOArgumentCaptor.capture(),
eq(updateConsultant.getFirstname()),
eq(updateConsultant.getLastname()));
assertThat(userDTOArgumentCaptor.getValue().getTenantId()).isEqualTo(consultant.getTenantId());
verify(this.consultantService, times(1)).saveConsultant(any());
verify(this.appointmentService, times(1)).syncConsultantData(any());
}
Expand Down
Loading