From ebc1677cec4d7c2a39da9f04828d2da843eef9e5 Mon Sep 17 00:00:00 2001 From: cdubuisson Date: Sat, 1 Feb 2020 22:37:22 +0100 Subject: [PATCH] :truck: : move inline function whenever in specific utils file --- .../io/codeka/gaia/modules/api/DockerRegistryApiTest.kt | 2 +- .../registries/controller/GithubRegistryControllerTest.kt | 8 +------- .../gaia/registries/service/RegistryServiceImplTest.kt | 2 +- src/test/java/io/codeka/gaia/test/KotlinUtils.kt | 8 ++++++++ 4 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 src/test/java/io/codeka/gaia/test/KotlinUtils.kt diff --git a/src/test/java/io/codeka/gaia/modules/api/DockerRegistryApiTest.kt b/src/test/java/io/codeka/gaia/modules/api/DockerRegistryApiTest.kt index 84f8a6029..78f4b727a 100644 --- a/src/test/java/io/codeka/gaia/modules/api/DockerRegistryApiTest.kt +++ b/src/test/java/io/codeka/gaia/modules/api/DockerRegistryApiTest.kt @@ -1,6 +1,6 @@ package io.codeka.gaia.modules.api -import io.codeka.gaia.registries.controller.whenever +import io.codeka.gaia.test.whenever import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test diff --git a/src/test/java/io/codeka/gaia/registries/controller/GithubRegistryControllerTest.kt b/src/test/java/io/codeka/gaia/registries/controller/GithubRegistryControllerTest.kt index 49ef3a800..6577c3cfb 100644 --- a/src/test/java/io/codeka/gaia/registries/controller/GithubRegistryControllerTest.kt +++ b/src/test/java/io/codeka/gaia/registries/controller/GithubRegistryControllerTest.kt @@ -9,14 +9,12 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.mockito.InjectMocks import org.mockito.Mock -import org.mockito.Mockito import org.mockito.Mockito.verify import org.mockito.Mockito.verifyNoMoreInteractions import org.mockito.junit.jupiter.MockitoExtension -import org.mockito.stubbing.OngoingStubbing @ExtendWith(MockitoExtension::class) -class GithubRegistryControllerTest{ +class GithubRegistryControllerTest { @Mock lateinit var githubRegistryApi: RegistryApi @@ -51,7 +49,3 @@ class GithubRegistryControllerTest{ verifyNoMoreInteractions(registryService) } } - -inline fun whenever(methodCall: T): OngoingStubbing { - return Mockito.`when`(methodCall)!! -} \ No newline at end of file diff --git a/src/test/java/io/codeka/gaia/registries/service/RegistryServiceImplTest.kt b/src/test/java/io/codeka/gaia/registries/service/RegistryServiceImplTest.kt index ae6432ed9..dae743f10 100644 --- a/src/test/java/io/codeka/gaia/registries/service/RegistryServiceImplTest.kt +++ b/src/test/java/io/codeka/gaia/registries/service/RegistryServiceImplTest.kt @@ -6,10 +6,10 @@ import io.codeka.gaia.modules.bo.Variable import io.codeka.gaia.modules.repository.TerraformModuleRepository import io.codeka.gaia.registries.RegistryApi import io.codeka.gaia.registries.RegistryType -import io.codeka.gaia.registries.controller.whenever import io.codeka.gaia.registries.github.GithubRepository import io.codeka.gaia.registries.gitlab.GitlabRepository import io.codeka.gaia.teams.User +import io.codeka.gaia.test.whenever import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test diff --git a/src/test/java/io/codeka/gaia/test/KotlinUtils.kt b/src/test/java/io/codeka/gaia/test/KotlinUtils.kt new file mode 100644 index 000000000..5bdbf60fa --- /dev/null +++ b/src/test/java/io/codeka/gaia/test/KotlinUtils.kt @@ -0,0 +1,8 @@ +package io.codeka.gaia.test + +import org.mockito.Mockito +import org.mockito.stubbing.OngoingStubbing + +inline fun whenever(methodCall: T): OngoingStubbing { + return Mockito.`when`(methodCall)!! +}