problem: unable to run without default options
This commit is contained in:
@@ -201,7 +201,8 @@ class UpstreamsConfigReader {
|
||||
}
|
||||
|
||||
private fun <T> getList(mappingNode: MappingNode?, key: String): CollectionNode<T>? {
|
||||
return getValue(mappingNode, key, CollectionNode::class.java) as CollectionNode<T>
|
||||
val value = getValue(mappingNode, key, CollectionNode::class.java) ?: return null
|
||||
return value as CollectionNode<T>
|
||||
}
|
||||
|
||||
private fun getListOfString(mappingNode: MappingNode?, key: String): List<String>? {
|
||||
|
||||
@@ -136,4 +136,27 @@ class UpstreamsConfigReaderSpec extends Specification {
|
||||
"\${PASSWORD}" | "1a68f20154fc258fe4149c199ad8f281"
|
||||
}
|
||||
|
||||
def "Parse config without defaults"() {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("upstreams-no-defaults.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
then:
|
||||
act != null
|
||||
act.version == "v1"
|
||||
with(act.defaultOptions) {
|
||||
size() == 0
|
||||
}
|
||||
act.upstreams.size() == 1
|
||||
with(act.upstreams.get(0)) {
|
||||
id == "local"
|
||||
chain == "ethereum"
|
||||
connection instanceof UpstreamsConfig.EthereumConnection
|
||||
with((UpstreamsConfig.EthereumConnection)connection) {
|
||||
rpc != null
|
||||
rpc.url == new URI("http://localhost:8545")
|
||||
ws == null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
9
src/test/resources/upstreams-no-defaults.yaml
Normal file
9
src/test/resources/upstreams-no-defaults.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
version: v1
|
||||
|
||||
upstreams:
|
||||
- id: local
|
||||
chain: ethereum
|
||||
connection:
|
||||
ethereum:
|
||||
rpc:
|
||||
url: "http://localhost:8545"
|
||||
Reference in New Issue
Block a user