io.lsdconsulting.stub.model.ControllerModel.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-wiremock-stub-generator Show documentation
Show all versions of spring-wiremock-stub-generator Show documentation
A tool for generating Java based Wiremock stubs from Spring MVC controllers
package io.lsdconsulting.stub.model
import org.springframework.http.HttpMethod
data class Model(
val controllers: MutableMap = mutableMapOf(),
) {
fun getControllerModel(name: String): ControllerModel = controllers.getOrPut(name) {ControllerModel()}
}
data class ControllerModel(
var packageName: String? = null,
var stubFullyQualifiedName: String? = null,
var stubClassName: String? = null,
var rootResource: String? = null,
var responseStatus: Int? = null,
val resources: MutableMap = mutableMapOf(),
var containsDateTimeFormat: Boolean = false
) {
fun getResourceModel(name: String): ResourceModel = resources.getOrPut(name) {ResourceModel()}
}
data class ResourceModel(
var httpMethod: HttpMethod? = null,
var methodName: String? = null,
var responseType: String? = null,
var responseStatus: Int? = null,
var subResource: String? = null,
var urlHasPathVariable: Boolean = false,
var hasOptionalMultiValueRequestParams: Boolean = false,
val requestParameters: MutableMap = mutableMapOf(),
val pathVariables: MutableMap = mutableMapOf(),
var requestBody: ArgumentModel? = null,
var stubMethodArgumentList: MutableList = mutableListOf(),
var stubMethodArgumentListWithRequest: MutableList = mutableListOf(),
var stubMethodArgumentListForCustomResponse: MutableList = mutableListOf(),
var verifyMethodArgumentList: MutableList = mutableListOf(),
var verifyMethodArgumentListWithTimes: MutableList = mutableListOf(),
var verifyMethodArgumentListWithTimesWithoutBody: MutableList = mutableListOf(),
var verifyMethodArgumentListPathVariablesOnly: List = mutableListOf(),
var verifyStubCallArgumentList: List = mutableListOf(),
val requestHeaders: MutableMap = mutableMapOf(),
) {
fun getRequestParamModel(name: String): ArgumentModel = requestParameters.getOrPut(name) {ArgumentModel()}
fun getPathVariableModel(name: String): ArgumentModel = pathVariables.getOrPut(name) {ArgumentModel()}
fun getRequestHeaderModel(name: String): ArgumentModel = requestHeaders.getOrPut(name) {ArgumentModel()}
}
data class ArgumentModel(
var name: String? = null,
var headerName: String? = null,
var type: String? = null,
var iterable: Boolean = false,
var optional: Boolean = false,
var dateTimeFormatAnnotation: DateTimeFormatAnnotation? = null,
) {
}
data class DateTimeFormatAnnotation(
val iso: String?,
val fallbackPatterns: Array?,
val pattern: String?,
val style: String?,
val clazz: String?,
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as DateTimeFormatAnnotation
if (iso != other.iso) return false
if (!fallbackPatterns.contentEquals(other.fallbackPatterns)) return false
if (pattern != other.pattern) return false
if (style != other.style) return false
return true
}
override fun hashCode(): Int {
var result = iso.hashCode()
result = 31 * result + fallbackPatterns.contentHashCode()
result = 31 * result + pattern.hashCode()
result = 31 * result + style.hashCode()
return result
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy