From e210ca226d42cf5168d86494c96351e4adc9b9fc Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Mon, 28 Mar 2016 11:43:46 +0200 Subject: [PATCH] Added tests for RunningStubs --- .../stubrunner/RunningStubsSpec.groovy | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 stub-runner/stub-runner/src/test/groovy/io/codearte/accurest/stubrunner/RunningStubsSpec.groovy diff --git a/stub-runner/stub-runner/src/test/groovy/io/codearte/accurest/stubrunner/RunningStubsSpec.groovy b/stub-runner/stub-runner/src/test/groovy/io/codearte/accurest/stubrunner/RunningStubsSpec.groovy new file mode 100644 index 0000000000..d9cf63516b --- /dev/null +++ b/stub-runner/stub-runner/src/test/groovy/io/codearte/accurest/stubrunner/RunningStubsSpec.groovy @@ -0,0 +1,61 @@ +package io.codearte.accurest.stubrunner + +import spock.lang.Specification + +/** + * @author Marcin Grzejszczak + */ +class RunningStubsSpec extends Specification { + RunningStubs runningStubs = new RunningStubs([(new StubConfiguration('a', 'b', 'c')) : 100]) + + def "should get port by group and artifact id"() { + expect: + runningStubs.getPort('a', 'b') == 100 + } + + def "should get port by artifact id"() { + expect: + runningStubs.getPort('b') == 100 + } + + def "should get port by group and artifact id in Ivy notation"() { + expect: + runningStubs.getPort('a:b') == 100 + } + + def "should get port by group, artifact id and classifier in Ivy notation"() { + expect: + runningStubs.getPort('a:b:c') == 100 + } + + def "should return null if no stub has been found"() { + expect: + runningStubs.getPort('missing artifact id') == null + } + + def "should find stub by group and artifact id"() { + expect: + runningStubs.isPresent('a', 'b') + } + + def "should find stub by artifact id"() { + expect: + runningStubs.isPresent('b') + } + + def "should find stub by group and artifact id in Ivy notation"() { + expect: + runningStubs.isPresent('a:b') + } + + def "should find stub by group, artifact id and classifier in Ivy notation"() { + expect: + runningStubs.isPresent('a:b:c') + } + + def "should return false if no stub has been found"() { + expect: + runningStubs.isPresent('missing artifact id') == false + } + +}