AsyncOperationCollection implements IAsyncOperationCollection { @Override public void complete(final IObject document) throws CompleteAsyncOperationException { try (IPoolGuard poolGuard = new PoolGuard(connectionPool)) { ITask updateTask = IOC.resolve(Keys.getOrAdd("db.async_ops_collection.complete"), poolGuard.getObject(), collectionName, document ); updateTask.execute(); } catch (TaskExecutionException e) { throw new CompleteAsyncOperationException("Error during execution complete.", e); } catch (PoolGuardException e) { throw new CompleteAsyncOperationException("Can't get connection from pool.", e); } catch (ResolutionException e) { throw new CompleteAsyncOperationException("Can't resolve async operation object.", e); } } AsyncOperationCollection(final IPool connectionPool, final String collectionName); @Override IObject getAsyncOperation(final String token); @Override void createAsyncOperation(final IObject data, final String token, final String expiredTime); @Override void delete(final String token); @Override void complete(final IObject document);  }
@Test(expected = CompleteAsyncOperationException.class) public void ShouldThrowUpsertItemException_When_NestedErrorIsOccurred() throws Exception { IObject query = mock(IObject.class); when(IOC.resolve(any(), any(), any(), any())).thenThrow(new ResolutionException("")); collection.complete(query); }