PostgresSearchTask implements IDatabaseTask { @Override public void prepare(final IObject query) throws TaskPrepareException { try { SearchMessage message = IOC.resolve(Keys.getOrAdd(SearchMessage.class.getCanonicalName()), query); collection = message.getCollectionName(); criteria = message.getCriteria(); callback = message.getCallback(); preparedQuery = new QueryStatement(); PostgresSchema.search(preparedQuery, collection, criteria); } catch (Exception e) { throw new TaskPrepareException(e); } } PostgresSearchTask(final IStorageConnection connection); @Override void prepare(final IObject query); @Override void execute();  }
@Test public void testSearchInvalidCriteria() throws InvalidArgumentException, ReadValueException, TaskPrepareException, TaskSetConnectionException, TaskExecutionException, ChangeValueException, StorageException, SQLException { IAction<IObject[]> callback = mock(IAction.class); when(message.getCallback()).thenReturn(callback); when(message.getCriteria()).thenReturn(new DSObject("{ \"filter\": 123 }")); try { task.prepare(null); fail(); } catch (TaskPrepareException e) { } verifyZeroInteractions(connection); verifyZeroInteractions(sqlStatement); }