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

OZG-3539 apply code review improvements and disable mongock from tests

parent c25e5f07
No related branches found
No related tags found
No related merge requests found
...@@ -64,7 +64,6 @@ public class User { ...@@ -64,7 +64,6 @@ public class User {
public static final String USERNAME_FIELD = "username"; public static final String USERNAME_FIELD = "username";
public static final String ORGANISATIONS_EINHEIT_IDS_FIELD = "organisationsEinheitIds"; public static final String ORGANISATIONS_EINHEIT_IDS_FIELD = "organisationsEinheitIds";
public static final String USER_SETTINGS_FIELD = "userSettings"; public static final String USER_SETTINGS_FIELD = "userSettings";
public static final String NOTIFICATION_SEND_FOR_FIELD = "userSettings.notificationsSendFor";
@JsonIgnore @JsonIgnore
@BsonId @BsonId
......
...@@ -4,17 +4,21 @@ import static de.ozgcloud.user.User.*; ...@@ -4,17 +4,21 @@ import static de.ozgcloud.user.User.*;
import java.util.List; import java.util.List;
import jakarta.enterprise.context.ApplicationScoped;
import de.ozgcloud.common.logging.OzgCloudLogging; import de.ozgcloud.common.logging.OzgCloudLogging;
import de.ozgcloud.user.User; import de.ozgcloud.user.User;
import de.ozgcloud.user.common.DocumentUtils;
import de.ozgcloud.user.settings.NotificationsSendFor; import de.ozgcloud.user.settings.NotificationsSendFor;
import de.ozgcloud.user.settings.UserSettings;
import io.quarkus.mongodb.panache.PanacheMongoRepository; import io.quarkus.mongodb.panache.PanacheMongoRepository;
import jakarta.enterprise.context.ApplicationScoped;
@ApplicationScoped @ApplicationScoped
@OzgCloudLogging @OzgCloudLogging
class RecipientRepository implements PanacheMongoRepository<User> { class RecipientRepository implements PanacheMongoRepository<User> {
private static final String SEARCH_RECIPIENT_QUERY = ORGANISATIONS_EINHEIT_IDS_FIELD + " = ?1 and " + NOTIFICATION_SEND_FOR_FIELD + " = ?2"; private static final String SEARCH_RECIPIENT_QUERY = ORGANISATIONS_EINHEIT_IDS_FIELD + " = ?1 and "
+ DocumentUtils.buildFieldPath(USER_SETTINGS_FIELD, UserSettings.NOTIFICATIONS_SEND_FOR_FIELD) + " = ?2";
public List<User> findByOrganisationsEinheitId(String organisationseinheitId) { public List<User> findByOrganisationsEinheitId(String organisationseinheitId) {
return find(SEARCH_RECIPIENT_QUERY, organisationseinheitId, NotificationsSendFor.ALL.name()).list(); return find(SEARCH_RECIPIENT_QUERY, organisationseinheitId, NotificationsSendFor.ALL.name()).list();
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*/ */
package de.ozgcloud.user.settings; package de.ozgcloud.user.settings;
import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -30,6 +31,7 @@ import lombok.Setter; ...@@ -30,6 +31,7 @@ import lombok.Setter;
@Builder(toBuilder = true) @Builder(toBuilder = true)
@Getter @Getter
@Setter @Setter
@AllArgsConstructor
public class UserSettings { public class UserSettings {
public static final String NOTIFICATIONS_SEND_FOR_FIELD = "notificationsSendFor"; public static final String NOTIFICATIONS_SEND_FOR_FIELD = "notificationsSendFor";
...@@ -44,29 +46,15 @@ public class UserSettings { ...@@ -44,29 +46,15 @@ public class UserSettings {
private boolean postfachNachrichtFromAntragsteller; private boolean postfachNachrichtFromAntragsteller;
private boolean wiedervorlageOverdue; private boolean wiedervorlageOverdue;
public UserSettings(final NotificationsSendFor notificationsSendFor, final boolean vorgangCreated, final boolean vorgangAssignedToUser, public UserSettings(NotificationsSendFor notificationsSendFor) {
final boolean postfachNachrichtFromAntragsteller, final boolean wiedervorlageOverdue) {
this.notificationsSendFor = notificationsSendFor;
this.vorgangCreated = vorgangCreated;
this.vorgangAssignedToUser = vorgangAssignedToUser;
this.postfachNachrichtFromAntragsteller = postfachNachrichtFromAntragsteller;
this.wiedervorlageOverdue = wiedervorlageOverdue;
}
public UserSettings(final NotificationsSendFor notificationsSendFor) {
this(notificationsSendFor, notificationsSendFor == NotificationsSendFor.ALL, true, true, true); this(notificationsSendFor, notificationsSendFor == NotificationsSendFor.ALL, true, true, true);
} }
public UserSettings() { public UserSettings() {
this(NotificationsSendFor.NONE, false, true, true, true); this(NotificationsSendFor.NONE);
} }
public static UserSettings createDefault() { public static UserSettings createDefault() {
return UserSettings.builder() return new UserSettings();
.notificationsSendFor(NotificationsSendFor.NONE)
.vorgangCreated(false)
.vorgangAssignedToUser(true)
.postfachNachrichtFromAntragsteller(true)
.wiedervorlageOverdue(true).build();
} }
} }
...@@ -37,7 +37,9 @@ import org.mockito.Spy; ...@@ -37,7 +37,9 @@ import org.mockito.Spy;
import de.ozgcloud.user.User; import de.ozgcloud.user.User;
import de.ozgcloud.user.UserTestFactory; import de.ozgcloud.user.UserTestFactory;
import de.ozgcloud.user.common.DocumentUtils;
import de.ozgcloud.user.settings.NotificationsSendFor; import de.ozgcloud.user.settings.NotificationsSendFor;
import de.ozgcloud.user.settings.UserSettings;
import io.quarkus.mongodb.panache.PanacheQuery; import io.quarkus.mongodb.panache.PanacheQuery;
class RecipientRepositoryTest { class RecipientRepositoryTest {
...@@ -50,7 +52,8 @@ class RecipientRepositoryTest { ...@@ -50,7 +52,8 @@ class RecipientRepositoryTest {
@DisplayName("Test finding users by Organistationseinheit") @DisplayName("Test finding users by Organistationseinheit")
@Nested @Nested
class TestFindByOrganisationsEinheit { class TestFindByOrganisationsEinheit {
private static final String QUERY = ORGANISATIONS_EINHEIT_IDS_FIELD + " = ?1 and " + NOTIFICATION_SEND_FOR_FIELD + " = ?2"; private static final String QUERY = ORGANISATIONS_EINHEIT_IDS_FIELD + " = ?1 and "
+ DocumentUtils.buildFieldPath(USER_SETTINGS_FIELD, UserSettings.NOTIFICATIONS_SEND_FOR_FIELD) + " = ?2";
@Test @Test
void shouldCallFind() { void shouldCallFind() {
......
...@@ -17,6 +17,8 @@ quarkus: ...@@ -17,6 +17,8 @@ quarkus:
auth-server-url: https://sso.dev.by.ozg-cloud.de/realms/by-kiel-dev auth-server-url: https://sso.dev.by.ozg-cloud.de/realms/by-kiel-dev
management: management:
test-port: 9003 test-port: 9003
mongock:
enabled: false
keycloak: keycloak:
url: http://localhost:8088 url: http://localhost:8088
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment