fix moar flaky StorageTest.testNotificationStorage() [FINERACT-828]

similar fix to earlier Pull Request for the same

also added some more toString()
This commit is contained in:
Michael Vorburger
2020-05-17 21:29:20 +02:00
committed by Michael Vorburger ⛑️
parent e7889f8463
commit 5557b8be4a
3 changed files with 20 additions and 11 deletions
@@ -78,4 +78,9 @@ public class NotificationMapper extends AbstractPersistableCustom {
isRead = read;
}
@Override
public String toString() {
return "NotificationMapper [notification=" + this.notification + ", userId=" + this.userId + ", isRead=" + this.isRead
+ ", createdAt=" + this.createdAt + ", getId()=" + this.getId() + "]";
}
}
@@ -129,7 +129,7 @@ public class AppUser extends AbstractPersistableCustom implements PlatformUser {
String password = command.stringValueOfParameterNamed("password");
final Boolean sendPasswordToEmail = command.booleanObjectValueOfParameterNamed("sendPasswordToEmail");
if (sendPasswordToEmail.booleanValue()) {
if (sendPasswordToEmail) {
password = new RandomPasswordGenerator(13).generate();
}
@@ -309,14 +309,14 @@ public class AppUser extends AbstractPersistableCustom implements PlatformUser {
}
if(this.isSelfServiceUser && command.hasParameter(AppUserConstants.CLIENTS)){
actualChanges.put(AppUserConstants.CLIENTS, command.arrayValueOfParameterNamed(AppUserConstants.CLIENTS));
Set<AppUserClientMapping> newClients = createAppUserClientMappings(clients);
if(this.appUserClientMappings == null){
this.appUserClientMappings = new HashSet<>();
}else{
this.appUserClientMappings.retainAll(newClients);
}
this.appUserClientMappings.addAll(newClients);
actualChanges.put(AppUserConstants.CLIENTS, command.arrayValueOfParameterNamed(AppUserConstants.CLIENTS));
Set<AppUserClientMapping> newClients = createAppUserClientMappings(clients);
if(this.appUserClientMappings == null){
this.appUserClientMappings = new HashSet<>();
}else{
this.appUserClientMappings.retainAll(newClients);
}
this.appUserClientMappings.addAll(newClients);
}else if(!this.isSelfServiceUser && actualChanges.containsKey(AppUserConstants.IS_SELF_SERVICE_USER)){
actualChanges.put(AppUserConstants.CLIENTS, new ArrayList<>());
if(this.appUserClientMappings != null){
@@ -575,7 +575,7 @@ public class AppUser extends AbstractPersistableCustom implements PlatformUser {
public void validateHasPermissionTo(final String function) {
if (hasNotPermissionTo(function)) {
final String authorizationMessage = "User has no authority to: " + function;
logger.info("Unauthorized access: userId: {} action: {} allowed: {}", new Object[] { getId(), function, getAuthorities() });
logger.info("Unauthorized access: userId: {} action: {} allowed: {}", getId(), function, getAuthorities());
throw new NoAuthorizationException(authorizationMessage);
}
}
@@ -663,4 +663,8 @@ public class AppUser extends AbstractPersistableCustom implements PlatformUser {
return newAppUserClientMappings;
}
@Override
public String toString() {
return "AppUser [username=" + this.username + ", getId()=" + this.getId() + "]";
}
}
@@ -122,7 +122,7 @@ public class StorageTest {
);
verify(this.notificationGeneratorWritePlatformService, times(1)).create(refEq(notification, "createdAt"));
verify(this.notificationMapperWritePlatformService, times(1)).create(refEq(notificationMapper));
verify(this.notificationMapperWritePlatformService, times(1)).create(refEq(notificationMapper, "createdAt"));
verify(this.notificationGeneratorReadRepositoryWrapper, times(1)).findById(1L);
assertEquals(actualGeneratedNotificationId, Long.valueOf(1));
}