org.eclipse.microprofile.fault.tolerance.tck.disableEnv

## Class DisableAnnotationClient

- java.lang.Object
- - org.eclipse.microprofile.fault.tolerance.tck.disableEnv.DisableAnnotationClient

    @ApplicationScoped
    public class DisableAnnotationClient
    extends Object

A client to determine the impact of disabling annotations via config

Each method has an easy test to determine whether it's annotations are active or not.

Author:
  Andrew Rouse

### Constructor Summary

Constructors
Constructor and Description
`DisableAnnotationClient()`

### Method Summary

All Methods Instance Methods Concrete Methods
`Future<String>` `asyncWaitThenReturn()` Returns a future which will be complete on method return if Asynchronous is disabled, or incomplete if Asynchronous is enabled.
`void` `failAndRetryOnce()` Always throws `TestException`, should increment counter by two if Retry is enabled, or one if it is not
`String` `failRetryOnceThenFallback()` Should return normally if Fallback is enabled or throw TestException if not
`void` `failWithCircuitBreaker()` Always throws TestException on first invocation, throws `CircuitBreakerOpenException` on second if CircuitBreaker is enabled
`void` `failWithTimeout()` Throws `TimeoutException` if Timeout is enabled or TestException otherwise
`String` `fallback()`
`int` `getFailAndRetryOnceCounter()` Returns the number of times that `failAndRetryOnce()` has been executed
`int` `getFailRetryOnceThenFallbackCounter()` Returns the number of times that `failRetryOnceThenFallback()` has been executed
`void` `waitForBulkheadExecutions(int count)` Wait for `count` executions of `waitWithBulkhead(Future)` to be in progress.
`void` `waitWithBulkhead(Future<?> waitingFuture)` Blocks waiting for `waitingFuture` to complete

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

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

### Constructor Detail

#### DisableAnnotationClient

    public DisableAnnotationClient()

### Method Detail

#### failAndRetryOnce

    @Retry(maxRetries=1)
    public void failAndRetryOnce()

Always throws `TestException`, should increment counter by two if Retry is enabled, or one if it is not

#### getFailAndRetryOnceCounter

    public int getFailAndRetryOnceCounter()

Returns the number of times that `failAndRetryOnce()` has been executed

Returns:
  failAndRetryOnceCounter

#### failRetryOnceThenFallback

    @Retry(maxRetries=1)
     @Fallback(fallbackMethod="fallback")
    public String failRetryOnceThenFallback()

Should return normally if Fallback is enabled or throw TestException if not

Should increment counter by two if Retry is enabled or one if it is not

Returns:
  nothing, always throws TestException

#### getFailRetryOnceThenFallbackCounter

    public int getFailRetryOnceThenFallbackCounter()

Returns the number of times that `failRetryOnceThenFallback()` has been executed

Returns:
  failRetryOnceThenFallbackCounter

#### fallback

    public String fallback()

#### failWithCircuitBreaker

    @CircuitBreaker(successThreshold=2,
                    requestVolumeThreshold=1,
                    failureRatio=1.0,
                    delay=50000L)
    public void failWithCircuitBreaker()

Always throws TestException on first invocation, throws `CircuitBreakerOpenException` on second if CircuitBreaker is enabled

Throw test exception on second invocation if CircuitBreaker is disabled

#### failWithTimeout

    @Timeout(value=500L)
    public void failWithTimeout()

Throws `TimeoutException` if Timeout is enabled or TestException otherwise

#### waitWithBulkhead

    @Bulkhead(value=2)
    public void waitWithBulkhead(Future<?> waitingFuture)

Blocks waiting for `waitingFuture` to complete

If passed an already completed `Future`, this method will return immediately.

Should permit two simultaneous calls if bulkhead enabled, or more if bulkhead disabled.

Parameters:
  `waitingFuture` - the future to wait for

#### waitForBulkheadExecutions

    public void waitForBulkheadExecutions(int count)

Wait for `count` executions of `waitWithBulkhead(Future)` to be in progress.

Parameters:
  `count` - execution count

#### asyncWaitThenReturn

    @Asynchronous
    public Future<String> asyncWaitThenReturn()

Returns a future which will be complete on method return if Asynchronous is disabled, or incomplete if Asynchronous is enabled.

Returns:
  Completed future