Skip to content

Commit

Permalink
APPPOCTOOL-16 Handle error if realm is not found after test
Browse files Browse the repository at this point in the history
  • Loading branch information
pfilippov-epam committed Jun 26, 2024
1 parent 3c76aff commit 830ba44
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static org.springframework.test.context.util.TestContextResourceUtils.convertToClasspathResourcePaths;
import static org.springframework.test.context.util.TestContextResourceUtils.convertToResourceList;

import jakarta.ws.rs.NotFoundException;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.reflect.AnnotatedElement;
Expand Down Expand Up @@ -49,7 +50,11 @@ public void afterTestMethod(@NonNull TestContext ctx) {
if (importedRawRealmNames instanceof List importedRealmNamesList) {
for (var rawRealmName : importedRealmNamesList) {
if (rawRealmName instanceof String realmName) {
keycloak.realm(realmName).remove();
try {
keycloak.realm(realmName).remove();
} catch (NotFoundException e) {
// nothing to do, cause realm is not found
}
}
}
}
Expand Down

0 comments on commit 830ba44

Please sign in to comment.