All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bybutter.sisyphus.test.CallContext.kt Maven / Gradle / Ivy

There is a newer version: 2.1.22
Show newest version
package com.bybutter.sisyphus.test

import com.bybutter.sisyphus.protobuf.Message
import io.grpc.CallOptions
import io.grpc.Metadata
import io.grpc.MethodDescriptor
import io.grpc.Status

data class CallContext(
    val case: TestCase,
    val step: TestStep,
    var options: CallOptions,
    val method: MethodDescriptor, Message<*, *>>,
    val headers: Metadata,
    val input: Message<*, *>,
    var status: Status? = null,
    var trailers: Metadata? = null,
    var output: Message<*, *>? = null
) {
    fun toCelContext(): Map {
        return mutableMapOf().apply {
            this["step"] = [email protected]
            this["case"] = [email protected]
            this["method"] = [email protected]
            this["status"] = [email protected]?.code?.value()?.toLong() ?: 0L
            this["message"] = [email protected]?.description ?: ""
            this["input"] = [email protected]
            this["output"] = [email protected]
            this["headers"] = [email protected]()
            this["trailers"] = [email protected]?.toMap()
        }
    }

    fun toTestResult(): TestResult {
        return TestResult {
            this.step = [email protected]
            this.case = [email protected]
            this.method = [email protected]
            this.status = [email protected]?.code?.value() ?: 0
            this.message = [email protected]?.description ?: ""
            this.input = [email protected]
            this.output = [email protected]
            this.headers += [email protected]()
            [email protected]?.toMap()?.let {
                this.trailers += it
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy