-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cover code generation from regressions (#130)
This patch covers the code generated files from regressions
- Loading branch information
1 parent
e77fd07
commit af73c24
Showing
16 changed files
with
1,257 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
samples/kspsample/src/jvmTest/kotlin/com/careem/mockingbird/kspsample/GeneratedFilesTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright Careem, an Uber Technologies Inc. company | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.careem.mockingbird.kspsample | ||
|
||
import com.careem.mockingbird.test.annotations.Mock | ||
import org.junit.Test | ||
import java.io.File | ||
import kotlin.test.assertEquals | ||
|
||
class GeneratedFilesTest { | ||
|
||
@Mock | ||
val pippoMock: PippoSample = PippoSampleMock() | ||
|
||
@Mock | ||
val outerInterface: OuterInterface = OuterInterfaceMock() | ||
|
||
@Mock | ||
val multipleGetterProperties: MultipleGetterProperties = MultipleGetterPropertiesMock() | ||
|
||
@Mock | ||
val mockWithExternalDependencies: MockWithExternalDependencies = MockWithExternalDependenciesMock() | ||
|
||
@Mock | ||
val mock1: Mock1 = Mock1Mock() | ||
|
||
@Mock | ||
val lambdaSample: LambdaSample = LambdaSampleMock() | ||
|
||
@Mock | ||
val javaTypes: JavaTypes = JavaTypesMock() | ||
|
||
@Mock | ||
private val internalSampleInterface: InternalSampleInterface = InternalSampleInterfaceMock() | ||
|
||
@Mock | ||
val interfaceWithGenerics: InterfaceWithGenerics = InterfaceWithGenericsMock() | ||
|
||
@Mock | ||
val innerInterface: InnerInterface = InnerInterfaceMock() | ||
|
||
@Mock | ||
val innerInnerInterface: InnerInnerInterface = InnerInnerInterfaceMock() | ||
|
||
@Mock | ||
val uiDelegate: UiDelegate<UiState> = UiDelegate_UiStateMock() | ||
|
||
@Mock | ||
val uiDelegate2Args: UiDelegate2Args<UiState, Value> = UiDelegate2Args_UiState_ValueMock() | ||
|
||
@Test | ||
fun testFileGeneration() { | ||
val expectFolder = expectedCodeGenFolder() | ||
val actualFolder = actualCodeGenFolder() | ||
|
||
assertEquals(actualFolder.listFiles()!!.size, expectFolder.listFiles()!!.size) | ||
|
||
expectFolder.listFiles()!!.forEach { expect -> | ||
val actual = lookUpActual(actualFolder, expect) | ||
assertEquals(expect.readText(), actual.readText()) | ||
} | ||
} | ||
|
||
private fun expectedCodeGenFolder(): File = File("src/jvmTest/resources/mocks/com/careem/mockingbird/kspsample") | ||
private fun actualCodeGenFolder(): File = File("build/generated/ksp/jvm/jvmTest/kotlin/com/careem/mockingbird/kspsample") | ||
private fun lookUpActual(actualFolder: File, expectFile: File): File { | ||
return File("${actualFolder.path}/${expectFile.name}") | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...e/src/jvmTest/resources/mocks/com/careem/mockingbird/kspsample/InnerInnerInterfaceMock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.careem.mockingbird.kspsample | ||
|
||
import com.careem.mockingbird.test.Mock | ||
import com.careem.mockingbird.test.mock | ||
import com.careem.mockingbird.test.mockUnit | ||
import com.careem.mockingbird.test.uuid | ||
import kotlin.Int | ||
import kotlin.String | ||
import kotlin.Unit | ||
|
||
public class InnerInnerInterfaceMock : InnerInnerInterface, Mock { | ||
public override val uuid: String by uuid() | ||
|
||
public override val yo3: Int | ||
get() = mock( | ||
methodName = Property.getYo3 | ||
) | ||
|
||
public override fun deepFoo(deepArg: String): Unit { | ||
return mockUnit( | ||
methodName = Method.deepFoo, | ||
arguments = mapOf(Arg.deepArg to deepArg) | ||
) | ||
} | ||
|
||
public object Method { | ||
public const val deepFoo: String = "deepFoo" | ||
} | ||
|
||
public object Arg { | ||
public const val deepArg: String = "deepArg" | ||
} | ||
|
||
public object Property { | ||
public const val getYo3: String = "getYo3" | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...sample/src/jvmTest/resources/mocks/com/careem/mockingbird/kspsample/InnerInterfaceMock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.careem.mockingbird.kspsample | ||
|
||
import com.careem.mockingbird.test.Mock | ||
import com.careem.mockingbird.test.mock | ||
import com.careem.mockingbird.test.mockUnit | ||
import com.careem.mockingbird.test.uuid | ||
import kotlin.Int | ||
import kotlin.String | ||
import kotlin.Unit | ||
|
||
public class InnerInterfaceMock : InnerInterface, Mock { | ||
public override val uuid: String by uuid() | ||
|
||
public override var yo2: String | ||
get() = mock( | ||
methodName = Property.getYo2 | ||
) | ||
set(`value`) { | ||
return mockUnit( | ||
methodName = Property.setYo2, | ||
arguments = mapOf(Property.`value` to value) | ||
) | ||
} | ||
|
||
public override val yo3: Int | ||
get() = mock( | ||
methodName = Property.getYo3 | ||
) | ||
|
||
public override fun foo(fooArg: String): Unit { | ||
return mockUnit( | ||
methodName = Method.foo, | ||
arguments = mapOf(Arg.fooArg to fooArg) | ||
) | ||
} | ||
|
||
public override fun foo2(fooArg2: String): Unit { | ||
return mockUnit( | ||
methodName = Method.foo2, | ||
arguments = mapOf(Arg.fooArg2 to fooArg2) | ||
) | ||
} | ||
|
||
public override fun deepFoo(deepArg: String): Unit { | ||
return mockUnit( | ||
methodName = Method.deepFoo, | ||
arguments = mapOf(Arg.deepArg to deepArg) | ||
) | ||
} | ||
|
||
public object Method { | ||
public const val foo: String = "foo" | ||
|
||
public const val foo2: String = "foo2" | ||
|
||
public const val deepFoo: String = "deepFoo" | ||
} | ||
|
||
public object Arg { | ||
public const val fooArg: String = "fooArg" | ||
|
||
public const val fooArg2: String = "fooArg2" | ||
|
||
public const val deepArg: String = "deepArg" | ||
} | ||
|
||
public object Property { | ||
public const val getYo2: String = "getYo2" | ||
|
||
public const val setYo2: String = "setYo2" | ||
|
||
public const val getYo3: String = "getYo3" | ||
|
||
public const val `value`: String = "value" | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
...src/jvmTest/resources/mocks/com/careem/mockingbird/kspsample/InterfaceWithGenericsMock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.careem.mockingbird.kspsample | ||
|
||
import com.careem.mockingbird.test.Mock | ||
import com.careem.mockingbird.test.mock | ||
import com.careem.mockingbird.test.mockUnit | ||
import com.careem.mockingbird.test.uuid | ||
import kotlin.Int | ||
import kotlin.String | ||
import kotlin.collections.List | ||
import kotlin.collections.Map | ||
|
||
public class InterfaceWithGenericsMock : InterfaceWithGenerics, Mock { | ||
public override val uuid: String by uuid() | ||
|
||
public override var g1: List<String> | ||
get() = mock( | ||
methodName = Property.getG1 | ||
) | ||
set(`value`) { | ||
return mockUnit( | ||
methodName = Property.setG1, | ||
arguments = mapOf(Property.`value` to value) | ||
) | ||
} | ||
|
||
public override var g2: Map<String, Int> | ||
get() = mock( | ||
methodName = Property.getG2 | ||
) | ||
set(`value`) { | ||
return mockUnit( | ||
methodName = Property.setG2, | ||
arguments = mapOf(Property.`value` to value) | ||
) | ||
} | ||
|
||
public override fun complexFoo(fooArg: List<Map<List<List<Int>>, List<String>>>): | ||
List<List<String>> { | ||
return mock( | ||
methodName = Method.complexFoo, | ||
arguments = mapOf(Arg.fooArg to fooArg) | ||
) | ||
} | ||
|
||
public override fun foo(fooArg: List<List<Int>>): List<List<String>> { | ||
return mock( | ||
methodName = Method.foo, | ||
arguments = mapOf(Arg.fooArg to fooArg) | ||
) | ||
} | ||
|
||
public override fun foo(fooArg: Map<Int, String>): Map<String, Int> { | ||
return mock( | ||
methodName = Method.foo, | ||
arguments = mapOf(Arg.fooArg to fooArg) | ||
) | ||
} | ||
|
||
public object Method { | ||
public const val complexFoo: String = "complexFoo" | ||
|
||
public const val foo: String = "foo" | ||
} | ||
|
||
public object Arg { | ||
public const val fooArg: String = "fooArg" | ||
} | ||
|
||
public object Property { | ||
public const val getG1: String = "getG1" | ||
|
||
public const val setG1: String = "setG1" | ||
|
||
public const val getG2: String = "getG2" | ||
|
||
public const val setG2: String = "setG2" | ||
|
||
public const val `value`: String = "value" | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...c/jvmTest/resources/mocks/com/careem/mockingbird/kspsample/InternalSampleInterfaceMock.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.careem.mockingbird.kspsample | ||
|
||
import com.careem.mockingbird.test.Mock | ||
import com.careem.mockingbird.test.mockUnit | ||
import com.careem.mockingbird.test.uuid | ||
import kotlin.String | ||
import kotlin.Unit | ||
|
||
internal class InternalSampleInterfaceMock : InternalSampleInterface, Mock { | ||
public override val uuid: String by uuid() | ||
|
||
public override fun thisIsInternal(`param`: String): Unit { | ||
return mockUnit( | ||
methodName = Method.thisIsInternal, | ||
arguments = mapOf(Arg.`param` to param) | ||
) | ||
} | ||
|
||
public object Method { | ||
public const val thisIsInternal: String = "thisIsInternal" | ||
} | ||
|
||
public object Arg { | ||
public const val `param`: String = "param" | ||
} | ||
|
||
public object Property | ||
} |
Oops, something went wrong.