Package org.jboss.weld.junit
Class MockInterceptor
java.lang.Object
org.jboss.weld.junit.MockInterceptor
- All Implemented Interfaces:
jakarta.enterprise.context.spi.Contextual<MockInterceptor.MockInterceptorInstance>,jakarta.enterprise.inject.spi.Bean<MockInterceptor.MockInterceptorInstance>,jakarta.enterprise.inject.spi.BeanAttributes<MockInterceptor.MockInterceptorInstance>,jakarta.enterprise.inject.spi.Interceptor<MockInterceptor.MockInterceptorInstance>
public class MockInterceptor
extends Object
implements jakarta.enterprise.inject.spi.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(jakarta.enterprise.context.spi.CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext) voiddestroy(MockInterceptor.MockInterceptorInstance instance, jakarta.enterprise.context.spi.CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext) Class<?>Set<jakarta.enterprise.inject.spi.InjectionPoint>getName()Class<? extends Annotation>getScope()Set<Class<? extends Annotation>>getTypes()intercept(jakarta.enterprise.inject.spi.InterceptionType type, MockInterceptor.MockInterceptorInstance instance, jakarta.interceptor.InvocationContext ctx) booleanintercepts(jakarta.enterprise.inject.spi.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 interfacejakarta.enterprise.inject.spi.Interceptor<MockInterceptor.MockInterceptorInstance>
-
intercepts
public boolean intercepts(jakarta.enterprise.inject.spi.InterceptionType type) - Specified by:
interceptsin interfacejakarta.enterprise.inject.spi.Interceptor<MockInterceptor.MockInterceptorInstance>
-
intercept
public Object intercept(jakarta.enterprise.inject.spi.InterceptionType type, MockInterceptor.MockInterceptorInstance instance, jakarta.interceptor.InvocationContext ctx) throws Exception - Specified by:
interceptin interfacejakarta.enterprise.inject.spi.Interceptor<MockInterceptor.MockInterceptorInstance>- Throws:
Exception
-
create
public MockInterceptor.MockInterceptorInstance create(jakarta.enterprise.context.spi.CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext) - Specified by:
createin interfacejakarta.enterprise.context.spi.Contextual<MockInterceptor.MockInterceptorInstance>
-
destroy
public void destroy(MockInterceptor.MockInterceptorInstance instance, jakarta.enterprise.context.spi.CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext) - Specified by:
destroyin interfacejakarta.enterprise.context.spi.Contextual<MockInterceptor.MockInterceptorInstance>
-
getBeanClass
- Specified by:
getBeanClassin interfacejakarta.enterprise.inject.spi.Bean<MockInterceptor.MockInterceptorInstance>
-
getInjectionPoints
- Specified by:
getInjectionPointsin interfacejakarta.enterprise.inject.spi.Bean<MockInterceptor.MockInterceptorInstance>
-
getTypes
- Specified by:
getTypesin interfacejakarta.enterprise.inject.spi.BeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getQualifiers
- Specified by:
getQualifiersin interfacejakarta.enterprise.inject.spi.BeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getScope
- Specified by:
getScopein interfacejakarta.enterprise.inject.spi.BeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getName
- Specified by:
getNamein interfacejakarta.enterprise.inject.spi.BeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getStereotypes
- Specified by:
getStereotypesin interfacejakarta.enterprise.inject.spi.BeanAttributes<MockInterceptor.MockInterceptorInstance>
-
isAlternative
public boolean isAlternative()- Specified by:
isAlternativein interfacejakarta.enterprise.inject.spi.BeanAttributes<MockInterceptor.MockInterceptorInstance>
-