use of org.seasar.doma.it.entity.Department in project doma by domaframework.
the class AutoInsertTest method test.
@Test
public void test(Config config) throws Exception {
DepartmentDao dao = new DepartmentDaoImpl(config);
Department department = new Department();
department.setDepartmentId(new Identity<Department>(99));
department.setDepartmentNo(99);
department.setDepartmentName("hoge");
department.setLocation(new Location<Department>("foo"));
int result = dao.insert(department);
assertEquals(1, result);
assertEquals(Integer.valueOf(1), department.getVersion());
department = dao.selectById(Integer.valueOf(99));
assertEquals(Integer.valueOf(99), department.getDepartmentId().getValue());
assertEquals(Integer.valueOf(99), department.getDepartmentNo());
assertEquals("hoge", department.getDepartmentName());
assertEquals("foo", department.getLocation().getValue());
assertEquals(Integer.valueOf(1), department.getVersion());
}
use of org.seasar.doma.it.entity.Department in project doma by domaframework.
the class AutoInsertTest method testIdNotAssigned.
@Test
public void testIdNotAssigned(Config config) throws Exception {
DepartmentDao dao = new DepartmentDaoImpl(config);
Department department = new Department();
department.setDepartmentNo(99);
department.setDepartmentName("hoge");
try {
dao.insert(department);
fail();
} catch (JdbcException expected) {
assertEquals(Message.DOMA2020, expected.getMessageResource());
}
}
use of org.seasar.doma.it.entity.Department in project doma by domaframework.
the class AutoBatchInsertTest method test.
@Test
public void test(Config config) throws Exception {
DepartmentDao dao = new DepartmentDaoImpl(config);
Department department = new Department();
department.setDepartmentId(new Identity<Department>(99));
department.setDepartmentNo(99);
department.setDepartmentName("hoge");
Department department2 = new Department();
department2.setDepartmentId(new Identity<Department>(98));
department2.setDepartmentNo(98);
department2.setDepartmentName("foo");
int[] result = dao.insert(Arrays.asList(department, department2));
assertEquals(2, result.length);
assertEquals(1, result[0]);
assertEquals(1, result[1]);
assertEquals(Integer.valueOf(1), department.getVersion());
assertEquals(Integer.valueOf(1), department2.getVersion());
department = dao.selectById(99);
assertEquals(Integer.valueOf(99), department.getDepartmentId().getValue());
assertEquals(Integer.valueOf(99), department.getDepartmentNo());
assertEquals("hoge", department.getDepartmentName());
assertNull(department.getLocation().getValue());
assertEquals(Integer.valueOf(1), department.getVersion());
department = dao.selectById(Integer.valueOf(98));
assertEquals(Integer.valueOf(98), department.getDepartmentId().getValue());
assertEquals(Integer.valueOf(98), department.getDepartmentNo());
assertEquals("foo", department.getDepartmentName());
assertNull(department.getLocation().getValue());
assertEquals(Integer.valueOf(1), department.getVersion());
}
Aggregations