mirror of
https://gitee.com/dcren/initializr.git
synced 2026-02-26 05:32:58 +08:00
Format default platform version when serving metadata v2.1
See gh-1113
This commit is contained in:
committed by
Stephane Nicoll
parent
9cdddc5a66
commit
a202ce00ac
@@ -48,6 +48,7 @@ import org.springframework.util.StringUtils;
|
||||
* A {@link InitializrMetadataJsonMapper} handling the metadata format for v2.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Guillaume Gerbaud
|
||||
*/
|
||||
public class InitializrMetadataV2JsonMapper implements InitializrMetadataJsonMapper {
|
||||
|
||||
@@ -146,7 +147,10 @@ public class InitializrMetadataV2JsonMapper implements InitializrMetadataJsonMap
|
||||
single.put("type", capability.getType().getName());
|
||||
DefaultMetadataElement defaultType = capability.getDefault();
|
||||
if (defaultType != null) {
|
||||
single.put("default", defaultType.getId());
|
||||
ObjectNode defaultNode = valueMapper.apply(defaultType);
|
||||
String defaultValue = (defaultNode.get("id") != null) ? defaultNode.get("id").textValue()
|
||||
: defaultType.getId();
|
||||
single.put("default", defaultValue);
|
||||
}
|
||||
ArrayNode values = nodeFactory.arrayNode();
|
||||
values.addAll(capability.getContent().stream().map(valueMapper).collect(Collectors.toList()));
|
||||
|
||||
@@ -102,7 +102,10 @@ class InitializrMetadataV21JsonMapperTests {
|
||||
.addBootVersion("2.5.0-M2", false).addBootVersion("2.4.2", true).build();
|
||||
String json = this.jsonMapper.write(metadata, null);
|
||||
JsonNode result = objectMapper.readTree(json);
|
||||
JsonNode versions = result.get("bootVersion").get("values");
|
||||
JsonNode bootVersion = result.get("bootVersion");
|
||||
JsonNode defaultNode = bootVersion.get("default");
|
||||
assertThat(defaultNode.textValue()).isEqualTo("2.4.2.RELEASE");
|
||||
JsonNode versions = bootVersion.get("values");
|
||||
assertThat(versions).hasSize(3);
|
||||
assertVersionMetadata(versions.get(0), "2.5.0.BUILD-SNAPSHOT", "2.5.0-SNAPSHOT");
|
||||
assertVersionMetadata(versions.get(1), "2.5.0.M2", "2.5.0-M2");
|
||||
|
||||
Reference in New Issue
Block a user