Skip to content

Commit 92b513d

Browse files
committed
Polish
1 parent d7ac20c commit 92b513d

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfigurationTests.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
import org.junit.jupiter.api.Test;
2828
import org.junit.jupiter.api.extension.ExtendWith;
29-
import org.mockito.invocation.InvocationOnMock;
30-
import org.mockito.stubbing.Answer;
3129

3230
import org.springframework.beans.factory.BeanCreationException;
3331
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -184,18 +182,13 @@ DataSource someDataSource() throws SQLException {
184182

185183
private DataSource mockDataSource(String url) throws SQLException {
186184
DataSource dataSource = mock(DataSource.class);
187-
given(dataSource.getConnection()).will(new Answer<Connection>() {
188-
189-
@Override
190-
public Connection answer(InvocationOnMock invocation) throws Throwable {
191-
assertThat(Thread.currentThread().getContextClassLoader()).isEqualTo(getClass().getClassLoader());
192-
Connection connection = mock(Connection.class);
193-
DatabaseMetaData metadata = mock(DatabaseMetaData.class);
194-
given(connection.getMetaData()).willReturn(metadata);
195-
given(metadata.getURL()).willReturn(url);
196-
return connection;
197-
}
198-
185+
given(dataSource.getConnection()).will((invocation) -> {
186+
assertThat(Thread.currentThread().getContextClassLoader()).isEqualTo(getClass().getClassLoader());
187+
Connection connection = mock(Connection.class);
188+
DatabaseMetaData metadata = mock(DatabaseMetaData.class);
189+
given(connection.getMetaData()).willReturn(metadata);
190+
given(metadata.getURL()).willReturn(url);
191+
return connection;
199192
});
200193

201194
return dataSource;

0 commit comments

Comments
 (0)