Search in sources :

Example 16 with SqlServiceMock

use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.

the class SelectInputBindTest method testBatchUpdateFromTableBeanHolderFilterInBean.

/**
 * {@link TableFieldBeanData} in combination with {@link TableBeanHolderFilter} (introduced with Luna). TableData for
 * batch update is in a bean (ContainerBean).
 */
@Test
public void testBatchUpdateFromTableBeanHolderFilterInBean() throws Exception {
    SqlServiceMock sql = createSqlServiceMock();
    TableFieldBeanData tableData = createTableFieldBeanData(true);
    TableBeanHolderFilter filter = new TableBeanHolderFilter(tableData, ITableBeanRowHolder.STATUS_UPDATED);
    ContainerBean bean = new ContainerBean();
    bean.setTableBeanHolderFilter(filter);
    sql.update("UDPATE my_table SET a=:{TableBeanHolderFilter.active}, s=:{TableBeanHolderFilter.state} where n=:{TableBeanHolderFilter.name} ", bean);
    assertExpectedProtocol(sql);
}
Also used : TableBeanHolderFilter(org.eclipse.scout.rt.platform.holders.TableBeanHolderFilter) 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)

Example 17 with SqlServiceMock

use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.

the class SelectInputBindTest method testBatchUpdateFromArray.

/**
 * Batch update from an array.
 */
@Test
public void testBatchUpdateFromArray() throws Exception {
    SqlServiceMock sql = createSqlServiceMock();
    Long person = 9L;
    Long[] roles = new Long[] { 5L, 6L };
    sql.update("UDPATE this_table SET v = :value where r = :{roles} and p = :personNr", new NVPair("personNr", person), new NVPair("roles", roles), new NVPair("value", "lorem"));
    assertExpectedProtocol2(sql);
}
Also used : SqlServiceMock(org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock) NVPair(org.eclipse.scout.rt.platform.holders.NVPair) Test(org.junit.Test)

Example 18 with SqlServiceMock

use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.

the class SelectInputBindTest method testBatchUpdateFromTableFieldBeanDataInNVPair.

/**
 * {@link TableFieldBeanData} is from type {@link ITableBeanHolder} (introduced with Luna). TableData for batch update
 * is in NVPair bind.
 */
@Test
public void testBatchUpdateFromTableFieldBeanDataInNVPair() throws Exception {
    SqlServiceMock sql = createSqlServiceMock();
    TableFieldBeanData tableData = createTableFieldBeanData(false);
    sql.update("UDPATE my_table SET a=:{table.active}, s=:{table.state} where n=:{table.name} ", new NVPair("table", tableData));
    assertExpectedProtocol(sql);
}
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 19 with SqlServiceMock

use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.

the class SelectInputBindTest method testBatchUpdateFromTableBeanHolderFilterInNVPair.

/**
 * {@link TableFieldBeanData} in combination with {@link TableBeanHolderFilter} (introduced with Luna). TableData for
 * batch update is in NVPair bind.
 */
@Test
public void testBatchUpdateFromTableBeanHolderFilterInNVPair() throws Exception {
    SqlServiceMock sql = createSqlServiceMock();
    TableFieldBeanData tableData = createTableFieldBeanData(true);
    TableBeanHolderFilter filter = new TableBeanHolderFilter(tableData, ITableBeanRowHolder.STATUS_UPDATED);
    sql.update("UDPATE my_table SET a=:{filter.active}, s=:{filter.state} where n=:{filter.name} ", new NVPair("filter", filter));
    assertExpectedProtocol(sql);
}
Also used : TableBeanHolderFilter(org.eclipse.scout.rt.platform.holders.TableBeanHolderFilter) 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 20 with SqlServiceMock

use of org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock in project scout.rt by eclipse.

the class SelectInputBindTest method testBatchUpdateFromArray2.

/**
 * This test is similar to {@link #testBatchUpdateFromArray()}. It ensure that
 * {@link #assertExpectedProtocol2(SqlServiceMock)} does not care about the order of the elements in the roles array
 * (because in a set you can not ensure the order of the entries in the set)
 */
@Test
public void testBatchUpdateFromArray2() throws Exception {
    SqlServiceMock sql = createSqlServiceMock();
    Long person = 9L;
    Long[] roles = new Long[] { 6L, 5L };
    sql.update("UDPATE this_table SET v = :value where r = :{roles} and p = :personNr", new NVPair("personNr", person), new NVPair("roles", roles), new NVPair("value", "lorem"));
    assertExpectedProtocol2(sql);
}
Also used : SqlServiceMock(org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock) NVPair(org.eclipse.scout.rt.platform.holders.NVPair) 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