Search in sources :

Example 16 with EmployeeDaoImpl

use of org.seasar.doma.it.dao.EmployeeDaoImpl in project doma by domaframework.

the class SqlFileSelectStreamTest method testDomain_limitOffset.

@Test
public void testDomain_limitOffset(Config config) throws Exception {
    EmployeeDao dao = new EmployeeDaoImpl(config);
    BigDecimal total = dao.streamAllSalary(s -> s.filter(Objects::nonNull).reduce(BigDecimal.ZERO, (x, y) -> x.add(y)), SelectOptions.get().limit(5).offset(3));
    assertTrue(new BigDecimal("6900").compareTo(total) == 0);
}
Also used : Employee(org.seasar.doma.it.entity.Employee) IntegrationTestEnvironment(org.seasar.doma.it.IntegrationTestEnvironment) SelectOptions(org.seasar.doma.jdbc.SelectOptions) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) BigDecimal(java.math.BigDecimal) Stream(java.util.stream.Stream) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) Config(org.seasar.doma.jdbc.Config) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) Objects(java.util.Objects) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) BigDecimal(java.math.BigDecimal) Test(org.junit.jupiter.api.Test)

Example 17 with EmployeeDaoImpl

use of org.seasar.doma.it.dao.EmployeeDaoImpl in project doma by domaframework.

the class SqlFileSelectStreamTest method testMap_limitOffset.

@Test
public void testMap_limitOffset(Config config) throws Exception {
    EmployeeDao dao = new EmployeeDaoImpl(config);
    long count = dao.selectAllAsMapList(s -> s.count(), SelectOptions.get().limit(5).offset(3));
    assertEquals(5L, count);
}
Also used : EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) Test(org.junit.jupiter.api.Test)

Example 18 with EmployeeDaoImpl

use of org.seasar.doma.it.dao.EmployeeDaoImpl in project doma by domaframework.

the class SqlFileSelectStreamTest method testStreamAll_resultStream.

@Test
public void testStreamAll_resultStream(Config config) throws Exception {
    EmployeeDao dao = new EmployeeDaoImpl(config);
    Long count = null;
    try (Stream<Employee> stream = dao.streamAll()) {
        count = stream.filter(e -> e.getEmployeeName() != null).filter(e -> e.getEmployeeName().startsWith("S")).count();
    }
    assertEquals(Long.valueOf(2), count);
}
Also used : Employee(org.seasar.doma.it.entity.Employee) IntegrationTestEnvironment(org.seasar.doma.it.IntegrationTestEnvironment) SelectOptions(org.seasar.doma.jdbc.SelectOptions) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) BigDecimal(java.math.BigDecimal) Stream(java.util.stream.Stream) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) Config(org.seasar.doma.jdbc.Config) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) Employee(org.seasar.doma.it.entity.Employee) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) Test(org.junit.jupiter.api.Test)

Example 19 with EmployeeDaoImpl

use of org.seasar.doma.it.dao.EmployeeDaoImpl in project doma by domaframework.

the class SqlFileSelectStreamTest method testEntity_limitOffset.

@Test
public void testEntity_limitOffset(Config config) throws Exception {
    EmployeeDao dao = new EmployeeDaoImpl(config);
    long count = dao.streamAll(s -> s.count(), SelectOptions.get().limit(5).offset(3));
    assertEquals(5L, count);
}
Also used : EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) Test(org.junit.jupiter.api.Test)

Example 20 with EmployeeDaoImpl

use of org.seasar.doma.it.dao.EmployeeDaoImpl in project doma by domaframework.

the class SqlFileSelectStreamTest method testMap.

@Test
public void testMap(Config config) throws Exception {
    EmployeeDao dao = new EmployeeDaoImpl(config);
    long count = dao.selectAllAsMapList(s -> s.count());
    assertEquals(14L, count);
}
Also used : EmployeeDao(org.seasar.doma.it.dao.EmployeeDao) EmployeeDaoImpl(org.seasar.doma.it.dao.EmployeeDaoImpl) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)54 EmployeeDao (org.seasar.doma.it.dao.EmployeeDao)54 EmployeeDaoImpl (org.seasar.doma.it.dao.EmployeeDaoImpl)54 Employee (org.seasar.doma.it.entity.Employee)43 Run (org.seasar.doma.it.Run)8 CompKeyEmployeeDao (org.seasar.doma.it.dao.CompKeyEmployeeDao)8 CompKeyEmployeeDaoImpl (org.seasar.doma.it.dao.CompKeyEmployeeDaoImpl)8 CompKeyEmployee (org.seasar.doma.it.entity.CompKeyEmployee)8 SelectOptions (org.seasar.doma.jdbc.SelectOptions)8 BigDecimal (java.math.BigDecimal)6 Objects (java.util.Objects)4 Stream (java.util.stream.Stream)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)4 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)4 IntegrationTestEnvironment (org.seasar.doma.it.IntegrationTestEnvironment)4 Config (org.seasar.doma.jdbc.Config)4 HiredateImpl (org.seasar.doma.it.domain.HiredateImpl)2 OptimisticLockException (org.seasar.doma.jdbc.OptimisticLockException)2 List (java.util.List)1