use of org.eclipse.scout.rt.shared.services.lookup.ILookupRow in project scout.rt by eclipse.
the class BatchNormalizerTest method setUp.
@Before
public void setUp() throws Exception {
Answer answer = new Answer<List<ILookupRow<Object>>>() {
@Override
public List<ILookupRow<Object>> answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
ILookupCall<?> call = (ILookupCall<?>) args[0];
return createCallResult(call);
}
};
Mockito.doAnswer(answer).when(m_lookupService).getDataByKey(Mockito.<ILookupCall<Object>>any());
Mockito.doAnswer(answer).when(m_lookupService).getDataByAll(Mockito.<ILookupCall<Object>>any());
Mockito.doAnswer(answer).when(m_lookupService).getDataByText(Mockito.<ILookupCall<Object>>any());
Mockito.doAnswer(answer).when(m_lookupService).getDataByRec(Mockito.<ILookupCall<Object>>any());
}
use of org.eclipse.scout.rt.shared.services.lookup.ILookupRow in project scout.rt by eclipse.
the class IncrementalTreeBuilderTest method testCreateParentMap_EmptyTree.
@Test
public void testCreateParentMap_EmptyTree() {
ITree tree = createTestTree();
Map<Long, ILookupRow<Long>> parentMap = new IncrementalTreeBuilder<Long>(null).createParentMap(tree);
assertTrue(parentMap.isEmpty());
}
use of org.eclipse.scout.rt.shared.services.lookup.ILookupRow in project scout.rt by eclipse.
the class IncrementalTreeBuilderTest method testCreatePaths_Empty.
@Test
public void testCreatePaths_Empty() {
ITree tree = createTestTree();
IncrementalTreeBuilder<Long> builder = new IncrementalTreeBuilder<Long>(null);
ArrayList<ILookupRow<Long>> rows = new ArrayList<>();
List<List<ILookupRow<Long>>> paths = builder.createPaths(rows, tree);
assertTrue(paths.isEmpty());
}
use of org.eclipse.scout.rt.shared.services.lookup.ILookupRow in project scout.rt by eclipse.
the class JsonTableTest method testTableEventCoalesceInUi_ReplaceRows.
@Test
public void testTableEventCoalesceInUi_ReplaceRows() throws Exception {
ListBoxTable listbox = new ListBoxTable();
ILookupRow<Long> row1 = new LookupRow<Long>(1L, "Row1");
ILookupRow<Long> row2 = new LookupRow<Long>(2L, "Row2").withActive(false);
ILookupRow<Long> row3 = new LookupRow<Long>(3L, "Row3");
ILookupRow<Long> row4 = new LookupRow<Long>(4L, "Row4");
ArrayList<ITableRow> rowsInitial = new ArrayList<ITableRow>();
rowsInitial.add(listbox.getTableRowBuilder().createTableRow(row1));
rowsInitial.add(listbox.getTableRowBuilder().createTableRow(row2));
rowsInitial.add(listbox.getTableRowBuilder().createTableRow(row3));
ITable table = listbox.getTable();
table.addRows(rowsInitial);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
m_uiSession.currentJsonResponse().addAdapter(jsonTable);
JSONObject response = m_uiSession.currentJsonResponse().toJson();
JsonTestUtility.endRequest(m_uiSession);
JSONArray events = response.optJSONArray("events");
ArrayList<ITableRow> rowsUpdate = new ArrayList<ITableRow>();
rowsUpdate.add(listbox.getTableRowBuilder().createTableRow(row1));
rowsUpdate.add(listbox.getTableRowBuilder().createTableRow(row2));
rowsUpdate.add(listbox.getTableRowBuilder().createTableRow(row3));
rowsUpdate.add(listbox.getTableRowBuilder().createTableRow(row4));
table.replaceRows(rowsUpdate);
response = m_uiSession.currentJsonResponse().toJson();
JsonTestUtility.endRequest(m_uiSession);
events = response.optJSONArray("events");
JSONObject lastEvent = events.optJSONObject(events.length() - 1);
assertEquals(lastEvent.optString("type"), "rowOrderChanged");
JSONArray rowIds = lastEvent.optJSONArray("rowIds");
assertTrue(rowIds.length() == 3);
}
use of org.eclipse.scout.rt.shared.services.lookup.ILookupRow in project scout.rt by eclipse.
the class AbstractContentAssistField method newByKeyLookupRowProvider.
// ==== Lookup row fetching strategies ==== //
/**
* Creates a {@link ILookupRowProvider} to fetch a row by key.
*
* @see LookupCall#getDataByKey()
* @see LookupCall#getDataByAllInBackground(ILookupRowFetchedCallback)
*/
protected ILookupRowProvider<LOOKUP_KEY> newByKeyLookupRowProvider(final LOOKUP_KEY key) {
return new ILookupRowProvider<LOOKUP_KEY>() {
@Override
public void beforeProvide(ILookupCall<LOOKUP_KEY> lookupCall) {
prepareKeyLookup(lookupCall, key);
}
@Override
public void afterProvide(ILookupCall<LOOKUP_KEY> lookupCall, List<ILookupRow<LOOKUP_KEY>> result) {
interceptFilterLookupResult(lookupCall, result);
interceptFilterKeyLookupResult(lookupCall, result);
cleanupResultList(result);
}
@Override
public void provideSync(ILookupCall<LOOKUP_KEY> lookupCall, ILookupRowFetchedCallback<LOOKUP_KEY> callback) {
callback.onSuccess(provide(lookupCall));
}
@Override
public IFuture<Void> provideAsync(ILookupCall<LOOKUP_KEY> lookupCall, ILookupRowFetchedCallback<LOOKUP_KEY> callback, ClientRunContext clientRunContext) {
return lookupCall.getDataByKeyInBackground(clientRunContext, callback);
}
@SuppressWarnings("unchecked")
@Override
public List<ILookupRow<LOOKUP_KEY>> provide(ILookupCall<LOOKUP_KEY> lookupCall) {
return (List<ILookupRow<LOOKUP_KEY>>) lookupCall.getDataByKey();
}
@Override
public String toString() {
ToStringBuilder sb = new ToStringBuilder(this).attr("Key Lookup").attr("key", key);
return sb.toString();
}
};
}
Aggregations