This commit is contained in:
Stephane Nicoll
2020-06-18 15:34:21 +02:00
parent 193293480d
commit 11c553ef6d
4 changed files with 93 additions and 53 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -69,11 +69,12 @@ class DefaultInitializrMetadataUpdateStrategyTests {
InitializrMetadata updatedMetadata = provider.update(metadata); InitializrMetadata updatedMetadata = provider.update(metadata);
assertThat(updatedMetadata.getBootVersions()).isNotNull(); assertThat(updatedMetadata.getBootVersions()).isNotNull();
List<DefaultMetadataElement> updatedBootVersions = updatedMetadata.getBootVersions().getContent(); List<DefaultMetadataElement> updatedBootVersions = updatedMetadata.getBootVersions().getContent();
assertThat(updatedBootVersions).hasSize(4); assertThat(updatedBootVersions).hasSize(5);
assertBootVersion(updatedBootVersions.get(0), "1.4.1 (SNAPSHOT)", false); assertBootVersion(updatedBootVersions.get(0), "2.5.0-M1", false);
assertBootVersion(updatedBootVersions.get(1), "1.4.0", true); assertBootVersion(updatedBootVersions.get(1), "2.4.1 (SNAPSHOT)", false);
assertBootVersion(updatedBootVersions.get(2), "1.3.8 (SNAPSHOT)", false); assertBootVersion(updatedBootVersions.get(2), "2.4.0", true);
assertBootVersion(updatedBootVersions.get(3), "1.3.7", false); assertBootVersion(updatedBootVersions.get(3), "2.3.8 (SNAPSHOT)", false);
assertBootVersion(updatedBootVersions.get(4), "2.3.7", false);
} }
@Test @Test
@@ -89,11 +90,12 @@ class DefaultInitializrMetadataUpdateStrategyTests {
InitializrMetadata updatedMetadata = provider.update(metadata); InitializrMetadata updatedMetadata = provider.update(metadata);
assertThat(updatedMetadata.getBootVersions()).isNotNull(); assertThat(updatedMetadata.getBootVersions()).isNotNull();
List<DefaultMetadataElement> updatedBootVersions = updatedMetadata.getBootVersions().getContent(); List<DefaultMetadataElement> updatedBootVersions = updatedMetadata.getBootVersions().getContent();
assertThat(updatedBootVersions).hasSize(4); assertThat(updatedBootVersions).hasSize(5);
assertBootVersion(updatedBootVersions.get(0), "1.3.1 (SNAPSHOT)", true); assertBootVersion(updatedBootVersions.get(0), "2.5.0-M1", true);
assertBootVersion(updatedBootVersions.get(1), "1.3.0", false); assertBootVersion(updatedBootVersions.get(1), "2.4.1 (SNAPSHOT)", false);
assertBootVersion(updatedBootVersions.get(2), "1.2.6 (SNAPSHOT)", false); assertBootVersion(updatedBootVersions.get(2), "2.4.0", false);
assertBootVersion(updatedBootVersions.get(3), "1.2.5", false); assertBootVersion(updatedBootVersions.get(3), "2.3.8 (SNAPSHOT)", false);
assertBootVersion(updatedBootVersions.get(4), "2.3.7", false);
} }
private static void assertBootVersion(DefaultMetadataElement actual, String name, boolean defaultVersion) { private static void assertBootVersion(DefaultMetadataElement actual, String name, boolean defaultVersion) {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package io.spring.initializr.web.support;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import io.spring.initializr.metadata.DefaultMetadataElement; import io.spring.initializr.metadata.DefaultMetadataElement;
@@ -57,19 +56,20 @@ class SpringBootMetadataReaderTests {
withSuccess(new ClassPathResource("metadata/sagan/spring-boot.json"), MediaType.APPLICATION_JSON)); withSuccess(new ClassPathResource("metadata/sagan/spring-boot.json"), MediaType.APPLICATION_JSON));
List<DefaultMetadataElement> versions = new SpringBootMetadataReader(this.objectMapper, this.restTemplate, List<DefaultMetadataElement> versions = new SpringBootMetadataReader(this.objectMapper, this.restTemplate,
this.metadata.getConfiguration().getEnv().getSpringBootMetadataUrl()).getBootVersions(); this.metadata.getConfiguration().getEnv().getSpringBootMetadataUrl()).getBootVersions();
assertThat(versions).as("spring boot versions should not be null").isNotNull(); assertThat(versions).hasSize(5);
AtomicBoolean defaultFound = new AtomicBoolean(false); assertSpringBootVersion(versions.get(0), "2.5.0-M1", "2.5.0-M1", false);
versions.forEach((it) -> { assertSpringBootVersion(versions.get(1), "2.4.1-SNAPSHOT", "2.4.1 (SNAPSHOT)", false);
assertThat(it.getId()).as("Id must be set").isNotNull(); assertSpringBootVersion(versions.get(2), "2.4.0", "2.4.0", true);
assertThat(it.getName()).as("Name must be set").isNotNull(); assertSpringBootVersion(versions.get(3), "2.3.8.BUILD-SNAPSHOT", "2.3.8 (SNAPSHOT)", false);
if (it.isDefault()) { assertSpringBootVersion(versions.get(4), "2.3.7.RELEASE", "2.3.7", false);
if (defaultFound.get()) {
throw new AssertionError("One default version was already found " + it.getId());
}
defaultFound.set(true);
}
});
this.server.verify(); this.server.verify();
} }
private void assertSpringBootVersion(DefaultMetadataElement actual, String id, String name,
boolean defaultVersion) {
assertThat(actual.getId()).isEqualTo(id);
assertThat(actual.getName()).isEqualTo(name);
assertThat(actual.isDefault()).isEqualTo(defaultVersion);
}
} }

View File

@@ -8,8 +8,27 @@
"projectReleases": [ "projectReleases": [
{ {
"releaseStatus": "SNAPSHOT", "releaseStatus": "SNAPSHOT",
"refDocUrl": "https://docs.spring.io/spring-boot/docs/1.3.1.BUILD-SNAPSHOT/reference/htmlsingle/", "refDocUrl": "https://docs.spring.io/spring-boot/docs/2.5.0-M1/reference/htmlsingle/",
"apiDocUrl": "https://docs.spring.io/spring-boot/docs/1.3.1.BUILD-SNAPSHOT/api/", "apiDocUrl": "https://docs.spring.io/spring-boot/docs/2.5.0-M1/api/",
"groupId": "org.springframework.boot",
"artifactId": "spring-boot",
"repository": {
"id": "spring-milestones",
"name": "Spring Milestones",
"url": "https://repo.spring.io/libs-milestone",
"snapshotsEnabled": false
},
"preRelease": true,
"generalAvailability": false,
"versionDisplayName": "2.5.0-M1",
"current": false,
"snapshot": false,
"version": "2.5.0-M1"
},
{
"releaseStatus": "SNAPSHOT",
"refDocUrl": "https://docs.spring.io/spring-boot/docs/2.4.1-SNAPSHOT/reference/htmlsingle/",
"apiDocUrl": "https://docs.spring.io/spring-boot/docs/2.4.1-SNAPSHOT/api/",
"groupId": "org.springframework.boot", "groupId": "org.springframework.boot",
"artifactId": "spring-boot", "artifactId": "spring-boot",
"repository": { "repository": {
@@ -20,29 +39,29 @@
}, },
"preRelease": false, "preRelease": false,
"generalAvailability": false, "generalAvailability": false,
"versionDisplayName": "1.3.1", "versionDisplayName": "2.4.1",
"current": false, "current": false,
"snapshot": true, "snapshot": true,
"version": "1.3.1.BUILD-SNAPSHOT" "version": "2.4.1-SNAPSHOT"
}, },
{ {
"releaseStatus": "GENERAL_AVAILABILITY", "releaseStatus": "GENERAL_AVAILABILITY",
"refDocUrl": "https://docs.spring.io/spring-boot/docs/1.3.0.RELEASE/reference/htmlsingle/", "refDocUrl": "https://docs.spring.io/spring-boot/docs/2.4.0/reference/htmlsingle/",
"apiDocUrl": "https://docs.spring.io/spring-boot/docs/1.3.0.RELEASE/api/", "apiDocUrl": "https://docs.spring.io/spring-boot/docs/2.4.0/api/",
"groupId": "org.springframework.boot", "groupId": "org.springframework.boot",
"artifactId": "spring-boot", "artifactId": "spring-boot",
"repository": null, "repository": null,
"preRelease": false, "preRelease": false,
"generalAvailability": true, "generalAvailability": true,
"versionDisplayName": "1.3.0", "versionDisplayName": "2.4.0",
"current": false, "current": false,
"snapshot": false, "snapshot": false,
"version": "1.3.0.RELEASE" "version": "2.4.0"
}, },
{ {
"releaseStatus": "SNAPSHOT", "releaseStatus": "SNAPSHOT",
"refDocUrl": "https://docs.spring.io/spring-boot/docs/1.2.6.BUILD-SNAPSHOT/reference/htmlsingle/", "refDocUrl": "https://docs.spring.io/spring-boot/docs/2.3.8.BUILD-SNAPSHOT/reference/htmlsingle/",
"apiDocUrl": "https://docs.spring.io/spring-boot/docs/1.2.6.BUILD-SNAPSHOT/api/", "apiDocUrl": "https://docs.spring.io/spring-boot/docs/2.3.8.BUILD-SNAPSHOT/api/",
"groupId": "org.springframework.boot", "groupId": "org.springframework.boot",
"artifactId": "spring-boot", "artifactId": "spring-boot",
"repository": { "repository": {
@@ -53,10 +72,10 @@
}, },
"preRelease": false, "preRelease": false,
"generalAvailability": false, "generalAvailability": false,
"versionDisplayName": "1.2.6", "versionDisplayName": "2.3.8",
"current": false, "current": false,
"snapshot": true, "snapshot": true,
"version": "1.2.6.BUILD-SNAPSHOT" "version": "2.3.8.BUILD-SNAPSHOT"
}, },
{ {
"releaseStatus": "GENERAL_AVAILABILITY", "releaseStatus": "GENERAL_AVAILABILITY",
@@ -67,10 +86,10 @@
"repository": null, "repository": null,
"preRelease": false, "preRelease": false,
"generalAvailability": true, "generalAvailability": true,
"versionDisplayName": "1.2.5", "versionDisplayName": "2.3.7",
"current": false, "current": false,
"snapshot": false, "snapshot": false,
"version": "1.2.5.RELEASE" "version": "2.3.7.RELEASE"
} }
], ],
"aggregator": false, "aggregator": false,

View File

@@ -8,8 +8,27 @@
"projectReleases": [ "projectReleases": [
{ {
"releaseStatus": "SNAPSHOT", "releaseStatus": "SNAPSHOT",
"refDocUrl": "https://docs.spring.io/spring-boot/docs/1.4.1.BUILD-SNAPSHOT/reference/htmlsingle/", "refDocUrl": "https://docs.spring.io/spring-boot/docs/2.5.0-M1/reference/htmlsingle/",
"apiDocUrl": "https://docs.spring.io/spring-boot/docs/1.4.1.BUILD-SNAPSHOT/api/", "apiDocUrl": "https://docs.spring.io/spring-boot/docs/2.5.0-M1/api/",
"groupId": "org.springframework.boot",
"artifactId": "spring-boot",
"repository": {
"id": "spring-milestones",
"name": "Spring Milestones",
"url": "https://repo.spring.io/libs-milestone",
"snapshotsEnabled": false
},
"preRelease": true,
"generalAvailability": false,
"versionDisplayName": "2.5.0-M1",
"current": false,
"snapshot": false,
"version": "2.5.0-M1"
},
{
"releaseStatus": "SNAPSHOT",
"refDocUrl": "https://docs.spring.io/spring-boot/docs/2.4.1-SNAPSHOT/reference/htmlsingle/",
"apiDocUrl": "https://docs.spring.io/spring-boot/docs/2.4.1-SNAPSHOT/api/",
"groupId": "org.springframework.boot", "groupId": "org.springframework.boot",
"artifactId": "spring-boot", "artifactId": "spring-boot",
"repository": { "repository": {
@@ -20,29 +39,29 @@
}, },
"preRelease": false, "preRelease": false,
"generalAvailability": false, "generalAvailability": false,
"versionDisplayName": "1.4.1", "versionDisplayName": "2.4.1",
"current": false, "current": false,
"snapshot": true, "snapshot": true,
"version": "1.4.1.BUILD-SNAPSHOT" "version": "2.4.1-SNAPSHOT"
}, },
{ {
"releaseStatus": "GENERAL_AVAILABILITY", "releaseStatus": "GENERAL_AVAILABILITY",
"refDocUrl": "https://docs.spring.io/spring-boot/docs/1.4.0.RELEASE/reference/htmlsingle/", "refDocUrl": "https://docs.spring.io/spring-boot/docs/2.4.0/reference/htmlsingle/",
"apiDocUrl": "https://docs.spring.io/spring-boot/docs/1.4.0.RELEASE/api/", "apiDocUrl": "https://docs.spring.io/spring-boot/docs/2.4.0/api/",
"groupId": "org.springframework.boot", "groupId": "org.springframework.boot",
"artifactId": "spring-boot", "artifactId": "spring-boot",
"repository": null, "repository": null,
"preRelease": false, "preRelease": false,
"generalAvailability": true, "generalAvailability": true,
"versionDisplayName": "1.4.0", "versionDisplayName": "2.4.0",
"current": true, "current": true,
"snapshot": false, "snapshot": false,
"version": "1.4.0.RELEASE" "version": "2.4.0"
}, },
{ {
"releaseStatus": "SNAPSHOT", "releaseStatus": "SNAPSHOT",
"refDocUrl": "https://docs.spring.io/spring-boot/docs/1.3.8.BUILD-SNAPSHOT/reference/htmlsingle/", "refDocUrl": "https://docs.spring.io/spring-boot/docs/2.3.8.BUILD-SNAPSHOT/reference/htmlsingle/",
"apiDocUrl": "https://docs.spring.io/spring-boot/docs/1.3.8.BUILD-SNAPSHOT/api/", "apiDocUrl": "https://docs.spring.io/spring-boot/docs/2.3.8.BUILD-SNAPSHOT/api/",
"groupId": "org.springframework.boot", "groupId": "org.springframework.boot",
"artifactId": "spring-boot", "artifactId": "spring-boot",
"repository": { "repository": {
@@ -53,10 +72,10 @@
}, },
"preRelease": false, "preRelease": false,
"generalAvailability": false, "generalAvailability": false,
"versionDisplayName": "1.3.8", "versionDisplayName": "2.3.8",
"current": false, "current": false,
"snapshot": true, "snapshot": true,
"version": "1.3.8.BUILD-SNAPSHOT" "version": "2.3.8.BUILD-SNAPSHOT"
}, },
{ {
"releaseStatus": "GENERAL_AVAILABILITY", "releaseStatus": "GENERAL_AVAILABILITY",
@@ -67,10 +86,10 @@
"repository": null, "repository": null,
"preRelease": false, "preRelease": false,
"generalAvailability": true, "generalAvailability": true,
"versionDisplayName": "1.3.7", "versionDisplayName": "2.3.7",
"current": false, "current": false,
"snapshot": false, "snapshot": false,
"version": "1.3.7.RELEASE" "version": "2.3.7.RELEASE"
} }
], ],
"aggregator": false, "aggregator": false,