Skip to content

Commit

Permalink
Fix spacing issues
Browse files Browse the repository at this point in the history
(double-spaces, missing spaces, and new line at end of file)
  • Loading branch information
TWiStErRob committed Dec 3, 2023
1 parent 2f68291 commit 164652a
Show file tree
Hide file tree
Showing 24 changed files with 60 additions and 72 deletions.
66 changes: 33 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -44,7 +44,7 @@ jobs:
#
build:
needs: [verify]
runs-on: ubuntu-latest
runs-on: ubuntu-latest

# Definition of the build matrix
strategy:
Expand All @@ -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
Expand All @@ -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}}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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/)

Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions mockito-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
testImplementation 'com.nhaarman:expect.kt:1.0.1'

testImplementation "org.jetbrains.kotlin:kotlin-stdlib"
testImplementation "org.jetbrains.kotlin:kotlin-test"
testImplementation "org.jetbrains.kotlin:kotlin-stdlib"
testImplementation "org.jetbrains.kotlin:kotlin-test"
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0'

testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class ArgumentCaptorHolder5<out A, out B, out C, out D, out E>(
operator fun component5() = fifth
}


/**
* Creates 4 [KArgumentCaptor]s for given types.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <b>happened once</b> in order.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import org.mockito.stubbing.OngoingStubbing
import org.mockito.stubbing.Stubber
import kotlin.reflect.KClass


inline fun <T : Any> stubbing(
mock: T,
stubbing: KStubbing<T>.(T) -> Unit
Expand All @@ -47,7 +46,7 @@ inline fun <T : Any> T.stub(stubbing: KStubbing<T>.(T) -> Unit): T {

class KStubbing<out T : Any>(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 <R> on(methodCall: R): OngoingStubbing<R> = Mockito.`when`(methodCall)
Expand Down Expand Up @@ -90,4 +89,4 @@ class KStubbing<out T : Any>(val mock: T) {
fun Stubber.on(methodCall: T.() -> Unit) {
this.`when`(mock).methodCall()
}
}
}
5 changes: 2 additions & 3 deletions mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Matchers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ inline fun <reified T : Any> anyVararg(): T {
}

fun <T : Any> anyVararg(clazz: KClass<T>): T {
return ArgumentMatchers.argThat(VarargMatcher(clazz.java))?: createInstance(clazz)
return ArgumentMatchers.argThat(VarargMatcher(clazz.java)) ?: createInstance(clazz)
}

private class VarargMatcher<T>(private val clazz: Class<T>) : ArgumentMatcher<T>{
private class VarargMatcher<T>(private val clazz: Class<T>) : ArgumentMatcher<T> {
override fun matches(t: T): Boolean = true

// In Java >= 12 you can do clazz.arrayClass()
Expand Down Expand Up @@ -148,4 +148,3 @@ fun <T : Any> notNull(): T? {
inline fun <reified T : Any> refEq(value: T, vararg excludeFields: String): T {
return ArgumentMatchers.refEq<T>(value, *excludeFields) ?: createInstance()
}

Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ fun <T> reset(vararg mocks: T) {

fun mockingDetails(toInspect: Any): MockingDetails {
return Mockito.mockingDetails(toInspect)!!
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ package org.mockito.kotlin

import org.mockito.Mockito


/**
* Creates a spy of the real object.
* The spy calls <b>real</b> methods unless they are stubbed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import org.mockito.invocation.InvocationOnMock
import org.mockito.stubbing.Stubber
import kotlin.reflect.KClass


fun <T> doAnswer(answer: (InvocationOnMock) -> T?): Stubber {
return Mockito.doAnswer { answer(it) }!!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ fun <T> 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.
*
Expand Down Expand Up @@ -258,7 +259,6 @@ fun only(): VerificationMode {
return Mockito.only()!!
}


/**
* For usage with verification only.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

package org.mockito.kotlin


/**
* Verify multiple calls on mock
* Supports an easier to read style of
Expand All @@ -45,4 +44,4 @@ class VerifyScope<out T>(val mock: T) {
operator inline fun Int.times(call: T.() -> Unit) {
verify(mock, org.mockito.kotlin.times(this)).call()
}
}
}
1 change: 0 additions & 1 deletion mockito-kotlin/src/test/kotlin/test/CoroutinesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import org.mockito.InOrder
import org.mockito.kotlin.*
import java.util.*


class CoroutinesTest {

@Test
Expand Down
1 change: 0 additions & 1 deletion tests/src/test/kotlin/test/LenientStubberTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions tests/src/test/kotlin/test/MatchersTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class MatchersTest : TestBase() {
verify(this).boolean(anyOrNull())
}
}

@Test
fun anyNull_forPrimitiveByte() {
mock<Methods>().apply {
Expand Down Expand Up @@ -237,7 +238,6 @@ class MatchersTest : TestBase() {
}
}


@Test
fun isA_withNonNullableString() {
mock<Methods>().apply {
Expand Down Expand Up @@ -309,14 +309,14 @@ class MatchersTest : TestBase() {
/** https://github.com/nhaarman/mockito-kotlin/issues/328 */
@Test
fun testRefEqForNonNullableParameter() {
mock<Methods>().apply {
/* When */
val array = intArrayOf(2, 3)
intArray(array)
/* Then */
verify(this).intArray(refEq(array))
}
mock<Methods>().apply {
/* When */
val array = intArrayOf(2, 3)
intArray(array)

/* Then */
verify(this).intArray(refEq(array))
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/kotlin/test/MockMaker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
4 changes: 1 addition & 3 deletions tests/src/test/kotlin/test/MockingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class MockingTest : TestBase() {
expect(cal.time.time).toBe(123L)
}


@Test
fun testMockStubbing_lambda() {
/* Given */
Expand Down Expand Up @@ -106,7 +105,6 @@ class MockingTest : TestBase() {
expect(result).toBe("B")
}


@Test
fun mock_withCustomDefaultAnswer_parameterName() {
/* Given */
Expand Down Expand Up @@ -362,4 +360,4 @@ class MockingTest : TestBase() {

private interface MyInterface
private open class MyClass
}
}
1 change: 0 additions & 1 deletion tests/src/test/kotlin/test/OngoingStubbingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ class OngoingStubbingTest : TestBase() {
expect(result).toBe("result2")
}


@Test
fun stubbingTwiceWithArgumentMatchers() {
/* When */
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/kotlin/test/StubberTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ class StubberTest : TestBase() {

expect(mock.stringResult()).toBe("Test")
}
}
}
2 changes: 1 addition & 1 deletion tests/src/test/kotlin/test/TestBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ abstract class TestBase {
open fun tearDown() {
mockMakerInlineEnabled = null
}
}
}
2 changes: 1 addition & 1 deletion tests/src/test/kotlin/test/VerificationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ class VerificationTest : TestBase() {
verify(this, after(10)).int(3)
}
}
}
}
2 changes: 1 addition & 1 deletion tests/src/test/kotlin/test/VerifyTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ class VerifyTest : TestBase() {

fun defaultArgs(a: Int = 3, b: Int = 42)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import org.mockito.kotlin.internal.createInstance
import org.junit.Test
import test.TestBase


class NullCasterTest : TestBase() {

@Test
Expand Down

0 comments on commit 164652a

Please sign in to comment.