Skip to content

Commit

Permalink
OGM-1542 Distinct count tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Mylnikov authored and DavideD committed Dec 14, 2018
1 parent 896f5f8 commit a8567d5
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,30 @@ public void shouldCountEntities() {
} );
}

@Test
public void shouldCountByName() {
inTransaction( em -> {
Number result = (Number) em.createQuery( "SELECT COUNT(author.name) FROM Author author" ).getSingleResult();
assertThat( result.intValue() ).isEqualTo( 4 );
} );
}

@Test
public void shouldCountDistinctByName() {
inTransaction( em -> {
Number result = (Number) em.createQuery( "SELECT COUNT(DISTINCT author.name) FROM Author author" ).getSingleResult();
assertThat( result.intValue() ).isEqualTo( 2 );
} );
}

@Test
public void shouldCountDistinctWithNullValues() {
inTransaction( em -> {
Number result = (Number) em.createQuery( "SELECT COUNT(DISTINCT author.age) FROM Author author" ).getSingleResult();
assertThat( result.intValue() ).isEqualTo( 3 );
} );
}

@Test
public void shouldCountEntitiesWithCondition() {
inTransaction( em -> {
Expand Down

0 comments on commit a8567d5

Please sign in to comment.