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
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfacestatic class -
Method Summary
Modifier and TypeMethodDescriptioncreate(CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext) voiddestroy(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) booleanintercepts(InterceptionType type) booleanstatic MockInterceptor.BuilderwithBindings(Annotation... interceptorBindings)
-
Method Details
-
withBindings
- Parameters:
interceptorBindings-- Returns:
- a new builder instance with the specified interceptor bindings
-
getInterceptorBindings
- Specified by:
getInterceptorBindingsin interfaceInterceptor<MockInterceptor.MockInterceptorInstance>
-
intercepts
- Specified by:
interceptsin interfaceInterceptor<MockInterceptor.MockInterceptorInstance>
-
intercept
public Object intercept(InterceptionType type, MockInterceptor.MockInterceptorInstance instance, jakarta.interceptor.InvocationContext ctx) throws Exception - Specified by:
interceptin interfaceInterceptor<MockInterceptor.MockInterceptorInstance>- Throws:
Exception
-
create
public MockInterceptor.MockInterceptorInstance create(CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext) - Specified by:
createin interfaceContextual<MockInterceptor.MockInterceptorInstance>
-
destroy
public void destroy(MockInterceptor.MockInterceptorInstance instance, CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext) - Specified by:
destroyin interfaceContextual<MockInterceptor.MockInterceptorInstance>
-
getBeanClass
- Specified by:
getBeanClassin interfaceBean<MockInterceptor.MockInterceptorInstance>
-
getInjectionPoints
- Specified by:
getInjectionPointsin interfaceBean<MockInterceptor.MockInterceptorInstance>
-
getTypes
- Specified by:
getTypesin interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getQualifiers
- Specified by:
getQualifiersin interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getScope
- Specified by:
getScopein interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getName
- Specified by:
getNamein interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getStereotypes
- Specified by:
getStereotypesin interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
isAlternative
public boolean isAlternative()- Specified by:
isAlternativein interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-