perf(document): EAGER→LAZY migration with @EntityGraph + @BatchSize (#467) #622
@@ -18,6 +18,7 @@ import org.springframework.test.context.bean.override.mockito.MockitoBean;
|
||||
import software.amazon.awssdk.services.s3.S3Client;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -84,7 +85,7 @@ class DocumentLazyLoadingTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getRecentActivity_doesNotThrowLazyInitializationException() {
|
||||
void getRecentActivity_collectionsAccessibleAfterReturn() {
|
||||
Person sender = personRepository.save(Person.builder().firstName("Hans").lastName("RaSender").build());
|
||||
Tag tag = tagRepository.save(Tag.builder().name("RaTag").build());
|
||||
for (int i = 0; i < 3; i++) {
|
||||
@@ -96,8 +97,13 @@ class DocumentLazyLoadingTest {
|
||||
.build());
|
||||
}
|
||||
|
||||
assertThatCode(() -> documentService.getRecentActivity(3))
|
||||
.doesNotThrowAnyException();
|
||||
List<Document> results = documentService.getRecentActivity(3);
|
||||
|
||||
assertThatCode(() -> {
|
||||
results.forEach(d -> assertThat(d.getSender()).isNotNull());
|
||||
results.forEach(d -> assertThat(d.getSender().getLastName()).isNotNull());
|
||||
results.forEach(d -> d.getTags().size());
|
||||
}).doesNotThrowAnyException();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user