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 customInterceptor
implementation is useful for mocking.A new instance is usually created through a
MockInterceptor.Builder
(see alsowithBindings(Annotation...)
method) and then passed to theWeldInitiator.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 Classes Modifier and Type Class Description static class
MockInterceptor.Builder
static interface
MockInterceptor.InterceptionCallback
static class
MockInterceptor.MockInterceptorInstance
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MockInterceptor.MockInterceptorInstance
create(jakarta.enterprise.context.spi.CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext)
void
destroy(MockInterceptor.MockInterceptorInstance instance, jakarta.enterprise.context.spi.CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext)
Class<?>
getBeanClass()
Set<jakarta.enterprise.inject.spi.InjectionPoint>
getInjectionPoints()
Set<Annotation>
getInterceptorBindings()
String
getName()
Set<Annotation>
getQualifiers()
Class<? extends Annotation>
getScope()
Set<Class<? extends Annotation>>
getStereotypes()
Set<Type>
getTypes()
Object
intercept(jakarta.enterprise.inject.spi.InterceptionType type, MockInterceptor.MockInterceptorInstance instance, jakarta.interceptor.InvocationContext ctx)
boolean
intercepts(jakarta.enterprise.inject.spi.InterceptionType type)
boolean
isAlternative()
boolean
isNullable()
static MockInterceptor.Builder
withBindings(Annotation... interceptorBindings)
-
-
-
Method Detail
-
withBindings
public static MockInterceptor.Builder withBindings(Annotation... interceptorBindings)
- Parameters:
interceptorBindings
-- Returns:
- a new builder instance with the specified interceptor bindings
-
getInterceptorBindings
public Set<Annotation> getInterceptorBindings()
- Specified by:
getInterceptorBindings
in interfacejakarta.enterprise.inject.spi.Interceptor<MockInterceptor.MockInterceptorInstance>
-
intercepts
public boolean intercepts(jakarta.enterprise.inject.spi.InterceptionType type)
- Specified by:
intercepts
in 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:
intercept
in interfacejakarta.enterprise.inject.spi.Interceptor<MockInterceptor.MockInterceptorInstance>
- Throws:
Exception
-
create
public MockInterceptor.MockInterceptorInstance create(jakarta.enterprise.context.spi.CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext)
- Specified by:
create
in interfacejakarta.enterprise.context.spi.Contextual<MockInterceptor.MockInterceptorInstance>
-
destroy
public void destroy(MockInterceptor.MockInterceptorInstance instance, jakarta.enterprise.context.spi.CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext)
- Specified by:
destroy
in interfacejakarta.enterprise.context.spi.Contextual<MockInterceptor.MockInterceptorInstance>
-
getBeanClass
public Class<?> getBeanClass()
- Specified by:
getBeanClass
in interfacejakarta.enterprise.inject.spi.Bean<MockInterceptor.MockInterceptorInstance>
-
getInjectionPoints
public Set<jakarta.enterprise.inject.spi.InjectionPoint> getInjectionPoints()
- Specified by:
getInjectionPoints
in interfacejakarta.enterprise.inject.spi.Bean<MockInterceptor.MockInterceptorInstance>
-
isNullable
public boolean isNullable()
- Specified by:
isNullable
in interfacejakarta.enterprise.inject.spi.Bean<MockInterceptor.MockInterceptorInstance>
-
getTypes
public Set<Type> getTypes()
- Specified by:
getTypes
in interfacejakarta.enterprise.inject.spi.BeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getQualifiers
public Set<Annotation> getQualifiers()
- Specified by:
getQualifiers
in interfacejakarta.enterprise.inject.spi.BeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getScope
public Class<? extends Annotation> getScope()
- Specified by:
getScope
in interfacejakarta.enterprise.inject.spi.BeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getName
public String getName()
- Specified by:
getName
in interfacejakarta.enterprise.inject.spi.BeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getStereotypes
public Set<Class<? extends Annotation>> getStereotypes()
- Specified by:
getStereotypes
in interfacejakarta.enterprise.inject.spi.BeanAttributes<MockInterceptor.MockInterceptorInstance>
-
isAlternative
public boolean isAlternative()
- Specified by:
isAlternative
in interfacejakarta.enterprise.inject.spi.BeanAttributes<MockInterceptor.MockInterceptorInstance>
-
-