Skip to content
Permalink
Browse files
Merge pull request #15 from myrle-krantz/develop
minor change
  • Loading branch information
myrle-krantz committed Jul 20, 2017
2 parents 7824c9f + c88105b commit 192355aae4b7f0c5bb72a15b4ed46e83d143f87d
Showing 2 changed files with 9 additions and 7 deletions.
@@ -149,7 +149,7 @@ public List<EventExpectation> postApplicationPermittableGroups(
//You might look at this and wonder: "Why isn't she returning a stream here? She's just turning it back into
//a stream on the other side..."
//The answer is that you need the createOrFindPermittableGroup to be executed in the proper tenant context. If you
//return the stream, the call to createOrFindPermittableGroup will be executed when the stream is itereated over.
//return the stream, the call to createOrFindPermittableGroup will be executed when the stream is iterated over.
return permittableGroups.map(x -> createOrFindPermittableGroup(identityService, x)).collect(Collectors.toList());
} catch (final Exception e) {
throw new IllegalStateException(e);
@@ -254,25 +254,24 @@ EventExpectation createOrFindPermittableGroup(
}
catch (final PermittableGroupAlreadyExistsException groupAlreadyExistsException)
{
identityListener.withdrawExpectation(eventExpectation);
//if the group already exists, read out and compare. If the group is the same, there is nothing left to do.
final PermittableGroup existingGroup = identityService.getPermittableGroup(permittableGroup.getIdentifier());
if (!existingGroup.getIdentifier().equals(permittableGroup.getIdentifier())) {
logger.error("Group '{}' already exists for tenant {}, but has a different name {} (strange).", permittableGroup.getIdentifier(), TenantContextHolder.checkedGetIdentifier(), existingGroup.getIdentifier());
identityListener.withdrawExpectation(eventExpectation);
}

//Compare as sets because I'm not going to get into a hissy fit over order.
final Set<PermittableEndpoint> existingGroupPermittables = new HashSet<>(existingGroup.getPermittables());
final Set<PermittableEndpoint> newGroupPermittables = new HashSet<>(permittableGroup.getPermittables());
if (!existingGroupPermittables.equals(newGroupPermittables)) {
logger.error("Group '{}' already exists for tenant {}, but has different contents.", permittableGroup.getIdentifier(), TenantContextHolder.checkedGetIdentifier());
identityListener.withdrawExpectation(eventExpectation);
}
}
catch (final RuntimeException unexpected)
{
logger.error("Creating group '{}' for tenant {} failed.", permittableGroup.getIdentifier(), TenantContextHolder.checkedGetIdentifier(), unexpected);
identityListener.withdrawExpectation(eventExpectation);
logger.error("Creating group '{}' for tenant {} failed.", permittableGroup.getIdentifier(), TenantContextHolder.checkedGetIdentifier(), unexpected);
}
return eventExpectation;
}
@@ -103,7 +103,8 @@ public void createOrFindPermittableGroupThatAlreadyExists() throws Exception {

try (final AutoTenantContext ignored = new AutoTenantContext("blah")) {
final SystemProperties systemProperties = new SystemProperties();
new IdentityServiceInitializer(identityListenerMock, null, null, loggerMock, systemProperties).createOrFindPermittableGroup(identityServiceMock, group1);
new IdentityServiceInitializer(identityListenerMock, null, null, loggerMock, systemProperties)
.createOrFindPermittableGroup(identityServiceMock, group1);
}
}

@@ -118,7 +119,8 @@ public void createOrFindPermittableGroupThatAlreadyExistsDifferently() throws Ex

try (final AutoTenantContext ignored = new AutoTenantContext("blah")) {
final SystemProperties systemProperties = new SystemProperties();
new IdentityServiceInitializer(identityListenerMock, null, null, loggerMock, systemProperties).createOrFindPermittableGroup(identityServiceMock, group1);
new IdentityServiceInitializer(identityListenerMock, null, null, loggerMock, systemProperties)
.createOrFindPermittableGroup(identityServiceMock, group1);
}

verify(loggerMock).error(anyString(), anyString(), anyString());
@@ -135,7 +137,8 @@ public void createOrFindPermittableGroupWhenIsisCallFails() throws Exception {

try (final AutoTenantContext ignored = new AutoTenantContext("blah")) {
final SystemProperties systemProperties = new SystemProperties();
new IdentityServiceInitializer(identityListenerMock, null, null, loggerMock, systemProperties).createOrFindPermittableGroup(identityServiceMock, group1);
new IdentityServiceInitializer(identityListenerMock, null, null, loggerMock, systemProperties)
.createOrFindPermittableGroup(identityServiceMock, group1);
}

verify(loggerMock).error(anyString(), anyString(), anyString(), isA(IllegalStateException.class));

0 comments on commit 192355a

Please sign in to comment.