Skip to content

Commit

Permalink
Changed test to get working
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Schauer-Koeckeis <[email protected]>
  • Loading branch information
Gepardgame committed Dec 2, 2024
1 parent fc3ed81 commit 2bf9b9d
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import static alpine.persistence.Transaction.defaultOptions;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class TransactionTest {

Expand All @@ -58,20 +59,20 @@ public void tearDown() {

@Test
public void testRetainValues() {
final Team team = qm.callInTransaction(() -> qm.createTeam("foo", true));
final Team team = qm.callInTransaction(() -> qm.createTeam("foo"));
qm.close(); // Close PM to prevent lazy loading of values when getters are called.

// Ensure the values assigned during the transaction are present.
assertThat(team.getName()).isEqualTo("foo");
assertThat(team.getApiKeys()).satisfiesExactly(apiKey -> assertThat(apiKey.getKey()).isNotNull());
assertEquals(0, team.getApiKeys().size());
}

@Test
public void testTransactionRollback() {
assertThatExceptionOfType(IllegalStateException.class)
.isThrownBy(() -> qm.runInTransaction(() -> {
final ManagedUser user = qm.createManagedUser("username", "passwordHash");
final Team team = qm.createTeam("foo", true);
final Team team = qm.createTeam("foo");
final boolean added = qm.addUserToTeam(user, team);
assertThat(added).isTrue();

Expand All @@ -88,7 +89,7 @@ public void testNestedTransactionRollback() {
qm.runInTransaction(() -> {
final ManagedUser userA = qm.createManagedUser("usernameA", "passwordHash");
final ManagedUser userB = qm.createManagedUser("usernameB", "passwordHash");
final Team team = qm.createTeam("foo", true);
final Team team = qm.createTeam("foo");

final boolean addedUserA = qm.addUserToTeam(userA, team);
assertThat(addedUserA).isTrue();
Expand Down Expand Up @@ -176,4 +177,4 @@ public void testSerializableReadRestore() {
assertThat(qm.getPersistenceManager().currentTransaction().getSerializeRead()).isFalse();
}

}
}

0 comments on commit 2bf9b9d

Please sign in to comment.