mirror of
https://github.com/openflocon/Flocon.git
synced 2026-05-14 19:14:48 +00:00
feat: [NETWORK] mock http calls (#83)
* feat: [NETWORK] mock http calls * feat: [NETWORK] mock http calls * feat: [NETWORK] mock http calls * feat: [NETWORK] mock http calls * used buildmap * used buildmap * used buildmap --------- Co-authored-by: Florent Champigny <florent@bere.al>
This commit is contained in:
parent
b89c3f8a1d
commit
9d73df5e5a
12 changed files with 334 additions and 8 deletions
|
|
@ -2,7 +2,9 @@ package io.github.openflocon.flocon.plugins.network
|
|||
|
||||
import io.github.openflocon.flocon.core.FloconPlugin
|
||||
import io.github.openflocon.flocon.plugins.network.model.FloconNetworkRequest
|
||||
import io.github.openflocon.flocon.plugins.network.model.MockNetworkResponse
|
||||
|
||||
interface FloconNetworkPlugin : FloconPlugin {
|
||||
val mocks: Collection<MockNetworkResponse>
|
||||
fun log(call: FloconNetworkRequest)
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ data class FloconNetworkRequest(
|
|||
val response: Response,
|
||||
val durationMs: Double,
|
||||
val floconNetworkType: String,
|
||||
val isMocked: Boolean,
|
||||
) {
|
||||
data class Request(
|
||||
val url: String,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package io.github.openflocon.flocon.plugins.network.model
|
||||
|
||||
import java.util.regex.Pattern
|
||||
|
||||
data class MockNetworkResponse(
|
||||
val expectation: Expectation,
|
||||
val response: Response,
|
||||
) {
|
||||
data class Expectation(
|
||||
val urlPattern: String, // a regex
|
||||
val pattern: Pattern,
|
||||
val method: String, // can be get, post, put, ... or a wildcard *
|
||||
)
|
||||
|
||||
data class Response(
|
||||
val httpCode: Int,
|
||||
val body: String,
|
||||
val mediaType: String,
|
||||
val delay: Long,
|
||||
val headers: Map<String, String>,
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue