Search in sources :

Example 1 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 testRecLookupWithExceptions.

@Test(expected = PlatformException.class)
public void testRecLookupWithExceptions() {
    m_field.setLookupCall(new TestLookupCall());
    throwOnRecLookup();
    m_field.callSubTreeLookup(1L, TriState.TRUE);
}
Also used : TestLookupCall(org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall) Test(org.junit.Test)

Example 2 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 testTextLookupWithExceptions.

@SuppressWarnings("unchecked")
@Test(expected = PlatformException.class)
public void testTextLookupWithExceptions() {
    m_field.setLookupCall(new TestLookupCall());
    when(m_mock_service.getDataByText(any(ILookupCall.class))).thenThrow(new PlatformException("lookup error"));
    m_field.callTextLookup("test", 10);
}
Also used : TestLookupCall(org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall) Test(org.junit.Test)

Example 3 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 testTextLookupExceptions_InBackground.

@SuppressWarnings("unchecked")
@Test
public void testTextLookupExceptions_InBackground() throws InterruptedException {
    m_field.setLookupCall(new TestLookupCall());
    final String errorText = "lookup error";
    when(m_mock_service.getDataByText(any(ILookupCall.class))).thenThrow(new PlatformException(errorText));
    final IBlockingCondition bc = Jobs.newBlockingCondition(true);
    ILookupRowFetchedCallback callback = new ILookupRowFetchedCallback<Long>() {

        @Override
        public void onSuccess(List<? extends ILookupRow<Long>> rows) {
            Assert.fail("no exception thrown");
            bc.setBlocking(false);
        }

        @Override
        public void onFailure(RuntimeException exception) {
            assertTrue(exception instanceof PlatformException);
            assertEquals(errorText, exception.getMessage());
            bc.setBlocking(false);
        }
    };
    m_field.callTextLookupInBackground("", 10, callback);
    bc.waitFor();
}
Also used : TestLookupCall(org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall) ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) ILookupRowFetchedCallback(org.eclipse.scout.rt.shared.services.lookup.ILookupRowFetchedCallback) ArrayList(java.util.ArrayList) List(java.util.List) ILookupCall(org.eclipse.scout.rt.shared.services.lookup.ILookupCall) IBlockingCondition(org.eclipse.scout.rt.platform.job.IBlockingCondition) Test(org.junit.Test)

Example 4 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 testSubteeLookup_WithPrepare.

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

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

Example 5 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_NullParent.

@Test
public void testSubtreeLookup_NullParent() {
    m_field.setLookupCall(new TestLookupCall());
    List<? extends ILookupRow<Long>> rows = m_field.callSubTreeLookup(null);
    assertEquals(0, rows.size());
}
Also used : TestLookupCall(org.eclipse.scout.rt.client.ui.form.fields.smartfield.fixture.TestLookupCall) 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