Skip to content

Commit

Permalink
✅ (org): Create test that uses the test data
Browse files Browse the repository at this point in the history
  • Loading branch information
byte-sized-emi committed Dec 12, 2024
1 parent 0af0883 commit 788d0a1
Showing 1 changed file with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -36,6 +32,9 @@ class BommelTest {
@Inject
BommelTestResourceCreator resourceCreator;

@Inject
Flyway flyway;

@BeforeEach
@Transactional
void clearDatabase() {
Expand Down Expand Up @@ -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<TreeSearchBommel> treeSearchParents = repo.getParents(existingBommels.get(3));
List<TreeSearchBommel> treeSearchParents = repo.getParents(child);

// Assert
var actualParents = treeSearchParents.stream()
Expand Down

0 comments on commit 788d0a1

Please sign in to comment.