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

application.StubLoaderEngine.kt Maven / Gradle / Ivy

There is a newer version: 2.0.37
Show newest version
package application

import io.specmatic.core.Feature
import io.specmatic.core.getConfigFilePath
import io.specmatic.core.loadSpecmaticConfigOrDefault
import io.specmatic.core.log.logger
import io.specmatic.core.utilities.ContractPathData
import io.specmatic.mock.ScenarioStub
import io.specmatic.stub.loadContractStubsFromFiles
import io.specmatic.stub.loadContractStubsFromImplicitPaths
import org.springframework.stereotype.Component
import java.io.File

@Component
class StubLoaderEngine {
    fun loadStubs(
        contractPathDataList: List,
        dataDirs: List,
        specmaticConfigPath: String? = null,
        strictMode: Boolean
    ): List>> {
        contractPathDataList.forEach { contractPath ->
            if(!File(contractPath.path).exists()) {
                logger.log("$contractPath does not exist.")
            }
        }

        val specmaticConfig = loadSpecmaticConfigOrDefault(specmaticConfigPath ?: getConfigFilePath())

        return when {
            dataDirs.isNotEmpty() -> {
                loadContractStubsFromFiles(contractPathDataList, dataDirs, specmaticConfig, strictMode)
            }
            else -> loadContractStubsFromImplicitPaths(contractPathDataList, specmaticConfig)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy