use of com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration in project gocd by gocd.
the class JsonMessageHandler1_0Test method setUp.
@Before
public void setUp() throws Exception {
messageHandler = new JsonMessageHandler1_0();
repositoryConfiguration = new RepositoryConfiguration();
repositoryConfiguration.add(new PackageMaterialProperty("key-one", "value-one"));
repositoryConfiguration.add(new PackageMaterialProperty("key-two", "value-two"));
packageConfiguration = new PackageConfiguration();
packageConfiguration.add(new PackageMaterialProperty("key-three", "value-three"));
packageConfiguration.add(new PackageMaterialProperty("key-four", "value-four"));
}
use of com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration in project gocd by gocd.
the class JsonMessageHandler1_0 method responseMessageForPackageConfiguration.
@Override
public PackageConfiguration responseMessageForPackageConfiguration(String responseBody) {
try {
PackageConfiguration packageConfiguration = new PackageConfiguration();
Map<String, Map> configurations;
try {
configurations = parseResponseToMap(responseBody);
} catch (Exception e) {
throw new RuntimeException("Package configuration should be returned as a map");
}
if (configurations == null || configurations.isEmpty()) {
throw new RuntimeException("Empty response body");
}
for (String key : configurations.keySet()) {
if (isEmpty(key)) {
throw new RuntimeException("Package configuration key cannot be empty");
}
if (!(configurations.get(key) instanceof Map)) {
throw new RuntimeException(format("Package configuration properties for key '%s' should be represented as a Map", key));
}
packageConfiguration.add(toPackageMaterialProperty(key, configurations.get(key)));
}
return packageConfiguration;
} catch (RuntimeException e) {
throw new RuntimeException(format("Unable to de-serialize json response. %s", e.getMessage()));
}
}
Aggregations