Search in sources :

Example 26 with SqlServiceMock

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

Example 27 with SqlServiceMock

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

Example 28 with SqlServiceMock

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]);
    }
}
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 29 with SqlServiceMock

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));
}
Also used : SqlServiceMock(org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock) FormDataWithSet(org.eclipse.scout.rt.server.jdbc.fixture.FormDataWithSet) Test(org.junit.Test)

Example 30 with SqlServiceMock

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);
}
Also used : SqlServiceMock(org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock) TableFieldBeanData(org.eclipse.scout.rt.server.jdbc.fixture.TableFieldBeanData) Test(org.junit.Test)

Aggregations

SqlServiceMock (org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock)31 Test (org.junit.Test)28 NVPair (org.eclipse.scout.rt.platform.holders.NVPair)12 TableFieldBeanData (org.eclipse.scout.rt.server.jdbc.fixture.TableFieldBeanData)12 TableBeanHolderFilter (org.eclipse.scout.rt.platform.holders.TableBeanHolderFilter)4 FormDataWithSet (org.eclipse.scout.rt.server.jdbc.fixture.FormDataWithSet)4 BeanArrayHolder (org.eclipse.scout.rt.platform.holders.BeanArrayHolder)3 ContainerBean (org.eclipse.scout.rt.server.jdbc.fixture.ContainerBean)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Holder (org.eclipse.scout.rt.platform.holders.Holder)2 ITableBeanHolder (org.eclipse.scout.rt.platform.holders.ITableBeanHolder)2 FormDataWithArray (org.eclipse.scout.rt.server.jdbc.fixture.FormDataWithArray)2 BeanMetaData (org.eclipse.scout.rt.platform.BeanMetaData)1 ITableBeanRowHolder (org.eclipse.scout.rt.platform.holders.ITableBeanRowHolder)1 Before (org.junit.Before)1