Trying to fix the build

This commit is contained in:
Marcin Grzejszczak
2017-05-30 15:36:29 +02:00
parent 84b0cc6478
commit 766f90363b

View File

@@ -18,9 +18,12 @@ package org.springframework.cloud.contract.stubrunner.provider.moco
import com.github.dreamhead.moco.bootstrap.arg.HttpArgs
import com.github.dreamhead.moco.runner.JsonRunner
import com.github.dreamhead.moco.runner.RunnerSetting
import groovy.util.logging.Slf4j
import org.springframework.cloud.contract.stubrunner.HttpServerStub
import org.springframework.util.SocketUtils
@Slf4j
class MocoHttpServerStub implements HttpServerStub {
private boolean started
@@ -62,8 +65,16 @@ class MocoHttpServerStub implements HttpServerStub {
@Override
HttpServerStub registerMappings(Collection<File> stubFiles) {
List<InputStream> streams = stubFiles.collect { it.newInputStream() }
this.runner = JsonRunner.newJsonRunnerWithStreams(streams,
List<RunnerSetting> settings = stubFiles.findAll { it.name.endsWith("json") }
.collect {
try {
return RunnerSetting.aRunnerSetting().withStream(it.newInputStream()).build()
} catch (Exception e) {
log.warn("Exception occurred while trying to parse file [{}]", it.name, e)
return null
}
}.findAll { it }
this.runner = JsonRunner.newJsonRunnerWithSetting(settings,
HttpArgs.httpArgs().withPort(this.port).build())
this.runner.run()
this.started = true