001/*
002 * Copyright 2012-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.test.autoconfigure.data.neo4j;
018
019import java.lang.annotation.Documented;
020import java.lang.annotation.ElementType;
021import java.lang.annotation.Inherited;
022import java.lang.annotation.Retention;
023import java.lang.annotation.RetentionPolicy;
024import java.lang.annotation.Target;
025
026import org.junit.jupiter.api.extension.ExtendWith;
027
028import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
029import org.springframework.boot.autoconfigure.SpringBootApplication;
030import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration;
031import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache;
032import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters;
033import org.springframework.context.annotation.ComponentScan.Filter;
034import org.springframework.core.annotation.AliasFor;
035import org.springframework.core.env.Environment;
036import org.springframework.test.context.BootstrapWith;
037import org.springframework.test.context.junit.jupiter.SpringExtension;
038import org.springframework.transaction.annotation.Transactional;
039
040/**
041 * Annotation that can be used in combination with {@code @RunWith(SpringRunner.class)}
042 * for a typical Neo4j test. Can be used when a test focuses <strong>only</strong> on
043 * Neo4j components.
044 * <p>
045 * Using this annotation will disable full auto-configuration and instead apply only
046 * configuration relevant to Neo4j tests.
047 * <p>
048 * By default, tests annotated with {@code @DataNeo4jTest} will use an embedded in-memory
049 * Neo4j process (if available). They will also be transactional with the usual
050 * test-related semantics (i.e. rollback by default).
051 *
052 * @author EddĂș MelĂ©ndez
053 * @author Stephane Nicoll
054 * @author Artsiom Yudovin
055 * @since 2.0.0
056 */
057@Target(ElementType.TYPE)
058@Retention(RetentionPolicy.RUNTIME)
059@Documented
060@Inherited
061@BootstrapWith(DataNeo4jTestContextBootstrapper.class)
062@ExtendWith(SpringExtension.class)
063@OverrideAutoConfiguration(enabled = false)
064@TypeExcludeFilters(DataNeo4jTypeExcludeFilter.class)
065@Transactional
066@AutoConfigureCache
067@AutoConfigureDataNeo4j
068@ImportAutoConfiguration
069public @interface DataNeo4jTest {
070
071        /**
072         * Properties in form {@literal key=value} that should be added to the Spring
073         * {@link Environment} before the test runs.
074         * @return the properties to add
075         * @since 2.1.0
076         */
077        String[] properties() default {};
078
079        /**
080         * Determines if default filtering should be used with
081         * {@link SpringBootApplication @SpringBootApplication}. By default no beans are
082         * included.
083         * @see #includeFilters()
084         * @see #excludeFilters()
085         * @return if default filters should be used
086         */
087        boolean useDefaultFilters() default true;
088
089        /**
090         * A set of include filters which can be used to add otherwise filtered beans to the
091         * application context.
092         * @return include filters to apply
093         */
094        Filter[] includeFilters() default {};
095
096        /**
097         * A set of exclude filters which can be used to filter beans that would otherwise be
098         * added to the application context.
099         * @return exclude filters to apply
100         */
101        Filter[] excludeFilters() default {};
102
103        /**
104         * Auto-configuration exclusions that should be applied for this test.
105         * @return auto-configuration exclusions to apply
106         */
107        @AliasFor(annotation = ImportAutoConfiguration.class, attribute = "exclude")
108        Class<?>[] excludeAutoConfiguration() default {};
109
110}