Search in sources :

Example 11 with SqlServiceMock

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

Example 12 with SqlServiceMock

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());
}
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 13 with SqlServiceMock

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

Example 14 with SqlServiceMock

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

Example 15 with SqlServiceMock

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