use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectIntoArrayTest method testSelectFromFormDataArray.
@Test
public void testSelectFromFormDataArray() throws Exception {
SqlServiceMock sql = new SqlServiceMock();
Object[][] expectedData = new Object[][] { new Object[] { true, 1, "abc" } };
sql.setResultData(expectedData);
//
MyFormData f1 = new MyFormData();
f1.getActive().setValue(true);
f1.getState().setValue(1);
f1.getName().setValue("abc");
MyFormData f2 = new MyFormData();
f2.getActive().setValue(null);
f2.getState().setValue(null);
f2.getName().setValue(null);
//
MyFormData[] h = new MyFormData[] { f1, f2 };
Object[][] data = sql.select("SELECT A,B,C FROM T WHERE A=:{h.active} AND B=:{h.state} AND C=:{h.name}", new NVPair("h", h));
assertNotNull(data);
assertEquals(2, data.length);
assertArrayEquals(new Object[] { true, 1, "abc" }, data[0]);
assertArrayEquals(new Object[] { true, 1, "abc" }, data[1]);
}
use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectIntoArrayTest method testSelectIntoFormDataWithArray.
@Test
public void testSelectIntoFormDataWithArray() throws Exception {
SqlServiceMock sql = createSqlServiceMock(ROLES_DATA);
//
FormDataWithArray formData = new FormDataWithArray();
formData.getPersonNr().setValue(42L);
sql.selectInto("SELECT ROLE_NR FROM USER_ROLE WHERE USER_NR = :personNr INTO :{roles}", formData);
Long[] r = formData.getRoles().getValue();
assertNotNull(r);
assertEquals(3, r.length);
assertEquals("first role", 3L, r[0].longValue());
assertEquals("second role", 5L, r[1].longValue());
assertEquals("third role", 7L, r[2].longValue());
}
use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectIntoArrayTest method testSelectIntoListInHolder.
@Test
public void testSelectIntoListInHolder() throws Exception {
SqlServiceMock sql = createSqlServiceMock(ROLES_DATA);
//
Holder<List> rolesHolder = new Holder<List>(List.class);
sql.selectInto("SELECT ROLE_NR FROM USER_ROLE WHERE USER_NR = :personNr INTO :{roles}", new NVPair("personNr", 63L), new NVPair("roles", rolesHolder));
List r = rolesHolder.getValue();
assertNotNull(r);
assertEquals(3, r.size());
assertEquals("first role", 3L, r.get(0));
assertEquals("second role", 5L, r.get(1));
assertEquals("third role", 7L, r.get(2));
}
use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectIntoArrayTest method testSelectIntoFormDataArray.
@Test
public void testSelectIntoFormDataArray() throws Exception {
SqlServiceMock sql = createSqlServiceMock(DATA);
//
Object[][] expectedData = DATA;
BeanArrayHolder<MyFormData> h = new BeanArrayHolder<SelectIntoArrayTest.MyFormData>(MyFormData.class);
sql.selectInto("SELECT A,B,C FROM T WHERE D=0 INTO :{h.active},:{h.state},:{h.name}", new NVPair("h", h));
MyFormData[] a = h.getBeans();
assertNotNull(a);
assertEquals(4, a.length);
for (int i = 0; i < a.length; i++) {
a[i].assertValues(expectedData[i]);
}
}
use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.
the class SelectIntoArrayTest method testSelectIntoTableFieldBeanDataInBean.
/**
* {@link TableFieldBeanData} is from type {@link ITableBeanHolder} (introduced with Luna). TableData is in a bean
* (ContainerBean).
*/
@Test
public void testSelectIntoTableFieldBeanDataInBean() throws Exception {
SqlServiceMock sql = createSqlServiceMock(DATA);
//
ContainerBean bean = new ContainerBean();
bean.setTableFieldBeanData(new TableFieldBeanData());
sql.selectInto("SELECT A,B,C FROM T WHERE D=0 INTO :{tableFieldBeanData.active},:{tableFieldBeanData.state},:{tableFieldBeanData.name}", bean);
assertContainsData(bean.getTableFieldBeanData());
}
Aggregations