GetItemFromCachedCollectionTask implements IDatabaseTask { @Override public void prepare(final IObject query) throws TaskPrepareException { try { IObject queryForNestedTask = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject")); IObject filterObject = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject")); keyField = IOC.resolve(Keys.getOrAdd(IField.class.getCanonicalName()), (String) keyNameField.in(query)); String keyValue = keyValueField.in(query); IObject eqKeyObject = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject")); equalsField.out(eqKeyObject, keyValue); keyField.out(filterObject, eqKeyObject); IObject isActiveObject = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject")); equalsField.out(isActiveObject, true); isActiveField.out(filterObject, isActiveObject); IObject dateObject = IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject")); dateToField.out(dateObject, LocalDateTime.now().format(formatter)); startDateTimeField.out(filterObject, dateObject); filterField.out(queryForNestedTask, filterObject); getItemTask = IOC.resolve( Keys.getOrAdd("db.collection.search"), connection, collectionNameField.in(query), queryForNestedTask, callbackField.in(query) ); } catch (ResolutionException e) { throw new TaskPrepareException("Can't create searchQuery from input query", e); } catch (InvalidArgumentException | ChangeValueException | ReadValueException e) { throw new TaskPrepareException("Can't change value in one of IObjects", e); } } GetItemFromCachedCollectionTask(final IStorageConnection connection); @Override void prepare(final IObject query); @Override void execute();  }
@Test @Ignore public void MustCorrectPrepareQueryForSelecting() throws Exception { IObject query = spy(new DSObject("{" + "\"keyName\": \"name\"," + " \"key\": \"keyValue\"," + " \"collectionName\": \"collection\"" + "}" )); testTask.prepare(query); FieldName keyNameFN = new FieldName("keyName"); FieldName keyValueFN = new FieldName("key"); FieldName collectionNameFN = new FieldName("collectionName"); verify(query).getValue(eq(keyNameFN)); verify(query).getValue(eq(keyValueFN)); verify(query).getValue(eq(collectionNameFN)); }
@Test(expected = TaskPrepareException.class) @Ignore public void MustInCorrectPrepareQueryForSelectingWhenIOCThrowException() throws ResolutionException, TaskPrepareException, ReadValueException, ChangeValueException { testTask.prepare(null); }