|
|
|
@ -22,14 +22,15 @@ import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.junit.runner.RunWith; |
|
|
|
import org.junit.jupiter.api.condition.DisabledForJreRange; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.condition.JRE; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.mongodb.core.MongoOperations; |
|
|
|
import org.springframework.data.mongodb.core.MongoOperations; |
|
|
|
import org.springframework.test.context.ContextConfiguration; |
|
|
|
import org.springframework.test.context.ContextConfiguration; |
|
|
|
import org.springframework.test.context.junit4.SpringRunner; |
|
|
|
import org.springframework.test.context.junit.jupiter.SpringExtension; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Integration test for {@link PersonRepository} for lazy loading support. |
|
|
|
* Integration test for {@link PersonRepository} for lazy loading support. |
|
|
|
@ -38,13 +39,13 @@ import org.springframework.test.context.junit4.SpringRunner; |
|
|
|
* @author Oliver Gierke |
|
|
|
* @author Oliver Gierke |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ContextConfiguration(locations = "PersonRepositoryIntegrationTests-context.xml") |
|
|
|
@ContextConfiguration(locations = "PersonRepositoryIntegrationTests-context.xml") |
|
|
|
@RunWith(SpringRunner.class) |
|
|
|
@ExtendWith(SpringExtension.class) |
|
|
|
public class PersonRepositoryLazyLoadingIntegrationTests { |
|
|
|
public class PersonRepositoryLazyLoadingIntegrationTests { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired PersonRepository repository; |
|
|
|
@Autowired PersonRepository repository; |
|
|
|
@Autowired MongoOperations operations; |
|
|
|
@Autowired MongoOperations operations; |
|
|
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
@BeforeEach |
|
|
|
public void setUp() throws InterruptedException { |
|
|
|
public void setUp() throws InterruptedException { |
|
|
|
|
|
|
|
|
|
|
|
repository.deleteAll(); |
|
|
|
repository.deleteAll(); |
|
|
|
@ -61,7 +62,6 @@ public class PersonRepositoryLazyLoadingIntegrationTests { |
|
|
|
Person person = new Person(); |
|
|
|
Person person = new Person(); |
|
|
|
person.setFirstname("Oliver"); |
|
|
|
person.setFirstname("Oliver"); |
|
|
|
person.setFans(Arrays.asList(thomas)); |
|
|
|
person.setFans(Arrays.asList(thomas)); |
|
|
|
person.setRealFans(new ArrayList<User>(Arrays.asList(thomas))); |
|
|
|
|
|
|
|
repository.save(person); |
|
|
|
repository.save(person); |
|
|
|
|
|
|
|
|
|
|
|
Person oliver = repository.findById(person.id).get(); |
|
|
|
Person oliver = repository.findById(person.id).get(); |
|
|
|
@ -75,7 +75,8 @@ public class PersonRepositoryLazyLoadingIntegrationTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // DATAMONGO-348
|
|
|
|
@Test // DATAMONGO-348
|
|
|
|
public void shouldLoadAssociationWithDbRefOnConcreteCollectionAndLazyLoadingEnabled() throws Exception { |
|
|
|
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "Class Proxies for eg. ArrayList require to open java.util.") |
|
|
|
|
|
|
|
public void shouldLoadAssociationWithDbRefOnConcreteCollectionAndLazyLoadingEnabled() { |
|
|
|
|
|
|
|
|
|
|
|
User thomas = new User(); |
|
|
|
User thomas = new User(); |
|
|
|
thomas.username = "Thomas"; |
|
|
|
thomas.username = "Thomas"; |
|
|
|
@ -83,7 +84,6 @@ public class PersonRepositoryLazyLoadingIntegrationTests { |
|
|
|
|
|
|
|
|
|
|
|
Person person = new Person(); |
|
|
|
Person person = new Person(); |
|
|
|
person.setFirstname("Oliver"); |
|
|
|
person.setFirstname("Oliver"); |
|
|
|
person.setFans(Arrays.asList(thomas)); |
|
|
|
|
|
|
|
person.setRealFans(new ArrayList<User>(Arrays.asList(thomas))); |
|
|
|
person.setRealFans(new ArrayList<User>(Arrays.asList(thomas))); |
|
|
|
repository.save(person); |
|
|
|
repository.save(person); |
|
|
|
|
|
|
|
|
|
|
|
|