Skip to content

Commit d913447

Browse files
committed
DATAJDBC-293 - Remove usage of RETURNS_DEEP_STUBS.
This is broken from JDK9 on for generic types. See also: mockito/mockito#357
1 parent f099967 commit d913447

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactoryBeanUnitTests.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.mockito.stubbing.Answer;
2929
import org.springframework.beans.factory.BeanFactory;
3030
import org.springframework.beans.factory.ListableBeanFactory;
31+
import org.springframework.beans.factory.ObjectProvider;
3132
import org.springframework.context.ApplicationEventPublisher;
3233
import org.springframework.data.annotation.Id;
3334
import org.springframework.data.jdbc.core.DataAccessStrategy;
@@ -59,7 +60,7 @@ public class JdbcRepositoryFactoryBeanUnitTests {
5960

6061
@Mock DataAccessStrategy dataAccessStrategy;
6162
@Mock ApplicationEventPublisher publisher;
62-
@Mock(answer = Answers.RETURNS_DEEP_STUBS) ListableBeanFactory beanFactory;
63+
@Mock ListableBeanFactory beanFactory;
6364

6465
RelationalMappingContext mappingContext;
6566

@@ -73,7 +74,10 @@ public void setUp() {
7374

7475

7576
when(beanFactory.getBean(NamedParameterJdbcOperations.class)).thenReturn(mock(NamedParameterJdbcOperations.class));
76-
when(beanFactory.getBeanProvider(DataAccessStrategy.class).getIfAvailable(any()))
77+
78+
ObjectProvider<DataAccessStrategy> provider = mock(ObjectProvider.class);
79+
when(beanFactory.getBeanProvider(DataAccessStrategy.class)).thenReturn(provider);
80+
when(provider.getIfAvailable(any()))
7781
.then((Answer) invocation -> ((Supplier)invocation.getArgument(0)).get());
7882
}
7983

0 commit comments

Comments
 (0)