Skip to content

Commit

Permalink
Run stream tests between transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
terli00 committed Mar 14, 2024
1 parent 151b24c commit 50df466
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions core/src/test/java/com/kumuluz/ee/rest/test/QueriedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ public void testQueriedAndPaginated() {
q.setOffset(10);
q.setLimit(limit);

em.getTransaction().begin();
Queried<User> queried = JPAUtils.getQueried(em, User.class, q);

Assert.assertNotNull(queried);
Assert.assertEquals(Long.valueOf(100L), queried.getTotalCount());
Assert.assertEquals(limit, queried.stream().count());
em.getTransaction().commit();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ public void testStreamsObject() {
public void testStreamCollect() {
QueryParameters q = new QueryParameters();

em.getTransaction().begin();
Stream<User> users = JPAUtils.getEntityStream(em, User.class, q);

int size = (int) users.count();

Assert.assertNotNull(users);
Assert.assertEquals(100, size);

em.getTransaction().commit();
}

@Test
Expand All @@ -85,7 +86,7 @@ public void testMultipleQuieries() {
Assert.assertNotNull(users);
Assert.assertEquals(100, size);
Assert.assertEquals(totalCount.intValue(), size);

em.getTransaction().commit();
}

@Test(expected = IllegalStateException.class)
Expand Down

0 comments on commit 50df466

Please sign in to comment.