use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectIntoArrayTest method testSelect.
@Test
public void testSelect() throws Exception {
SqlServiceMock sql = createSqlServiceMock(DATA);
//
Object[][] data = sql.select("SELECT A,B,C FROM T WHERE D=0");
Object[][] expectedData = DATA;
assertNotNull(data);
assertEquals(4, data.length);
for (int i = 0; i < data.length; i++) {
assertArrayEquals(expectedData[i], data[i]);
}
}
use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectIntoArrayTest method testSelectIntoTableFieldBeanDataInNVPair.
/**
* {@link TableFieldBeanData} is from type {@link ITableBeanHolder} (introduced with Luna). TableData is in NVPair
* bind.
*/
@Test
public void testSelectIntoTableFieldBeanDataInNVPair() throws Exception {
SqlServiceMock sql = createSqlServiceMock(DATA);
//
TableFieldBeanData tableData = new TableFieldBeanData();
sql.selectInto("SELECT A,B,C FROM T WHERE D=0 INTO :{table.active},:{table.state},:{table.name}", new NVPair("table", tableData));
assertContainsData(tableData);
}
use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectIntoArrayTest method testSelectIntoBeanArray.
@Test
public void testSelectIntoBeanArray() throws Exception {
SqlServiceMock sql = createSqlServiceMock(DATA);
//
BeanArrayHolder<MyBean> h = new BeanArrayHolder<SelectIntoArrayTest.MyBean>(MyBean.class);
sql.selectInto("SELECT A,B,C FROM T WHERE D=0 INTO :{h.active},:{h.state},:{h.name}", new NVPair("h", h));
MyBean[] a = h.getBeans();
assertNotNull(a);
assertEquals(4, a.length);
for (int i = 0; i < a.length; i++) {
a[i].assertValues(DATA[i]);
}
}
use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectIntoArrayTest method testSelectIntoFormDataWithSet.
@Test
public void testSelectIntoFormDataWithSet() throws Exception {
SqlServiceMock sql = createSqlServiceMock(ROLES_DATA);
//
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(3, r.size());
assertTrue("role contains 3", r.contains(3L));
assertTrue("role contains 5", r.contains(5L));
assertTrue("role contains 7", r.contains(7L));
}
use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectIntoArrayTest method testSelectIntoTableFieldBeanDataInMap.
/**
* {@link TableFieldBeanData} is from type {@link ITableBeanHolder} (introduced with Luna). TableData is in Map bind.
*/
@Test
public void testSelectIntoTableFieldBeanDataInMap() throws Exception {
SqlServiceMock sql = createSqlServiceMock(DATA);
//
TableFieldBeanData tableData = new TableFieldBeanData();
Map<String, ?> map = Collections.singletonMap("table", tableData);
sql.selectInto("SELECT A,B,C FROM T WHERE D=0 INTO :{table.active},:{table.state},:{table.name}", map);
assertContainsData(tableData);
}
Aggregations