Java Code Examples for com.orientechnologies.orient.core.sql.query.OSQLQuery

The following examples show how to use com.orientechnologies.orient.core.sql.query.OSQLQuery. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Before
public void setup() {
  MockitoAnnotations.initMocks(this);

  when(adapter.getTypeName()).thenReturn(ENTITY_NAME);

  when(db.command(any(OSQLQuery.class))).thenReturn(command);
  when(command.execute(any(Object[].class))).thenReturn(documents);
  when(adapter.transform(documents)).thenReturn(results);

  browseEntitiesByPropertyInSetAction = new BrowseEntitiesByPropertyInSetAction<>(adapter, PROPERTY);
}
 
Example 2
@Test
public void buildsCorrectQueryForSingle() {
  ArgumentCaptor<OSQLQuery> queryCaptor = ArgumentCaptor.forClass(OSQLQuery.class);
  browseEntitiesByPropertyInSetAction.execute(db, newHashSet("Test"));
  verify(db, times(1)).command(queryCaptor.capture());
  assertEquals("SELECT * FROM " + ENTITY_NAME + " WHERE " + PROPERTY + " IN [ ? ]", queryCaptor.getValue().getText());
}
 
Example 3
@Test
public void buildsCorrectQueryForMultiple() {
  ArgumentCaptor<OSQLQuery> queryCaptor = ArgumentCaptor.forClass(OSQLQuery.class);
  browseEntitiesByPropertyInSetAction.execute(db, newHashSet("Test1", "Test2", "Test3"));
  verify(db, times(1)).command(queryCaptor.capture());
  assertEquals("SELECT * FROM " + ENTITY_NAME + " WHERE " + PROPERTY + " IN [ ?,?,? ]", queryCaptor.getValue().getText());
}
 
Example 4
@Override
public OCommandResultListener processListener(final OCommandRequest command,
                                              final Object listener,
                                              final Injector injector,
                                              final Class<?> conversionTarget) {
    checkExec(command instanceof OCommandRequestAbstract,
            "@%s can't be applied to query, because command object %s doesn't support it",
            Listen.class.getSimpleName(), command.getClass().getName());
    return wrap(listener, injector, conversionTarget, ((OSQLQuery) command).getText());
}