Skip to content
Snippets Groups Projects
Commit 108190cd authored by OZGCloud's avatar OZGCloud
Browse files

OZG-5031 Rename repository function and fix UserProfileGrpcServiceTest

parent 7dced2c3
Branches
No related tags found
No related merge requests found
...@@ -128,7 +128,7 @@ class UserRepository implements PanacheMongoRepository<User> { ...@@ -128,7 +128,7 @@ class UserRepository implements PanacheMongoRepository<User> {
return find(DELETED_FIELD, true).project(UserIdProjection.class).stream().map(UserIdProjection::getAsString); return find(DELETED_FIELD, true).project(UserIdProjection.class).stream().map(UserIdProjection::getAsString);
} }
public Stream<User> findAllUsersByOrganisationsEinheitId(String organisationsEinheitId) { public Stream<User> findAllByOrganisationsEinheitId(String organisationsEinheitId) {
return stream(ORGANISATIONS_EINHEIT_IDS_FIELD, organisationsEinheitId); return stream(ORGANISATIONS_EINHEIT_IDS_FIELD, organisationsEinheitId);
} }
......
...@@ -153,6 +153,6 @@ public class UserService { ...@@ -153,6 +153,6 @@ public class UserService {
if (StringUtils.isEmpty(organisationsEinheitId)) { if (StringUtils.isEmpty(organisationsEinheitId)) {
throw new FunctionalException(() -> String.format(MISSING_ORGANISATIONS_EINHEIT_ID_MESSAGE_TEMPLATE, organisationsEinheitId)); throw new FunctionalException(() -> String.format(MISSING_ORGANISATIONS_EINHEIT_ID_MESSAGE_TEMPLATE, organisationsEinheitId));
} }
return repository.findAllUsersByOrganisationsEinheitId(organisationsEinheitId); return repository.findAllByOrganisationsEinheitId(organisationsEinheitId);
} }
} }
\ No newline at end of file
...@@ -571,7 +571,7 @@ class UserRepositoryITCase { ...@@ -571,7 +571,7 @@ class UserRepositoryITCase {
} }
@Nested @Nested
class TestFindAllUsersByOrganisationsEinheitId { class TestFindAllByOrganisationsEinheitId {
private static final String ORGANISATIONSEINHEIT_ID_1 = UUID.randomUUID().toString(); private static final String ORGANISATIONSEINHEIT_ID_1 = UUID.randomUUID().toString();
private static final String ORGANISATIONSEINHEIT_ID_2 = UUID.randomUUID().toString(); private static final String ORGANISATIONSEINHEIT_ID_2 = UUID.randomUUID().toString();
...@@ -602,7 +602,7 @@ class UserRepositoryITCase { ...@@ -602,7 +602,7 @@ class UserRepositoryITCase {
@Test @Test
void shouldFindUsersByOrganisationsEinheitId() { void shouldFindUsersByOrganisationsEinheitId() {
var users = repository.findAllUsersByOrganisationsEinheitId(ORGANISATIONSEINHEIT_ID_1); var users = repository.findAllByOrganisationsEinheitId(ORGANISATIONSEINHEIT_ID_1);
assertThat(users).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder(user1, user2); assertThat(users).usingRecursiveFieldByFieldElementComparator().containsExactlyInAnyOrder(user1, user2);
} }
......
...@@ -204,7 +204,7 @@ class UserRepositoryTest { ...@@ -204,7 +204,7 @@ class UserRepositoryTest {
} }
@Nested @Nested
class TestFindAllUsersByOrganisationsEinheitId { class TestFindAllByOrganisationsEinheitId {
@BeforeEach @BeforeEach
void mock() { void mock() {
...@@ -226,7 +226,7 @@ class UserRepositoryTest { ...@@ -226,7 +226,7 @@ class UserRepositoryTest {
} }
private Stream<User> callRepository() { private Stream<User> callRepository() {
return userRepository.findAllUsersByOrganisationsEinheitId(UserTestFactory.ORGANISTATIONSEINHEITEN_ID); return userRepository.findAllByOrganisationsEinheitId(UserTestFactory.ORGANISTATIONSEINHEITEN_ID);
} }
} }
} }
...@@ -413,13 +413,13 @@ class UserServiceTest { ...@@ -413,13 +413,13 @@ class UserServiceTest {
void shouldCallRepository() { void shouldCallRepository() {
callService(); callService();
verify(repository).findAllUsersByOrganisationsEinheitId(UserTestFactory.ORGANISTATIONSEINHEITEN_ID); verify(repository).findAllByOrganisationsEinheitId(UserTestFactory.ORGANISTATIONSEINHEITEN_ID);
} }
@Test @Test
void shouldReturnFoundUsers() { void shouldReturnFoundUsers() {
var users = Stream.of(UserTestFactory.create()); var users = Stream.of(UserTestFactory.create());
when(repository.findAllUsersByOrganisationsEinheitId(UserTestFactory.ORGANISTATIONSEINHEITEN_ID)).thenReturn(users); when(repository.findAllByOrganisationsEinheitId(UserTestFactory.ORGANISTATIONSEINHEITEN_ID)).thenReturn(users);
var returnedUsers = callService(); var returnedUsers = callService();
......
...@@ -169,6 +169,7 @@ class UserProfileGrpcServiceTest { ...@@ -169,6 +169,7 @@ class UserProfileGrpcServiceTest {
@BeforeEach @BeforeEach
void mock() { void mock() {
when(userService.findAllUsersOfOrganisationsEinheit(UserTestFactory.ORGANISTATIONSEINHEITEN_ID)).thenReturn(users); when(userService.findAllUsersOfOrganisationsEinheit(UserTestFactory.ORGANISTATIONSEINHEITEN_ID)).thenReturn(users);
doReturn(response).when(grpcService).buildGrpcGetAllByOrganisationsEinheitIdResponse(users);
} }
@Test @Test
...@@ -187,8 +188,6 @@ class UserProfileGrpcServiceTest { ...@@ -187,8 +188,6 @@ class UserProfileGrpcServiceTest {
@Test @Test
void shouldCallOnNext() { void shouldCallOnNext() {
doReturn(response).when(grpcService).buildGrpcGetAllByOrganisationsEinheitIdResponse(users);
callService(); callService();
verify(streamObserver).onNext(response); verify(streamObserver).onNext(response);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment