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 {
public static final String USERNAME_FIELD = "username";
public static final String ORGANISATIONS_EINHEIT_IDS_FIELD = "organisationsEinheitIds";
public static final String USER_SETTINGS_FIELD = "userSettings";
public static final String NOTIFICATION_SEND_FOR_FIELD = "userSettings.notificationsSendFor";
@JsonIgnore
@BsonId
......
......@@ -4,17 +4,21 @@ import static de.ozgcloud.user.User.*;
import java.util.List;
import jakarta.enterprise.context.ApplicationScoped;
import de.ozgcloud.common.logging.OzgCloudLogging;
import de.ozgcloud.user.User;
import de.ozgcloud.user.common.DocumentUtils;
import de.ozgcloud.user.settings.NotificationsSendFor;
import de.ozgcloud.user.settings.UserSettings;
import io.quarkus.mongodb.panache.PanacheMongoRepository;
import jakarta.enterprise.context.ApplicationScoped;
@ApplicationScoped
@OzgCloudLogging
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) {
return find(SEARCH_RECIPIENT_QUERY, organisationseinheitId, NotificationsSendFor.ALL.name()).list();
......
......@@ -23,6 +23,7 @@
*/
package de.ozgcloud.user.settings;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
......@@ -30,6 +31,7 @@ import lombok.Setter;
@Builder(toBuilder = true)
@Getter
@Setter
@AllArgsConstructor
public class UserSettings {
public static final String NOTIFICATIONS_SEND_FOR_FIELD = "notificationsSendFor";
......@@ -44,29 +46,15 @@ public class UserSettings {
private boolean postfachNachrichtFromAntragsteller;
private boolean wiedervorlageOverdue;
public UserSettings(final NotificationsSendFor notificationsSendFor, final boolean vorgangCreated, final boolean vorgangAssignedToUser,
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) {
public UserSettings(NotificationsSendFor notificationsSendFor) {
this(notificationsSendFor, notificationsSendFor == NotificationsSendFor.ALL, true, true, true);
}
public UserSettings() {
this(NotificationsSendFor.NONE, false, true, true, true);
this(NotificationsSendFor.NONE);
}
public static UserSettings createDefault() {
return UserSettings.builder()
.notificationsSendFor(NotificationsSendFor.NONE)
.vorgangCreated(false)
.vorgangAssignedToUser(true)
.postfachNachrichtFromAntragsteller(true)
.wiedervorlageOverdue(true).build();
return new UserSettings();
}
}
......@@ -37,7 +37,9 @@ import org.mockito.Spy;
import de.ozgcloud.user.User;
import de.ozgcloud.user.UserTestFactory;
import de.ozgcloud.user.common.DocumentUtils;
import de.ozgcloud.user.settings.NotificationsSendFor;
import de.ozgcloud.user.settings.UserSettings;
import io.quarkus.mongodb.panache.PanacheQuery;
class RecipientRepositoryTest {
......@@ -50,7 +52,8 @@ class RecipientRepositoryTest {
@DisplayName("Test finding users by Organistationseinheit")
@Nested
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
void shouldCallFind() {
......
......@@ -17,6 +17,8 @@ quarkus:
auth-server-url: https://sso.dev.by.ozg-cloud.de/realms/by-kiel-dev
management:
test-port: 9003
mongock:
enabled: false
keycloak:
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