Skip to content
Permalink
Browse files
Minor change: scootching up expectation withdrawal so it's not forgot…
…ten.
  • Loading branch information
myrle-krantz committed Jul 20, 2017
1 parent 9d8a694 commit c88105bab2a050e3f8af1b7d707cec9826c0947f
Showing 2 changed files with 8 additions and 6 deletions.
@@ -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 c88105b

Please sign in to comment.