diff --git a/backend/app.hopps.org/src/test/java/app/hopps/org/jpa/BommelTest.java b/backend/app.hopps.org/src/test/java/app/hopps/org/jpa/BommelTest.java index 8e0bd9ac..89b51403 100644 --- a/backend/app.hopps.org/src/test/java/app/hopps/org/jpa/BommelTest.java +++ b/backend/app.hopps.org/src/test/java/app/hopps/org/jpa/BommelTest.java @@ -7,8 +7,7 @@ import jakarta.inject.Inject; import jakarta.transaction.Transactional; import jakarta.ws.rs.WebApplicationException; -import org.hamcrest.Matchers; -import org.hamcrest.collection.IsIterableWithSize; +import org.flywaydb.core.Flyway; import org.instancio.Instancio; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -19,9 +18,6 @@ import java.util.List; import java.util.Set; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.collection.IsIterableWithSize.iterableWithSize; import static org.junit.jupiter.api.Assertions.*; @QuarkusTest @@ -36,6 +32,9 @@ class BommelTest { @Inject BommelTestResourceCreator resourceCreator; + @Inject + Flyway flyway; + @BeforeEach @Transactional void clearDatabase() { @@ -105,14 +104,24 @@ void getChildrenWithCycle() { } @Test - @TestTransaction void simpleGetParentsTest() { // Arrange - var existingBommels = resourceCreator.setupSimpleTree(); - var expectedParentsList = List.of(existingBommels.get(1), existingBommels.getFirst()); + flyway.clean(); + flyway.migrate(); + + // bommel with id=2 is root + // id=4 is child of id=2 + // id=7 is child of id=4 + + var expectedParentsList = List.of( + repo.findById(4L), + repo.findById(2L) + ); + + var child = repo.findById(7L); // Act - List treeSearchParents = repo.getParents(existingBommels.get(3)); + List treeSearchParents = repo.getParents(child); // Assert var actualParents = treeSearchParents.stream()