/* * Copyright 2014 - 2017 Blazebit. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.blazebit.persistence.view.impl.spring; import com.blazebit.persistence.view.impl.spring.views.SomeSuperInterface; import com.blazebit.persistence.view.impl.spring.views.sub1.TestView1; import com.blazebit.persistence.view.spi.EntityViewConfiguration; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.inject.Inject; import java.util.Set; /** * @author Moritz Becker (moritz.becker@gmx.at) * @since 1.2 */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = AnnotationIncludeAssignableFilterTest.TestConfig.class) public class AnnotationIncludeAssignableFilterTest { @Inject private EntityViewConfiguration entityViewConfiguration; @Test public void testInjection() { Set<Class<?>> entityViews = entityViewConfiguration.getEntityViews(); Assert.assertEquals(1, entityViews.size()); Assert.assertTrue(entityViewConfiguration.getEntityViews().contains(TestView1.class)); } @Configuration @EnableEntityViews(includeFilters = { @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = SomeSuperInterface.class) }) static class TestConfig { } }