org.eclipse.microprofile.fault.tolerance.tck.util

## Class AsyncTaskManager.BarrierTask<T>

- java.lang.Object
- - org.eclipse.microprofile.fault.tolerance.tck.util.AsyncTaskManager.BarrierTask<T>

Type Parameters:
  `T` - the return type of the task

Enclosing class:
  AsyncTaskManager

    public static class AsyncTaskManager.BarrierTask<T>
    extends Object

A task which runs using a barrier

Use this interface to check that the task waits on the barrier and completes as expected

### Constructor Summary

Constructors
Constructor and Description
`BarrierTask(Future<? extends T> result, Barrier barrier)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `assertAwaits()` Assert that the task waits on its barrier within WAIT_TIME_MS
`void` `assertCompletes()` Assert that the task completes within WAIT_TIME_MS
`void` `assertNotAwaiting()` Assert that the task does not wait on its barrier
`void` `assertNotCompleting()` Assert that the task does not complete within EXPECTED_FAIL_TIME_MS
`void` `assertResult(org.hamcrest.Matcher<? super T> matcher)` Assert that the task completes without exception within WAIT_TIME_MS and that the value returned is matched by the provided matcher
`void` `assertSuccess()` Assert that the task completes without exception within WAIT_TIME_MS
`void` `assertThrows(Class<? extends Throwable> exceptionClass)` Assert that the task completes, throwing an exception of the specified class within WAIT_TIME_MS
`T` `getResult()` Get the result of the task
`T` `getResult(long time, TimeUnit unit)` Get the result of the task
`boolean` `isAwaiting()` Whether this task is awaiting its barrier right now
`void` `openBarrier()` Open the barrier used by the task

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### BarrierTask

    public BarrierTask(Future<? extends T> result,
                       Barrier barrier)

### Method Detail

#### openBarrier

    public void openBarrier()

Open the barrier used by the task

#### assertAwaits

    public void assertAwaits()

Assert that the task waits on its barrier within WAIT_TIME_MS

#### assertNotAwaiting

    public void assertNotAwaiting()

Assert that the task does not wait on its barrier

This method always takes EXPECTED_FAIL_TIME_MS ms.

If you need to check multiple tasks, use `AsyncTaskManager.assertAllNotAwaiting(Collection)` instead.

#### assertCompletes

    public void assertCompletes()

Assert that the task completes within WAIT_TIME_MS

#### assertNotCompleting

    public void assertNotCompleting()

Assert that the task does not complete within EXPECTED_FAIL_TIME_MS

#### assertSuccess

    public void assertSuccess()

Assert that the task completes without exception within WAIT_TIME_MS

#### assertThrows

    public void assertThrows(Class<? extends Throwable> exceptionClass)

Assert that the task completes, throwing an exception of the specified class within WAIT_TIME_MS

Parameters:
  `exceptionClass` - the class of the expected exception

#### assertResult

    public void assertResult(org.hamcrest.Matcher<? super T> matcher)

Assert that the task completes without exception within WAIT_TIME_MS and that the value returned is matched by the provided matcher

Parameters:
  `matcher` - the `Matcher` used to assert the returned value

#### getResult

    public T getResult()
                throws ExecutionException

Get the result of the task

Asserts that the task completes within WAIT_TIME_MS.

Returns:
  the task result
Throws:
  `ExecutionException` - if the task threw an exception instead of returning

#### getResult

    public T getResult(long time,
                       TimeUnit unit)
                throws ExecutionException

Get the result of the task

Asserts that the task completes within the given time

Parameters:
  `time` - the time to wait for the task to complete
  `unit` - the unit for `time`
Returns:
  the task result
Throws:
  `ExecutionException` - if the task threw an exception instead of returning

#### isAwaiting

    public boolean isAwaiting()

Whether this task is awaiting its barrier right now

This method returns immediately.

Returns:
  `true` if this task is currently waiting on its barrier, otherwise `false`