diff --git a/src/test/java/com/behl/cachetropolis/InitializeMysqlContainer.java b/src/test/java/com/behl/cachetropolis/InitializeMysqlContainer.java new file mode 100644 index 0000000..b639414 --- /dev/null +++ b/src/test/java/com/behl/cachetropolis/InitializeMysqlContainer.java @@ -0,0 +1,14 @@ +package com.behl.cachetropolis; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.junit.jupiter.api.extension.ExtendWith; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@ExtendWith(MySQLDataSourceInitializer.class) +public @interface InitializeMysqlContainer { +} \ No newline at end of file diff --git a/src/test/java/com/behl/cachetropolis/InitializeRedisContainer.java b/src/test/java/com/behl/cachetropolis/InitializeRedisContainer.java new file mode 100644 index 0000000..b8f57dc --- /dev/null +++ b/src/test/java/com/behl/cachetropolis/InitializeRedisContainer.java @@ -0,0 +1,14 @@ +package com.behl.cachetropolis; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.junit.jupiter.api.extension.ExtendWith; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@ExtendWith(RedisCacheInitializer.class) +public @interface InitializeRedisContainer { +} \ No newline at end of file diff --git a/src/test/java/com/behl/cachetropolis/repository/MasterHouseRepositoryTest.java b/src/test/java/com/behl/cachetropolis/repository/MasterHouseRepositoryTest.java index 5480a07..352d149 100644 --- a/src/test/java/com/behl/cachetropolis/repository/MasterHouseRepositoryTest.java +++ b/src/test/java/com/behl/cachetropolis/repository/MasterHouseRepositoryTest.java @@ -8,17 +8,16 @@ import java.util.UUID; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import com.behl.cachetropolis.MySQLDataSourceInitializer; +import com.behl.cachetropolis.InitializeMysqlContainer; import com.behl.cachetropolis.entity.MasterHouse; import junit.framework.AssertionFailedError; @DataJpaTest -@ExtendWith(MySQLDataSourceInitializer.class) +@InitializeMysqlContainer class MasterHouseRepositoryTest { @Autowired diff --git a/src/test/java/com/behl/cachetropolis/repository/WizardRepositoryTest.java b/src/test/java/com/behl/cachetropolis/repository/WizardRepositoryTest.java index 6f8587e..b0e8cd7 100644 --- a/src/test/java/com/behl/cachetropolis/repository/WizardRepositoryTest.java +++ b/src/test/java/com/behl/cachetropolis/repository/WizardRepositoryTest.java @@ -6,18 +6,17 @@ import java.util.UUID; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import com.behl.cachetropolis.MySQLDataSourceInitializer; +import com.behl.cachetropolis.InitializeMysqlContainer; import com.behl.cachetropolis.entity.Wizard; import junit.framework.AssertionFailedError; import net.bytebuddy.utility.RandomString; @DataJpaTest -@ExtendWith(MySQLDataSourceInitializer.class) +@InitializeMysqlContainer class WizardRepositoryTest { @Autowired diff --git a/src/test/java/com/behl/cachetropolis/service/MasterHouseServiceTest.java b/src/test/java/com/behl/cachetropolis/service/MasterHouseServiceTest.java index 079ca88..2b6b961 100644 --- a/src/test/java/com/behl/cachetropolis/service/MasterHouseServiceTest.java +++ b/src/test/java/com/behl/cachetropolis/service/MasterHouseServiceTest.java @@ -9,15 +9,14 @@ import java.util.UUID; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.cache.CacheManager; -import com.behl.cachetropolis.RedisCacheInitializer; -import com.behl.cachetropolis.MySQLDataSourceInitializer; +import com.behl.cachetropolis.InitializeMysqlContainer; +import com.behl.cachetropolis.InitializeRedisContainer; import com.behl.cachetropolis.dto.HouseDto; import com.behl.cachetropolis.dto.WizardDto; import com.behl.cachetropolis.entity.Wizard; @@ -29,7 +28,8 @@ import net.bytebuddy.utility.RandomString; @SpringBootTest -@ExtendWith({ MySQLDataSourceInitializer.class, RedisCacheInitializer.class }) +@InitializeMysqlContainer +@InitializeRedisContainer class MasterHouseServiceTest { @Autowired diff --git a/src/test/java/com/behl/cachetropolis/service/WizardServiceTest.java b/src/test/java/com/behl/cachetropolis/service/WizardServiceTest.java index b0ab012..82cd99a 100644 --- a/src/test/java/com/behl/cachetropolis/service/WizardServiceTest.java +++ b/src/test/java/com/behl/cachetropolis/service/WizardServiceTest.java @@ -10,7 +10,6 @@ import java.util.UUID; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import org.modelmapper.ModelMapper; import org.springframework.beans.factory.annotation.Autowired; @@ -18,8 +17,8 @@ import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.cache.CacheManager; -import com.behl.cachetropolis.RedisCacheInitializer; -import com.behl.cachetropolis.MySQLDataSourceInitializer; +import com.behl.cachetropolis.InitializeMysqlContainer; +import com.behl.cachetropolis.InitializeRedisContainer; import com.behl.cachetropolis.dto.WizardCreationRequestDto; import com.behl.cachetropolis.dto.WizardDto; import com.behl.cachetropolis.dto.WizardUpdationRequestDto; @@ -33,7 +32,8 @@ import net.bytebuddy.utility.RandomString; @SpringBootTest -@ExtendWith({ MySQLDataSourceInitializer.class, RedisCacheInitializer.class }) +@InitializeMysqlContainer +@InitializeRedisContainer class WizardServiceTest { @Autowired