Skip to content

Commit

Permalink
Cleanes lazy fetch test up
Browse files Browse the repository at this point in the history
  • Loading branch information
N0W0RK committed Jan 14, 2025
1 parent b6bcda4 commit 461973f
Showing 1 changed file with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,16 @@

import de.tum.cit.aet.artemis.atlas.AbstractAtlasIntegrationTest;
import de.tum.cit.aet.artemis.core.domain.User;
import de.tum.cit.aet.artemis.shared.TestRepositoryConfiguration;
import io.zonky.test.db.AutoConfigureEmbeddedDatabase;
import org.hibernate.Hibernate;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

@SpringBootTest
@AutoConfigureMockMvc
@ExtendWith(SpringExtension.class)
@Execution(ExecutionMode.CONCURRENT)
@Import(TestRepositoryConfiguration.class)
@AutoConfigureEmbeddedDatabase
public class LearnerProfileArchitectureTest extends AbstractAtlasIntegrationTest {

private static final String TEST_PREFIX = "learningpathintegration";
public class LearnerProfileIntegrationTest extends AbstractAtlasIntegrationTest {

private static final String TEST_PREFIX = "learnerprofiledatabase";

private static final int NUMBER_OF_STUDENTS = 1;

Expand All @@ -45,8 +31,8 @@ void setupTestScenario() {

@Test
@WithMockUser(username = STUDENT1_OF_COURSE, roles = "USER")
void testAll_asStudent() {
void testLazyFetchLearnerProfile() {
User user = userTestRepository.getUserWithGroupsAndAuthorities(STUDENT1_OF_COURSE);
assertFalse(Hibernate.isInitialized(user.getLearnerProfile()));
assertThat(Hibernate.isInitialized(user.getLearnerProfile())).isFalse();
}
}

0 comments on commit 461973f

Please sign in to comment.