@Override protected Filter[] getFilters(final FilterType type) { switch (type) { case INCLUDE: return this.annotation.includeFilters(); case EXCLUDE: return this.annotation.excludeFilters(); default: throw new IllegalStateException("Unsupported type " + type); } }
@Override protected Filter[] getFilters(FilterType type) { switch (type) { case INCLUDE: return this.annotation.includeFilters(); case EXCLUDE: return this.annotation.excludeFilters(); } throw new IllegalStateException("Unsupported type " + type); }
private List<TypeFilter> createTypeFilters(Filter[] filters) { List<TypeFilter> typeFilters = new ArrayList<TypeFilter>(); for (Filter filter : filters) { for (Class<?> filterClass : filter.classes()) { typeFilters.add(createTypeFilter(filter.type(), filterClass)); } for (String pattern : filter.pattern()) { typeFilters.add(createTypeFilter(filter.type(), pattern)); } } return Collections.unmodifiableList(typeFilters); }
@Before public void setUp() { ComponentContext.initComponentsLifeCycle(); IAMGroupVO group = new IAMGroupVO("group1", "my first group"); Mockito.when(_aclGroupDao.persist(Mockito.any(IAMGroupVO.class))).thenReturn(group); List<IAMGroupVO> groups = new ArrayList<IAMGroupVO>(); groups.add(group); when(_aclGroupDao.search(Mockito.any(SearchCriteria.class), Mockito.any(com.cloud.utils.db.Filter.class))) .thenReturn(groups); IAMPolicyVO policy = new IAMPolicyVO("policy1", "my first policy"); Mockito.when(_aclPolicyDao.persist(Mockito.any(IAMPolicyVO.class))).thenReturn(policy); }
public FilterAnnotations(ClassLoader classLoader, Filter[] filters) { Assert.notNull(filters, "Filters must not be null"); this.classLoader = classLoader; this.filters = createTypeFilters(filters); }
protected abstract Filter[] getFilters(FilterType type);