Search in sources :

Example 11 with TestLookupCall

use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall in project scout.rt by eclipse.

the class SmartFieldLookupTest method testSubtreeLookupExceptions_InBackground.

@SuppressWarnings("unchecked")
@Test
public void testSubtreeLookupExceptions_InBackground() throws InterruptedException {
    final IBlockingCondition bc = Jobs.newBlockingCondition(true);
    m_field.setLookupCall(new TestLookupCall());
    when(m_mock_service.getDataByRec(any(ILookupCall.class))).thenThrow(new PlatformException("lookup error"));
    IFuture<List<ILookupRow<Long>>> rows = m_field.callSubTreeLookupInBackground(1L, TriState.TRUE, false);
    rows.whenDone(new IDoneHandler<List<ILookupRow<Long>>>() {

        @Override
        public void onDone(DoneEvent<List<ILookupRow<Long>>> event) {
            assertTrue(event.getException() instanceof RuntimeException);
            assertEquals("lookup error", event.getException().getMessage());
            bc.setBlocking(false);
        }
    }, ClientRunContexts.copyCurrent());
    bc.waitFor();
}
Also used : TestLookupCall(org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) ArrayList(java.util.ArrayList) List(java.util.List) IBlockingCondition(org.eclipse.scout.rt.platform.job.IBlockingCondition) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall) Test(org.junit.Test)

Example 12 with TestLookupCall

use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall in project scout.rt by eclipse.

the class SmartFieldLookupTest method testSubtreeLookup_BrowseLimit.

@Test
public void testSubtreeLookup_BrowseLimit() {
    m_field.setLookupCall(new TestLookupCall());
    m_field.setBrowseMaxRowCount(2);
    List<? extends ILookupRow<Long>> rows = m_field.callSubTreeLookup(1L, TriState.FALSE);
    assertEquals(2, rows.size());
}
Also used : TestLookupCall(org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall) Test(org.junit.Test)

Example 13 with TestLookupCall

use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall in project scout.rt by eclipse.

the class SmartFieldLookupTest method testSubtreeLookup_WithMasterField.

@Test
public void testSubtreeLookup_WithMasterField() {
    IValueField<Long> masterField = new AbstractValueField<Long>() {
    };
    masterField.setValue(testMasterValue);
    m_field.setLookupCall(new TestLookupCall());
    m_field.setMasterField(masterField);
    List<? extends ILookupRow<Long>> rows2 = m_field.callSubTreeLookup(1L);
    assertEquals(2, rows2.size());
}
Also used : AbstractValueField(org.eclipse.scout.rt.client.ui.form.fields.AbstractValueField) TestLookupCall(org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall) Test(org.junit.Test)

Example 14 with TestLookupCall

use of org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall in project scout.rt by eclipse.

the class SmartFieldLookupTest method testSubtreeLookup_FilterResult.

@Test
public void testSubtreeLookup_FilterResult() {
    ISmartField<Long> field = new AbstractSmartField<Long>() {

        @Override
        protected void execFilterRecLookupResult(ILookupCall<Long> call, List<ILookupRow<Long>> result) {
            result.clear();
        }
    };
    field.setLookupCall(new TestLookupCall());
    List<? extends ILookupRow<Long>> rows2 = field.callSubTreeLookup(1L);
    assertEquals(0, rows2.size());
}
Also used : TestLookupCall(org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall) ArrayList(java.util.ArrayList) List(java.util.List) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall) Test(org.junit.Test)

Aggregations

TestLookupCall (org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall)14 Test (org.junit.Test)14 ILookupCall (org.eclipse.scout.rt.shared.services.lookup.ILookupCall)6 ArrayList (java.util.ArrayList)4 List (java.util.List)4 PlatformException (org.eclipse.scout.rt.platform.exception.PlatformException)3 AbstractValueField (org.eclipse.scout.rt.client.ui.form.fields.AbstractValueField)2 IBlockingCondition (org.eclipse.scout.rt.platform.job.IBlockingCondition)2 ILookupRow (org.eclipse.scout.rt.shared.services.lookup.ILookupRow)1 ILookupRowFetchedCallback (org.eclipse.scout.rt.shared.services.lookup.ILookupRowFetchedCallback)1