Pull request #97: notification preferences fix

Merge in RED/persistence-service from fixes to master

* commit '374fde2263304eae9c4c8c33b38b0384d8a1a379':
  test-fix
  notification preferences fix
This commit is contained in:
Timo Bejan 2021-11-03 10:40:35 +01:00
commit 001d0862d3
3 changed files with 3 additions and 5 deletions

View File

@ -14,7 +14,6 @@ import java.util.List;
@AllArgsConstructor
public class NotificationPreferences {
private String userId;
private boolean inAppNotificationsEnabled;
private boolean emailNotificationsEnabled;
private EmailNotificationType emailNotificationType;

View File

@ -19,11 +19,10 @@ public class NotificationPreferencesPersistenceService {
@Transactional
public void setNotificationPreference(String userId, NotificationPreferences notification) {
notificationPreferencesRepository.findById(userId)
.ifPresentOrElse(n -> {
BeanUtils.copyProperties(notification, n);
}, () -> {
.ifPresentOrElse(n -> BeanUtils.copyProperties(notification, n), () -> {
NotificationPreferencesEntity notificationPreferencesEntity = new NotificationPreferencesEntity();
BeanUtils.copyProperties(notification, notificationPreferencesEntity);
notificationPreferencesEntity.setUserId(userId);
notificationPreferencesRepository.save(notificationPreferencesEntity);
});
}

View File

@ -37,7 +37,7 @@ public class NotificationPreferencesTest extends AbstractPersistenceServerServic
emailNotifications.add(DOSSIER_YOU_OWN_NOTIFICATION_1);
emailNotifications.add(DOSSIER_YOU_OWN_NOTIFICATION_2);
emailNotifications.add(DOSSIER_YOU_OWN_NOTIFICATION_4);
notificationPreferences = new NotificationPreferences(USER_ID, true, true, EmailNotificationType.DAILY, emailNotifications, inAppNotifications);
notificationPreferences = new NotificationPreferences(true, true, EmailNotificationType.DAILY, emailNotifications, inAppNotifications);
}
@Test