use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectIntoArrayTest method createSqlServiceMock.
private SqlServiceMock createSqlServiceMock(Object[][] resultData) {
SqlServiceMock sql = new SqlServiceMock();
sql.setResultData(resultData);
return sql;
}
use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectIntoArrayTest method testEmptySelectIntoFormDataWithSet.
@Test
public void testEmptySelectIntoFormDataWithSet() throws Exception {
SqlServiceMock sql = createSqlServiceMock(new Object[][] {});
//
FormDataWithSet formData = new FormDataWithSet();
formData.getPersonNr().setValue(42L);
sql.selectInto("SELECT ROLE_NR FROM USER_ROLE WHERE USER_NR = :personNr INTO :{roles}", formData);
Set<Long> r = formData.getRoles().getValue();
assertNotNull(r);
assertEquals(0, r.size());
}
use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectIntoArrayTest method testSelectIntoTableFieldBeanData.
/**
* {@link TableFieldBeanData} is from type {@link ITableBeanHolder} (introduced with Luna). Direct select.
*/
@Test
public void testSelectIntoTableFieldBeanData() throws Exception {
SqlServiceMock sql = createSqlServiceMock(DATA);
//
TableFieldBeanData tableData = new TableFieldBeanData();
sql.selectInto("SELECT A,B,C FROM T WHERE D=0 INTO :active,:state,:name", tableData);
assertContainsData(tableData);
}
use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectInputBindTest method testBatchUpdateFromArrayInValueField.
/**
* Direct batch update from a array in {@link AbstractValueFieldData}.
*/
@Test
public void testBatchUpdateFromArrayInValueField() throws Exception {
SqlServiceMock sql = createSqlServiceMock();
FormDataWithArray formData = new FormDataWithArray();
formData.getPersonNr().setValue(9L);
formData.getValue().setValue("lorem");
formData.getRoles().setValue(new Long[] { 5L, 6L });
sql.update("UDPATE this_table SET v = :value where r = :{roles} and p = :personNr", formData);
assertExpectedProtocol2(sql);
}
use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectInputBindTest method testBatchUpdateFromTableFieldBeanDataInBean.
/**
* {@link TableFieldBeanData} is from type {@link ITableBeanHolder} (introduced with Luna). TableData for batch update
* is in a bean (ContainerBean).
*/
@Test
public void testBatchUpdateFromTableFieldBeanDataInBean() throws Exception {
SqlServiceMock sql = createSqlServiceMock();
TableFieldBeanData tableData = createTableFieldBeanData(false);
ContainerBean bean = new ContainerBean();
bean.setTableFieldBeanData(tableData);
sql.update("UDPATE my_table SET a=:{tableFieldBeanData.active}, s=:{tableFieldBeanData.state} where n=:{tableFieldBeanData.name} ", bean);
assertExpectedProtocol(sql);
}
Aggregations