Added count queries

This commit is contained in:
Amitabh Tiwari 2021-03-07 16:43:52 +05:30
parent 0900935000
commit 2fff4d24c5
1 changed files with 11 additions and 6 deletions

View File

@ -22,25 +22,30 @@ public class CountQueryIntegrationTest {
@Test
public void givenValidData_whenSimpleSelect_thenSucceed() {
int count = dsl.select().from(AUTHOR).execute();
int count = dsl.select().from(AUTHOR)
.execute();
Assert.assertEquals(3, count);
}
@Test
public void givenValidData_whenSelectCount_thenSucceed() {
int count = dsl.selectCount().from(AUTHOR).fetchOne(0, int.class);
int count = dsl.selectCount().from(AUTHOR)
.where(AUTHOR.FIRST_NAME.equalIgnoreCase("Bryan"))
.fetchOne(0, int.class);
Assert.assertEquals(3, count);
}
@Test
public void givenValidData_whenCount_thenSucceed() {
int count = dsl.select(DSL.count()).from(AUTHOR).fetchOne(0, int.class);
Assert.assertEquals(3, count);
int count = dsl.select(DSL.count()).from(AUTHOR)
.fetchOne(0, int.class);
Assert.assertEquals(1, count);
}
@Test
public void givenValidData_whenFetchCount_thenSucceed() {
int count = dsl.fetchCount(DSL.selectFrom(AUTHOR));
Assert.assertEquals(3, count);
int count = dsl.fetchCount(DSL.selectFrom(AUTHOR)
.where(AUTHOR.FIRST_NAME.equalIgnoreCase("Bryan")));
Assert.assertEquals(1, count);
}
}