Package org.jboss.weld.junit
Class MockInterceptor
java.lang.Object
org.jboss.weld.junit.MockInterceptor
- All Implemented Interfaces:
Contextual<MockInterceptor.MockInterceptorInstance>
,Bean<MockInterceptor.MockInterceptorInstance>
,BeanAttributes<MockInterceptor.MockInterceptorInstance>
,Interceptor<MockInterceptor.MockInterceptorInstance>
public class MockInterceptor
extends Object
implements Interceptor<MockInterceptor.MockInterceptorInstance>
This custom
Interceptor
implementation is useful for mocking.
A new instance is usually created through a MockInterceptor.Builder
(see also withBindings(Annotation...)
method) and then
passed to the
WeldInitiator.Builder#addBeans(Bean...)
method.
Note that by default all mock interceptors are automatically enabled for the synthetic bean archive. If needed a custom bean
class can be set through the
MockInterceptor.Builder.beanClass(Class)
method - the bean class can be used to enable the interceptor for a bean archive. It's not
possible to enable a mock
interceptor globally (per application).
- Since:
- 1.2.1
- Author:
- Martin Kouba See also {code WeldInitiator.Builder#addBean(Bean)} method.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static interface
static class
-
Method Summary
Modifier and TypeMethodDescriptioncreate
(CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext) void
destroy
(MockInterceptor.MockInterceptorInstance instance, CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext) Class<?>
getName()
Class<? extends Annotation>
getScope()
Set<Class<? extends Annotation>>
getTypes()
intercept
(InterceptionType type, MockInterceptor.MockInterceptorInstance instance, jakarta.interceptor.InvocationContext ctx) boolean
intercepts
(InterceptionType type) boolean
static MockInterceptor.Builder
withBindings
(Annotation... interceptorBindings)
-
Method Details
-
withBindings
- Parameters:
interceptorBindings
-- Returns:
- a new builder instance with the specified interceptor bindings
-
getInterceptorBindings
- Specified by:
getInterceptorBindings
in interfaceInterceptor<MockInterceptor.MockInterceptorInstance>
-
intercepts
- Specified by:
intercepts
in interfaceInterceptor<MockInterceptor.MockInterceptorInstance>
-
intercept
public Object intercept(InterceptionType type, MockInterceptor.MockInterceptorInstance instance, jakarta.interceptor.InvocationContext ctx) throws Exception - Specified by:
intercept
in interfaceInterceptor<MockInterceptor.MockInterceptorInstance>
- Throws:
Exception
-
create
public MockInterceptor.MockInterceptorInstance create(CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext) - Specified by:
create
in interfaceContextual<MockInterceptor.MockInterceptorInstance>
-
destroy
public void destroy(MockInterceptor.MockInterceptorInstance instance, CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext) - Specified by:
destroy
in interfaceContextual<MockInterceptor.MockInterceptorInstance>
-
getBeanClass
- Specified by:
getBeanClass
in interfaceBean<MockInterceptor.MockInterceptorInstance>
-
getInjectionPoints
- Specified by:
getInjectionPoints
in interfaceBean<MockInterceptor.MockInterceptorInstance>
-
getTypes
- Specified by:
getTypes
in interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getQualifiers
- Specified by:
getQualifiers
in interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getScope
- Specified by:
getScope
in interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getName
- Specified by:
getName
in interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getStereotypes
- Specified by:
getStereotypes
in interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
isAlternative
public boolean isAlternative()- Specified by:
isAlternative
in interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-