Fixed invalid parsing of ids
without this change when someone has provided an empty value of port then a default classifier was set instead of picking the provided one fixes #176
This commit is contained in:
@@ -76,7 +76,7 @@ public class StubConfiguration {
|
||||
stubsGroupId = splitPath[0];
|
||||
stubsArtifactId = splitPath[1];
|
||||
stubsVersion = splitPath.length >= 3 ? splitPath[2] : DEFAULT_VERSION;
|
||||
stubsClassifier = splitPath.length == 4 ? splitPath[3] : defaultClassifier;
|
||||
stubsClassifier = splitPath.length >= 4 ? splitPath[3] : defaultClassifier;
|
||||
}
|
||||
return new String[] { stubsGroupId, stubsArtifactId, stubsVersion,
|
||||
stubsClassifier };
|
||||
|
||||
@@ -102,8 +102,7 @@ public class StubsParser {
|
||||
try {
|
||||
port = Integer.valueOf(splitEntry[splitEntry.length-1]);
|
||||
id = id.substring(0, id.lastIndexOf(":"));
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} catch (NumberFormatException e) {}
|
||||
return new StubSpecification(new StubConfiguration(id, defaultClassifier), port);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.contract.stubrunner
|
||||
|
||||
import spock.lang.Issue
|
||||
import spock.lang.Specification
|
||||
|
||||
class StubRunnerOptionsBuilderSpec extends Specification {
|
||||
@@ -81,4 +82,17 @@ class StubRunnerOptionsBuilderSpec extends Specification {
|
||||
then:
|
||||
options.getDependencies().toString() == '[foo:bar:+:xxx]'
|
||||
}
|
||||
|
||||
@Issue("#176")
|
||||
def shouldCreateDependenciesWithEmptyPort() {
|
||||
|
||||
given:
|
||||
builder.withStubs('groupId:artifactId:version:classifier:')
|
||||
|
||||
when:
|
||||
StubRunnerOptions options = builder.build()
|
||||
|
||||
then:
|
||||
options.getDependencies().toString() == '[groupId:artifactId:version:classifier]'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user