Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Oct 4, 2023
1 parent 0afcb4d commit 95139fc
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.AnnotationConfigurationException;
import org.springframework.test.context.TestContext;
import org.springframework.test.context.jdbc.SqlConfig.TransactionMode;

import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
Expand All @@ -32,6 +31,7 @@
import static org.mockito.Mockito.mock;
import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.AFTER_TEST_CLASS;
import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TEST_CLASS;
import static org.springframework.test.context.jdbc.SqlConfig.TransactionMode.ISOLATED;

/**
* Unit tests for {@link SqlScriptsTestExecutionListener}.
Expand Down Expand Up @@ -71,11 +71,12 @@ void valueAndScriptsDeclared() throws Exception {
BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz);
given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("foo"));

assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
listener.beforeTestMethod(testContext))
.withMessageContaining("Different @AliasFor mirror values")
.withMessageContaining("attribute 'scripts' and its alias 'value'")
.withMessageContaining("values of [{bar}] and [{foo}]");
assertThatExceptionOfType(AnnotationConfigurationException.class)
.isThrownBy(() -> listener.beforeTestMethod(testContext))
.withMessageContainingAll(
"Different @AliasFor mirror values",
"attribute 'scripts' and its alias 'value'",
"values of [{bar}] and [{foo}]");
}

@Test
Expand Down Expand Up @@ -129,9 +130,9 @@ void afterTestClassOnMethod() throws Exception {
}

private void assertExceptionContains(String msg) throws Exception {
assertThatIllegalStateException().isThrownBy(() ->
listener.beforeTestMethod(testContext))
.withMessageContaining(msg);
assertThatIllegalStateException()
.isThrownBy(() -> listener.beforeTestMethod(testContext))
.withMessageContaining(msg);
}


Expand Down Expand Up @@ -160,7 +161,7 @@ public void foo() {

static class IsolatedWithoutTxMgr {

@Sql(scripts = "foo.sql", config = @SqlConfig(transactionMode = TransactionMode.ISOLATED))
@Sql(scripts = "foo.sql", config = @SqlConfig(transactionMode = ISOLATED))
public void foo() {
}
}
Expand Down

0 comments on commit 95139fc

Please sign in to comment.