Search in sources :

Example 1 with BeanArrayHolder

use of org.eclipse.scout.rt.platform.holders.BeanArrayHolder 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]);
    }
}
Also used : SqlServiceMock(org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock) NVPair(org.eclipse.scout.rt.platform.holders.NVPair) BeanArrayHolder(org.eclipse.scout.rt.platform.holders.BeanArrayHolder) Test(org.junit.Test)

Example 2 with BeanArrayHolder

use of org.eclipse.scout.rt.platform.holders.BeanArrayHolder 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]);
    }
}
Also used : SqlServiceMock(org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock) NVPair(org.eclipse.scout.rt.platform.holders.NVPair) BeanArrayHolder(org.eclipse.scout.rt.platform.holders.BeanArrayHolder) Test(org.junit.Test)

Aggregations

BeanArrayHolder (org.eclipse.scout.rt.platform.holders.BeanArrayHolder)2 NVPair (org.eclipse.scout.rt.platform.holders.NVPair)2 SqlServiceMock (org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock)2 Test (org.junit.Test)2