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 customInterceptorimplementation 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 classMockInterceptor.Builderstatic interfaceMockInterceptor.InterceptionCallbackstatic classMockInterceptor.MockInterceptorInstance
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MockInterceptor.MockInterceptorInstancecreate(CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext)voiddestroy(MockInterceptor.MockInterceptorInstance instance, CreationalContext<MockInterceptor.MockInterceptorInstance> creationalContext)Class<?>getBeanClass()Set<InjectionPoint>getInjectionPoints()Set<Annotation>getInterceptorBindings()StringgetName()Set<Annotation>getQualifiers()Class<? extends Annotation>getScope()Set<Class<? extends Annotation>>getStereotypes()Set<Type>getTypes()Objectintercept(InterceptionType type, MockInterceptor.MockInterceptorInstance instance, jakarta.interceptor.InvocationContext ctx)booleanintercepts(InterceptionType type)booleanisAlternative()static MockInterceptor.BuilderwithBindings(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:
getInterceptorBindingsin interfaceInterceptor<MockInterceptor.MockInterceptorInstance>
-
intercepts
public boolean intercepts(InterceptionType type)
- 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
public Class<?> getBeanClass()
- Specified by:
getBeanClassin interfaceBean<MockInterceptor.MockInterceptorInstance>
-
getInjectionPoints
public Set<InjectionPoint> getInjectionPoints()
- Specified by:
getInjectionPointsin interfaceBean<MockInterceptor.MockInterceptorInstance>
-
getTypes
public Set<Type> getTypes()
- Specified by:
getTypesin interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getQualifiers
public Set<Annotation> getQualifiers()
- Specified by:
getQualifiersin interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getScope
public Class<? extends Annotation> getScope()
- Specified by:
getScopein interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getName
public String getName()
- Specified by:
getNamein interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
getStereotypes
public Set<Class<? extends Annotation>> getStereotypes()
- Specified by:
getStereotypesin interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
isAlternative
public boolean isAlternative()
- Specified by:
isAlternativein interfaceBeanAttributes<MockInterceptor.MockInterceptorInstance>
-
-