嗨,我定义了以下限定符类型..
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.FIELD })
public @interface SortAndFilterType {
/**
* The value for the sort and filter.
*
* @return the sort and filter type value.
*/
String value();
}
以及其中的两个实现。
@SortAndFilterType("Users")
public class UserSortAndFilterProviderImpl implements SortAndFilterProvider<Field, User> {}
@SortAndFilterType("ReportsList")
public class ReportListSortAndFilterProviderImpl implements SortAndFilterProvider<Field, ReportList> {}
我从客户端注入..
@Inject
@SortAndFilterType("Users")
private SortAndFilterProvider mSortAndFilterProvider;
每件事在运行时都可以正常工作..
但是当我运行单元测试时问题就来了..
我收到以下异常..
org.jboss.weld.exceptions.DeploymentException: WELD-001408: 在注入点 [BackedAnnotatedField] @Inject @SortAndFilterType private com.collabnet.ctf.saturn.client.apps.users.ChangeUsersStatus 带有限定符的 SortAndFilterProvider 类型的依赖关系不满足。 mSortAndFilterProvider
我从这样的单元测试中调用它..它使用@RunWith(CdiRunner.class) 运行
@Produces
@SortAndFilterType("Users")
@Mock
private SortAndFilterProvider mSortAndFilterProvider;
这里出了什么问题?