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
import io.mockk.Called | |
import io.mockk.every | |
import io.mockk.mockk | |
import io.mockk.verify | |
import org.junit.jupiter.api.Test | |
import java.util.function.Consumer | |
import java.util.function.Supplier | |
class NullOrUnitWasNotCalled { | |
@Test |
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
import io.mockk.mockk | |
import io.mockk.verify | |
import org.junit.jupiter.api.Test | |
class MockkUnitLambdaTest { | |
@Test | |
fun mockUnitLambda() { | |
val fn: (String) -> Unit = mockk(relaxUnitFun = true) |
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
import groovy.transform.TupleConstructor | |
import org.javers.core.JaversBuilder | |
import org.javers.core.diff.changetype.container.SetChange | |
import org.javers.core.diff.changetype.container.ValueAdded | |
import org.javers.core.metamodel.annotation.Id | |
import spock.lang.Specification | |
import static java.util.UUID.randomUUID | |
class SetPropertySpec extends Specification { |
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
import org.jetbrains.spek.api.dsl.describe | |
import org.jetbrains.spek.api.dsl.given | |
import org.jetbrains.spek.api.dsl.it | |
import org.jetbrains.spek.api.dsl.on | |
import org.jetbrains.spek.subject.SubjectSpek | |
import org.jetbrains.spek.subject.itBehavesLike | |
import org.junit.Assert.assertFalse | |
import org.junit.Assert.assertTrue | |
open class Thing(protected val fn: () -> Unit) { |
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
import org.jetbrains.spek.api.Spek | |
class TableSpec : Spek({ | |
describe("using a table") { | |
table { a: String, b: Int -> | |
describe("$a and $b are parameters") { | |
it("should work") { | |
assert(a is String) | |
assert(b is Int) | |
} |
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
import groovy.transform.* | |
@CompileStatic | |
Map<String, ?> makeMap() { | |
def map = [string: "string"] | |
map.number = 1 | |
return map | |
} | |
def map = makeMap() |
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
import org.jetbrains.spek.api.* | |
class InteropNullabilitySpec : Spek() { | |
init { | |
given("a java object with null state") { | |
val obj = JavaStringWrapper(null) | |
on("calling a getter that will return null") { | |
it("allows me to assign the result to a nullable type") { | |
val s: String? = obj.value | |
shouldBeNull(s) |
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
fun diamond(c: Char): String { | |
if (c !in 'A'..'Z') throw IllegalArgumentException() | |
return ('A'..c) | |
.map(row(c)) | |
.mirrorDown() | |
.joinToString("\n") | |
} | |
private fun row(max: Char) = { next: Char -> | |
"$next" |
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
ctx | |
.byMethod(spec -> | |
spec | |
.get(() -> ctx.render("GET")) | |
.post(() -> ctx.render("POST")) | |
); |
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
import com.fasterxml.jackson.annotation.JsonSubTypes.Type | |
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id | |
import com.fasterxml.jackson.annotation.{JsonSubTypes, JsonTypeInfo} | |
@JsonTypeInfo(use = Id.NAME, property = "name") | |
@JsonSubTypes(Array( | |
new Type(classOf[Vodka.type]), | |
new Type(classOf[Whiskey]) | |
)) | |
trait Spirit |
NewerOlder