Search in sources :

Example 1 with FormDataWithSet

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

the class SelectInputBindTest method testBatchUpdateFromSetInValueField.

/**
 * Direct batch update from a array in {@link AbstractValueFieldData}.
 */
@Test
public void testBatchUpdateFromSetInValueField() throws Exception {
    SqlServiceMock sql = createSqlServiceMock();
    Set<Long> roles = new HashSet<Long>();
    roles.add(5L);
    roles.add(6L);
    FormDataWithSet formData = new FormDataWithSet();
    formData.getPersonNr().setValue(9L);
    formData.getValue().setValue("lorem");
    formData.getRoles().setValue(roles);
    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) FormDataWithSet(org.eclipse.scout.rt.server.jdbc.fixture.FormDataWithSet) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with FormDataWithSet

use of org.eclipse.scout.rt.server.jdbc.fixture.FormDataWithSet 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 3 with FormDataWithSet

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

the class SelectInputBindTest method testEmptyBatchUpdateFromSetInValueField.

/**
 * Direct batch update from a array in {@link AbstractValueFieldData}.
 */
@Test
public void testEmptyBatchUpdateFromSetInValueField() throws Exception {
    SqlServiceMock sql = createSqlServiceMock();
    FormDataWithSet formData = new FormDataWithSet();
    formData.getPersonNr().setValue(9L);
    formData.getValue().setValue("lorem");
    formData.getRoles().setValue(Collections.<Long>emptySet());
    sql.update("UDPATE this_table SET v = :value where r = :{roles} and p = :personNr", formData);
    assertEquals("", sql.getProtocol().toString());
}
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 4 with FormDataWithSet

use of org.eclipse.scout.rt.server.jdbc.fixture.FormDataWithSet 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)

Aggregations

FormDataWithSet (org.eclipse.scout.rt.server.jdbc.fixture.FormDataWithSet)4 SqlServiceMock (org.eclipse.scout.rt.server.jdbc.fixture.SqlServiceMock)4 Test (org.junit.Test)4 HashSet (java.util.HashSet)1