Skip to content

Commit

Permalink
SonarCloud fixes for SoftAssertionsExtension (assertj#1999)
Browse files Browse the repository at this point in the history
None of these were bugs in practice, but it
is easy to keep SonarCloud happy so let's do
it.
  • Loading branch information
kriegfrj authored Sep 22, 2020
1 parent 3c6bb8a commit 45bbadd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ public void beforeEach(ExtensionContext context) throws Exception {
tlec.setDelegate(collector);
} else {
// Make sure that all of the soft assertion provider instances have their delegate initialised to the assertion error
// collector for the current context. Also check parents (in the case of nested tests).
while (initialiseDelegate(context, collector)) {
// collector for the current context. Also check enclosing contexts (in the case of nested tests).
while (initialiseDelegate(context, collector) && context.getParent().isPresent()) {
context = context.getParent().get();
}
}
Expand Down Expand Up @@ -324,8 +324,7 @@ public void afterTestExecution(ExtensionContext extensionContext) {
AssertionErrorCollector collector;
if (isPerClassConcurrent(extensionContext)) {
ThreadLocalErrorCollector tlec = getThreadLocalCollector(extensionContext);
collector = tlec.getDelegate().get();
// Clear the tlec just in case this thread gets re-used.
collector = tlec.getDelegate().orElseThrow(() -> new IllegalStateException("Expecting delegate to be present for current context"));
tlec.reset();
} else {
collector = getAssertionErrorCollector(extensionContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class SoftAssertionsExtension_InjectionSanityChecking_Test {

@ExtendWith(SoftAssertionsExtension.class)
static private class TestBase {
static abstract class TestBase {
@Test
void myTest() {}
}
Expand Down

0 comments on commit 45bbadd

Please sign in to comment.