From d52a2dc1414af150f5d46742e877a5e0fd4cd2b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp=20=28TWiStErRob=29?= Date: Sat, 2 Dec 2023 12:38:20 +0000 Subject: [PATCH] Fix spacing issues (double-spaces, missing spaces, and new line at end of file) --- .github/workflows/ci.yml | 66 +++++++++---------- README.md | 3 +- mockito-kotlin/build.gradle | 4 +- .../org/mockito/kotlin/ArgumentCaptor.kt | 1 - .../kotlin/org/mockito/kotlin/KInOrder.kt | 2 +- .../kotlin/org/mockito/kotlin/KStubbing.kt | 5 +- .../kotlin/org/mockito/kotlin/Matchers.kt | 5 +- .../main/kotlin/org/mockito/kotlin/Mockito.kt | 2 +- .../org/mockito/kotlin/OngoingStubbing.kt | 1 - .../main/kotlin/org/mockito/kotlin/Spying.kt | 1 - .../main/kotlin/org/mockito/kotlin/Stubber.kt | 1 - .../kotlin/org/mockito/kotlin/Verification.kt | 2 +- .../kotlin/org/mockito/kotlin/VerifyScope.kt | 3 +- .../src/test/kotlin/test/CoroutinesTest.kt | 1 - .../test/kotlin/test/LenientStubberTest.kt | 1 - tests/src/test/kotlin/test/MatchersTest.kt | 18 ++--- tests/src/test/kotlin/test/MockMaker.kt | 2 +- tests/src/test/kotlin/test/MockingTest.kt | 4 +- .../test/kotlin/test/OngoingStubbingTest.kt | 1 - tests/src/test/kotlin/test/StubberTest.kt | 2 +- tests/src/test/kotlin/test/TestBase.kt | 2 +- .../src/test/kotlin/test/VerificationTest.kt | 2 +- tests/src/test/kotlin/test/VerifyTest.kt | 2 +- .../test/createinstance/NullCasterTest.kt | 1 - 24 files changed, 60 insertions(+), 72 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 809cad1e..b43e58a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: # SINGLE-JOB # verify: - runs-on: ubuntu-latest + runs-on: ubuntu-latest if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" steps: @@ -44,7 +44,7 @@ jobs: # build: needs: [verify] - runs-on: ubuntu-latest + runs-on: ubuntu-latest # Definition of the build matrix strategy: @@ -56,21 +56,21 @@ jobs: steps: - - name: 1. Check out code - uses: actions/checkout@v2 # https://github.com/actions/checkout + - name: 1. Check out code + uses: actions/checkout@v2 # https://github.com/actions/checkout - - name: 2. Set up Java 11 - uses: actions/setup-java@v1 # https://github.com/actions/setup-java - with: - java-version: 11 + - name: 2. Set up Java 11 + uses: actions/setup-java@v1 # https://github.com/actions/setup-java + with: + java-version: 11 - - name: 3. Build with Kotlin ${{ matrix.kotlin }} and mock-maker ${{ matrix.mock-maker }} - run: | - ops/mockMakerInline.sh - ./gradlew build - env: - KOTLIN_VERSION: ${{ matrix.kotlin }} - MOCK_MAKER: ${{ matrix.mock-maker }} + - name: 3. Build with Kotlin ${{ matrix.kotlin }} and mock-maker ${{ matrix.mock-maker }} + run: | + ops/mockMakerInline.sh + ./gradlew build + env: + KOTLIN_VERSION: ${{ matrix.kotlin }} + MOCK_MAKER: ${{ matrix.mock-maker }} # # Release job, only for pushes to the main development branch @@ -86,21 +86,21 @@ jobs: steps: - - name: Check out code - uses: actions/checkout@v2 # https://github.com/actions/checkout - with: - fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci - - - name: Set up Java 11 - uses: actions/setup-java@v1 - with: - java-version: 11 - - - name: Build and release - run: ./gradlew githubRelease publishToSonatype closeAndReleaseStagingRepository releaseSummary - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - NEXUS_TOKEN_USER: ${{secrets.NEXUS_TOKEN_USER}} - NEXUS_TOKEN_PWD: ${{secrets.NEXUS_TOKEN_PWD}} - PGP_KEY: ${{secrets.PGP_KEY}} - PGP_PWD: ${{secrets.PGP_PWD}} + - name: Check out code + uses: actions/checkout@v2 # https://github.com/actions/checkout + with: + fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci + + - name: Set up Java 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Build and release + run: ./gradlew githubRelease publishToSonatype closeAndReleaseStagingRepository releaseSummary + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + NEXUS_TOKEN_USER: ${{secrets.NEXUS_TOKEN_USER}} + NEXUS_TOKEN_PWD: ${{secrets.NEXUS_TOKEN_PWD}} + PGP_KEY: ${{secrets.PGP_KEY}} + PGP_PWD: ${{secrets.PGP_PWD}} diff --git a/README.md b/README.md index 32678c7a..ee78193d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Mockito-Kotlin + [ ![Download](https://maven-badges.herokuapp.com/maven-central/org.mockito.kotlin/mockito-kotlin/badge.svg) ](https://maven-badges.herokuapp.com/maven-central/org.mockito.kotlin/mockito-kotlin) [![Nexus Snapshot](https://img.shields.io/nexus/s/org.mockito.kotlin/mockito-kotlin?server=https%3A%2F%2Fs01.oss.sonatype.org%2F)](https://s01.oss.sonatype.org/content/repositories/snapshots/org/mockito/kotlin/mockito-kotlin/) @@ -56,7 +57,7 @@ keeping the base module at a recent version. - `./gradlew check` runs the checks including tests. -Usually it is enough to test only using the default Kotlin versions; +Usually it is enough to test only using the default Kotlin versions; CI will test against multiple versions. If you want to test using a different Kotlin version locally, set an environment variable `KOTLIN_VERSION` and run the tests. diff --git a/mockito-kotlin/build.gradle b/mockito-kotlin/build.gradle index 9b38018c..83d2d527 100644 --- a/mockito-kotlin/build.gradle +++ b/mockito-kotlin/build.gradle @@ -31,8 +31,8 @@ dependencies { testImplementation 'junit:junit:4.13.2' testImplementation 'com.nhaarman:expect.kt:1.0.1' - testImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0' testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0" diff --git a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/ArgumentCaptor.kt b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/ArgumentCaptor.kt index 0edfdb85..4b9017c9 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/ArgumentCaptor.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/ArgumentCaptor.kt @@ -93,7 +93,6 @@ class ArgumentCaptorHolder5( operator fun component5() = fifth } - /** * Creates 4 [KArgumentCaptor]s for given types. */ diff --git a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/KInOrder.kt b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/KInOrder.kt index 152148ea..f2de3584 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/KInOrder.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/KInOrder.kt @@ -28,7 +28,7 @@ package org.mockito.kotlin import org.mockito.InOrder import org.mockito.verification.VerificationMode -interface KInOrder: InOrder { +interface KInOrder : InOrder { /** * Verifies certain suspending behavior happened once in order. * diff --git a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/KStubbing.kt b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/KStubbing.kt index 3ea1d88d..31a7c75c 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/KStubbing.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/KStubbing.kt @@ -33,7 +33,6 @@ import org.mockito.stubbing.OngoingStubbing import org.mockito.stubbing.Stubber import kotlin.reflect.KClass - inline fun stubbing( mock: T, stubbing: KStubbing.(T) -> Unit @@ -47,7 +46,7 @@ inline fun T.stub(stubbing: KStubbing.(T) -> Unit): T { class KStubbing(val mock: T) { init { - if(!mockingDetails(mock).isMock) throw NotAMockException("Stubbing target is not a mock!") + if (!mockingDetails(mock).isMock) throw NotAMockException("Stubbing target is not a mock!") } fun on(methodCall: R): OngoingStubbing = Mockito.`when`(methodCall) @@ -90,4 +89,4 @@ class KStubbing(val mock: T) { fun Stubber.on(methodCall: T.() -> Unit) { this.`when`(mock).methodCall() } -} \ No newline at end of file +} diff --git a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Matchers.kt b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Matchers.kt index 19f91a78..14b37394 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Matchers.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Matchers.kt @@ -56,10 +56,10 @@ inline fun anyVararg(): T { } fun anyVararg(clazz: KClass): T { - return ArgumentMatchers.argThat(VarargMatcher(clazz.java))?: createInstance(clazz) + return ArgumentMatchers.argThat(VarargMatcher(clazz.java)) ?: createInstance(clazz) } -private class VarargMatcher(private val clazz: Class) : ArgumentMatcher{ +private class VarargMatcher(private val clazz: Class) : ArgumentMatcher { override fun matches(t: T): Boolean = true // In Java >= 12 you can do clazz.arrayClass() @@ -148,4 +148,3 @@ fun notNull(): T? { inline fun refEq(value: T, vararg excludeFields: String): T { return ArgumentMatchers.refEq(value, *excludeFields) ?: createInstance() } - diff --git a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Mockito.kt b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Mockito.kt index 0f80e0cd..2aeb68b4 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Mockito.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Mockito.kt @@ -38,4 +38,4 @@ fun reset(vararg mocks: T) { fun mockingDetails(toInspect: Any): MockingDetails { return Mockito.mockingDetails(toInspect)!! -} \ No newline at end of file +} diff --git a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/OngoingStubbing.kt b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/OngoingStubbing.kt index 25761122..30966bf3 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/OngoingStubbing.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/OngoingStubbing.kt @@ -34,7 +34,6 @@ import org.mockito.stubbing.Answer import org.mockito.stubbing.OngoingStubbing import kotlin.reflect.KClass - /** * Enables stubbing methods. Use it when you want the mock to return particular value when particular method is called. * diff --git a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Spying.kt b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Spying.kt index e879d9d3..e8da5e36 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Spying.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Spying.kt @@ -27,7 +27,6 @@ package org.mockito.kotlin import org.mockito.Mockito - /** * Creates a spy of the real object. * The spy calls real methods unless they are stubbed. diff --git a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Stubber.kt b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Stubber.kt index 5fa48c96..0c79f6e2 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Stubber.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Stubber.kt @@ -31,7 +31,6 @@ import org.mockito.invocation.InvocationOnMock import org.mockito.stubbing.Stubber import kotlin.reflect.KClass - fun doAnswer(answer: (InvocationOnMock) -> T?): Stubber { return Mockito.doAnswer { answer(it) }!! } diff --git a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Verification.kt b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Verification.kt index e8437731..ad7ff0f3 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Verification.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Verification.kt @@ -63,6 +63,7 @@ fun verifyBlocking(mock: T, mode: VerificationMode, f: suspend T.() -> Unit) val m = Mockito.verify(mock, mode) runBlocking { m.f() } } + /** * Verifies certain behavior happened at least once / exact number of times / never. * @@ -258,7 +259,6 @@ fun only(): VerificationMode { return Mockito.only()!! } - /** * For usage with verification only. * diff --git a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/VerifyScope.kt b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/VerifyScope.kt index 72ac6e24..29a49a93 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/VerifyScope.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/VerifyScope.kt @@ -25,7 +25,6 @@ package org.mockito.kotlin - /** * Verify multiple calls on mock * Supports an easier to read style of @@ -45,4 +44,4 @@ class VerifyScope(val mock: T) { operator inline fun Int.times(call: T.() -> Unit) { verify(mock, org.mockito.kotlin.times(this)).call() } -} \ No newline at end of file +} diff --git a/mockito-kotlin/src/test/kotlin/test/CoroutinesTest.kt b/mockito-kotlin/src/test/kotlin/test/CoroutinesTest.kt index 48208133..eea7fd43 100644 --- a/mockito-kotlin/src/test/kotlin/test/CoroutinesTest.kt +++ b/mockito-kotlin/src/test/kotlin/test/CoroutinesTest.kt @@ -16,7 +16,6 @@ import org.mockito.InOrder import org.mockito.kotlin.* import java.util.* - class CoroutinesTest { @Test diff --git a/tests/src/test/kotlin/test/LenientStubberTest.kt b/tests/src/test/kotlin/test/LenientStubberTest.kt index f7dddd57..f95e871a 100644 --- a/tests/src/test/kotlin/test/LenientStubberTest.kt +++ b/tests/src/test/kotlin/test/LenientStubberTest.kt @@ -12,7 +12,6 @@ import org.mockito.kotlin.mock import org.mockito.kotlin.whenever import org.mockito.quality.Strictness - open class LenientStubberTest { @get:Rule val rule: MockitoRule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS) diff --git a/tests/src/test/kotlin/test/MatchersTest.kt b/tests/src/test/kotlin/test/MatchersTest.kt index 2eb0dc2e..0fc47faa 100644 --- a/tests/src/test/kotlin/test/MatchersTest.kt +++ b/tests/src/test/kotlin/test/MatchersTest.kt @@ -98,6 +98,7 @@ class MatchersTest : TestBase() { verify(this).boolean(anyOrNull()) } } + @Test fun anyNull_forPrimitiveByte() { mock().apply { @@ -237,7 +238,6 @@ class MatchersTest : TestBase() { } } - @Test fun isA_withNonNullableString() { mock().apply { @@ -309,14 +309,14 @@ class MatchersTest : TestBase() { /** https://github.com/nhaarman/mockito-kotlin/issues/328 */ @Test fun testRefEqForNonNullableParameter() { - mock().apply { - /* When */ - val array = intArrayOf(2, 3) - intArray(array) - - /* Then */ - verify(this).intArray(refEq(array)) - } + mock().apply { + /* When */ + val array = intArrayOf(2, 3) + intArray(array) + + /* Then */ + verify(this).intArray(refEq(array)) + } } /** diff --git a/tests/src/test/kotlin/test/MockMaker.kt b/tests/src/test/kotlin/test/MockMaker.kt index 54f3d91d..da8d2528 100644 --- a/tests/src/test/kotlin/test/MockMaker.kt +++ b/tests/src/test/kotlin/test/MockMaker.kt @@ -3,8 +3,8 @@ package test import org.mockito.internal.configuration.plugins.Plugins import org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker - internal var mockMakerInlineEnabled: Boolean? = null + internal fun mockMakerInlineEnabled(): Boolean { return mockMakerInlineEnabled ?: (Plugins.getMockMaker() is InlineByteBuddyMockMaker) } diff --git a/tests/src/test/kotlin/test/MockingTest.kt b/tests/src/test/kotlin/test/MockingTest.kt index f0f9f64a..a7ca713c 100644 --- a/tests/src/test/kotlin/test/MockingTest.kt +++ b/tests/src/test/kotlin/test/MockingTest.kt @@ -76,7 +76,6 @@ class MockingTest : TestBase() { expect(cal.time.time).toBe(123L) } - @Test fun testMockStubbing_lambda() { /* Given */ @@ -106,7 +105,6 @@ class MockingTest : TestBase() { expect(result).toBe("B") } - @Test fun mock_withCustomDefaultAnswer_parameterName() { /* Given */ @@ -362,4 +360,4 @@ class MockingTest : TestBase() { private interface MyInterface private open class MyClass -} \ No newline at end of file +} diff --git a/tests/src/test/kotlin/test/OngoingStubbingTest.kt b/tests/src/test/kotlin/test/OngoingStubbingTest.kt index bf2af984..ab452a76 100644 --- a/tests/src/test/kotlin/test/OngoingStubbingTest.kt +++ b/tests/src/test/kotlin/test/OngoingStubbingTest.kt @@ -236,7 +236,6 @@ class OngoingStubbingTest : TestBase() { expect(result).toBe("result2") } - @Test fun stubbingTwiceWithArgumentMatchers() { /* When */ diff --git a/tests/src/test/kotlin/test/StubberTest.kt b/tests/src/test/kotlin/test/StubberTest.kt index 81ac7f23..7b8f6af9 100644 --- a/tests/src/test/kotlin/test/StubberTest.kt +++ b/tests/src/test/kotlin/test/StubberTest.kt @@ -109,4 +109,4 @@ class StubberTest : TestBase() { expect(mock.stringResult()).toBe("Test") } -} \ No newline at end of file +} diff --git a/tests/src/test/kotlin/test/TestBase.kt b/tests/src/test/kotlin/test/TestBase.kt index 95c76ece..52c45c20 100644 --- a/tests/src/test/kotlin/test/TestBase.kt +++ b/tests/src/test/kotlin/test/TestBase.kt @@ -8,4 +8,4 @@ abstract class TestBase { open fun tearDown() { mockMakerInlineEnabled = null } -} \ No newline at end of file +} diff --git a/tests/src/test/kotlin/test/VerificationTest.kt b/tests/src/test/kotlin/test/VerificationTest.kt index f2f92fdf..db5620fc 100644 --- a/tests/src/test/kotlin/test/VerificationTest.kt +++ b/tests/src/test/kotlin/test/VerificationTest.kt @@ -112,4 +112,4 @@ class VerificationTest : TestBase() { verify(this, after(10)).int(3) } } -} \ No newline at end of file +} diff --git a/tests/src/test/kotlin/test/VerifyTest.kt b/tests/src/test/kotlin/test/VerifyTest.kt index 1af73fdf..0fd9514b 100644 --- a/tests/src/test/kotlin/test/VerifyTest.kt +++ b/tests/src/test/kotlin/test/VerifyTest.kt @@ -93,4 +93,4 @@ class VerifyTest : TestBase() { fun defaultArgs(a: Int = 3, b: Int = 42) } -} \ No newline at end of file +} diff --git a/tests/src/test/kotlin/test/createinstance/NullCasterTest.kt b/tests/src/test/kotlin/test/createinstance/NullCasterTest.kt index 6d160c78..d379c00a 100644 --- a/tests/src/test/kotlin/test/createinstance/NullCasterTest.kt +++ b/tests/src/test/kotlin/test/createinstance/NullCasterTest.kt @@ -5,7 +5,6 @@ import org.mockito.kotlin.internal.createInstance import org.junit.Test import test.TestBase - class NullCasterTest : TestBase() { @Test