Class FakeResilient<T>
java.lang.Object
io.github.teceli.resiliencia.test.FakeResilient<T>
- All Implemented Interfaces:
Resilient<T>
A pass-through
Resilient for testing code that composes or accepts patterns
(e.g. Policy chains) without pulling in real pattern behavior. Executes the operation
directly, counts invocations, and can impersonate any PatternKind / pattern name.
Configured via withX copy methods like the real patterns; each returns a new
instance with a fresh call count.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.teceli.resiliencia.core.api.Resilient
Resilient.Operation<T> -
Method Summary
Modifier and TypeMethodDescriptioncall(Resilient.Operation<T> operation) Execute an operation with resilience guarantees.intHow many timescall(io.github.teceli.resiliencia.core.api.Resilient.Operation<T>)oroutcome(io.github.teceli.resiliencia.core.api.Resilient.Operation<T>)has executed on this instance.outcome(Resilient.Operation<T> operation) Execute an operation and capture the result or failure as an Outcome.static <T> FakeResilient<T> A fake that simply executes the operation, reporting itself as a CUSTOM pattern.The kind of this pattern, used for internal comparisons (e.g.The name of this pattern, e.g.withOnCall(Runnable onCall) Run the given hook each time this fake executes, before the operation — useful for recording execution order across a chain of fakes.withPatternKind(PatternKind patternKind) withPatternName(String patternName) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.teceli.resiliencia.core.api.Resilient
callAsync, hasOwnDeadline
-
Method Details
-
passthrough
A fake that simply executes the operation, reporting itself as a CUSTOM pattern. -
withPatternName
-
withPatternKind
-
withOnCall
Run the given hook each time this fake executes, before the operation — useful for recording execution order across a chain of fakes. -
callCount
public int callCount()How many timescall(io.github.teceli.resiliencia.core.api.Resilient.Operation<T>)oroutcome(io.github.teceli.resiliencia.core.api.Resilient.Operation<T>)has executed on this instance. -
patternName
Description copied from interface:ResilientThe name of this pattern, e.g. "retry", "timeout", "circuit-breaker". Used for identification (e.g. by Policy) without coupling to concrete pattern types. Defaults to "custom" for user-defined Resilient implementations.- Specified by:
patternNamein interfaceResilient<T>
-
patternKind
Description copied from interface:ResilientThe kind of this pattern, used for internal comparisons (e.g. Policy order validation). UnlikeResilient.patternName(), which is a free-form observability label, this is a closed enum the library can reason about exhaustively. Defaults toPatternKind.CUSTOMfor user-defined Resilient implementations.- Specified by:
patternKindin interfaceResilient<T>
-
call
Description copied from interface:ResilientExecute an operation with resilience guarantees. May throw ResilienciaException or a specific pattern exception.- Specified by:
callin interfaceResilient<T>- Throws:
ResilientException
-
outcome
Description copied from interface:ResilientExecute an operation and capture the result or failure as an Outcome. Never throws for a recordedException— always returns Success, Failure, or a pattern-specific outcome. AnErrorthrown by the operation propagates uncaught instead of being captured as a Failure: fatal JVM conditions (e.g.OutOfMemoryError) should not be treated as a recoverable result.
-