From 11c553ef6d28baa0f338dc2352607b4f227301b7 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 18 Jun 2020 15:34:21 +0200 Subject: [PATCH] Polish --- ...InitializrMetadataUpdateStrategyTests.java | 24 +++++----- .../SpringBootMetadataReaderTests.java | 28 +++++------ .../sagan/spring-boot-no-default.json | 47 +++++++++++++------ .../resources/metadata/sagan/spring-boot.json | 47 +++++++++++++------ 4 files changed, 93 insertions(+), 53 deletions(-) diff --git a/initializr-web/src/test/java/io/spring/initializr/web/support/DefaultInitializrMetadataUpdateStrategyTests.java b/initializr-web/src/test/java/io/spring/initializr/web/support/DefaultInitializrMetadataUpdateStrategyTests.java index 677b95db..f9540938 100755 --- a/initializr-web/src/test/java/io/spring/initializr/web/support/DefaultInitializrMetadataUpdateStrategyTests.java +++ b/initializr-web/src/test/java/io/spring/initializr/web/support/DefaultInitializrMetadataUpdateStrategyTests.java @@ -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"); * you may not use this file except in compliance with the License. @@ -69,11 +69,12 @@ class DefaultInitializrMetadataUpdateStrategyTests { InitializrMetadata updatedMetadata = provider.update(metadata); assertThat(updatedMetadata.getBootVersions()).isNotNull(); List updatedBootVersions = updatedMetadata.getBootVersions().getContent(); - assertThat(updatedBootVersions).hasSize(4); - assertBootVersion(updatedBootVersions.get(0), "1.4.1 (SNAPSHOT)", false); - assertBootVersion(updatedBootVersions.get(1), "1.4.0", true); - assertBootVersion(updatedBootVersions.get(2), "1.3.8 (SNAPSHOT)", false); - assertBootVersion(updatedBootVersions.get(3), "1.3.7", false); + assertThat(updatedBootVersions).hasSize(5); + assertBootVersion(updatedBootVersions.get(0), "2.5.0-M1", false); + assertBootVersion(updatedBootVersions.get(1), "2.4.1 (SNAPSHOT)", false); + assertBootVersion(updatedBootVersions.get(2), "2.4.0", true); + assertBootVersion(updatedBootVersions.get(3), "2.3.8 (SNAPSHOT)", false); + assertBootVersion(updatedBootVersions.get(4), "2.3.7", false); } @Test @@ -89,11 +90,12 @@ class DefaultInitializrMetadataUpdateStrategyTests { InitializrMetadata updatedMetadata = provider.update(metadata); assertThat(updatedMetadata.getBootVersions()).isNotNull(); List updatedBootVersions = updatedMetadata.getBootVersions().getContent(); - assertThat(updatedBootVersions).hasSize(4); - assertBootVersion(updatedBootVersions.get(0), "1.3.1 (SNAPSHOT)", true); - assertBootVersion(updatedBootVersions.get(1), "1.3.0", false); - assertBootVersion(updatedBootVersions.get(2), "1.2.6 (SNAPSHOT)", false); - assertBootVersion(updatedBootVersions.get(3), "1.2.5", false); + assertThat(updatedBootVersions).hasSize(5); + assertBootVersion(updatedBootVersions.get(0), "2.5.0-M1", true); + assertBootVersion(updatedBootVersions.get(1), "2.4.1 (SNAPSHOT)", false); + assertBootVersion(updatedBootVersions.get(2), "2.4.0", 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) { diff --git a/initializr-web/src/test/java/io/spring/initializr/web/support/SpringBootMetadataReaderTests.java b/initializr-web/src/test/java/io/spring/initializr/web/support/SpringBootMetadataReaderTests.java index e4d9d3fa..83133b07 100755 --- a/initializr-web/src/test/java/io/spring/initializr/web/support/SpringBootMetadataReaderTests.java +++ b/initializr-web/src/test/java/io/spring/initializr/web/support/SpringBootMetadataReaderTests.java @@ -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"); * 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.util.List; -import java.util.concurrent.atomic.AtomicBoolean; import com.fasterxml.jackson.databind.ObjectMapper; import io.spring.initializr.metadata.DefaultMetadataElement; @@ -57,19 +56,20 @@ class SpringBootMetadataReaderTests { withSuccess(new ClassPathResource("metadata/sagan/spring-boot.json"), MediaType.APPLICATION_JSON)); List versions = new SpringBootMetadataReader(this.objectMapper, this.restTemplate, this.metadata.getConfiguration().getEnv().getSpringBootMetadataUrl()).getBootVersions(); - assertThat(versions).as("spring boot versions should not be null").isNotNull(); - AtomicBoolean defaultFound = new AtomicBoolean(false); - versions.forEach((it) -> { - assertThat(it.getId()).as("Id must be set").isNotNull(); - assertThat(it.getName()).as("Name must be set").isNotNull(); - if (it.isDefault()) { - if (defaultFound.get()) { - throw new AssertionError("One default version was already found " + it.getId()); - } - defaultFound.set(true); - } - }); + assertThat(versions).hasSize(5); + assertSpringBootVersion(versions.get(0), "2.5.0-M1", "2.5.0-M1", false); + assertSpringBootVersion(versions.get(1), "2.4.1-SNAPSHOT", "2.4.1 (SNAPSHOT)", false); + assertSpringBootVersion(versions.get(2), "2.4.0", "2.4.0", true); + assertSpringBootVersion(versions.get(3), "2.3.8.BUILD-SNAPSHOT", "2.3.8 (SNAPSHOT)", false); + assertSpringBootVersion(versions.get(4), "2.3.7.RELEASE", "2.3.7", false); 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); + } + } diff --git a/initializr-web/src/test/resources/metadata/sagan/spring-boot-no-default.json b/initializr-web/src/test/resources/metadata/sagan/spring-boot-no-default.json index 7c0e34c1..c02efbff 100644 --- a/initializr-web/src/test/resources/metadata/sagan/spring-boot-no-default.json +++ b/initializr-web/src/test/resources/metadata/sagan/spring-boot-no-default.json @@ -8,8 +8,27 @@ "projectReleases": [ { "releaseStatus": "SNAPSHOT", - "refDocUrl": "https://docs.spring.io/spring-boot/docs/1.3.1.BUILD-SNAPSHOT/reference/htmlsingle/", - "apiDocUrl": "https://docs.spring.io/spring-boot/docs/1.3.1.BUILD-SNAPSHOT/api/", + "refDocUrl": "https://docs.spring.io/spring-boot/docs/2.5.0-M1/reference/htmlsingle/", + "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", "artifactId": "spring-boot", "repository": { @@ -20,29 +39,29 @@ }, "preRelease": false, "generalAvailability": false, - "versionDisplayName": "1.3.1", + "versionDisplayName": "2.4.1", "current": false, "snapshot": true, - "version": "1.3.1.BUILD-SNAPSHOT" + "version": "2.4.1-SNAPSHOT" }, { "releaseStatus": "GENERAL_AVAILABILITY", - "refDocUrl": "https://docs.spring.io/spring-boot/docs/1.3.0.RELEASE/reference/htmlsingle/", - "apiDocUrl": "https://docs.spring.io/spring-boot/docs/1.3.0.RELEASE/api/", + "refDocUrl": "https://docs.spring.io/spring-boot/docs/2.4.0/reference/htmlsingle/", + "apiDocUrl": "https://docs.spring.io/spring-boot/docs/2.4.0/api/", "groupId": "org.springframework.boot", "artifactId": "spring-boot", "repository": null, "preRelease": false, "generalAvailability": true, - "versionDisplayName": "1.3.0", + "versionDisplayName": "2.4.0", "current": false, "snapshot": false, - "version": "1.3.0.RELEASE" + "version": "2.4.0" }, { "releaseStatus": "SNAPSHOT", - "refDocUrl": "https://docs.spring.io/spring-boot/docs/1.2.6.BUILD-SNAPSHOT/reference/htmlsingle/", - "apiDocUrl": "https://docs.spring.io/spring-boot/docs/1.2.6.BUILD-SNAPSHOT/api/", + "refDocUrl": "https://docs.spring.io/spring-boot/docs/2.3.8.BUILD-SNAPSHOT/reference/htmlsingle/", + "apiDocUrl": "https://docs.spring.io/spring-boot/docs/2.3.8.BUILD-SNAPSHOT/api/", "groupId": "org.springframework.boot", "artifactId": "spring-boot", "repository": { @@ -53,10 +72,10 @@ }, "preRelease": false, "generalAvailability": false, - "versionDisplayName": "1.2.6", + "versionDisplayName": "2.3.8", "current": false, "snapshot": true, - "version": "1.2.6.BUILD-SNAPSHOT" + "version": "2.3.8.BUILD-SNAPSHOT" }, { "releaseStatus": "GENERAL_AVAILABILITY", @@ -67,10 +86,10 @@ "repository": null, "preRelease": false, "generalAvailability": true, - "versionDisplayName": "1.2.5", + "versionDisplayName": "2.3.7", "current": false, "snapshot": false, - "version": "1.2.5.RELEASE" + "version": "2.3.7.RELEASE" } ], "aggregator": false, diff --git a/initializr-web/src/test/resources/metadata/sagan/spring-boot.json b/initializr-web/src/test/resources/metadata/sagan/spring-boot.json index e0b6c06d..06e616f4 100644 --- a/initializr-web/src/test/resources/metadata/sagan/spring-boot.json +++ b/initializr-web/src/test/resources/metadata/sagan/spring-boot.json @@ -8,8 +8,27 @@ "projectReleases": [ { "releaseStatus": "SNAPSHOT", - "refDocUrl": "https://docs.spring.io/spring-boot/docs/1.4.1.BUILD-SNAPSHOT/reference/htmlsingle/", - "apiDocUrl": "https://docs.spring.io/spring-boot/docs/1.4.1.BUILD-SNAPSHOT/api/", + "refDocUrl": "https://docs.spring.io/spring-boot/docs/2.5.0-M1/reference/htmlsingle/", + "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", "artifactId": "spring-boot", "repository": { @@ -20,29 +39,29 @@ }, "preRelease": false, "generalAvailability": false, - "versionDisplayName": "1.4.1", + "versionDisplayName": "2.4.1", "current": false, "snapshot": true, - "version": "1.4.1.BUILD-SNAPSHOT" + "version": "2.4.1-SNAPSHOT" }, { "releaseStatus": "GENERAL_AVAILABILITY", - "refDocUrl": "https://docs.spring.io/spring-boot/docs/1.4.0.RELEASE/reference/htmlsingle/", - "apiDocUrl": "https://docs.spring.io/spring-boot/docs/1.4.0.RELEASE/api/", + "refDocUrl": "https://docs.spring.io/spring-boot/docs/2.4.0/reference/htmlsingle/", + "apiDocUrl": "https://docs.spring.io/spring-boot/docs/2.4.0/api/", "groupId": "org.springframework.boot", "artifactId": "spring-boot", "repository": null, "preRelease": false, "generalAvailability": true, - "versionDisplayName": "1.4.0", + "versionDisplayName": "2.4.0", "current": true, "snapshot": false, - "version": "1.4.0.RELEASE" + "version": "2.4.0" }, { "releaseStatus": "SNAPSHOT", - "refDocUrl": "https://docs.spring.io/spring-boot/docs/1.3.8.BUILD-SNAPSHOT/reference/htmlsingle/", - "apiDocUrl": "https://docs.spring.io/spring-boot/docs/1.3.8.BUILD-SNAPSHOT/api/", + "refDocUrl": "https://docs.spring.io/spring-boot/docs/2.3.8.BUILD-SNAPSHOT/reference/htmlsingle/", + "apiDocUrl": "https://docs.spring.io/spring-boot/docs/2.3.8.BUILD-SNAPSHOT/api/", "groupId": "org.springframework.boot", "artifactId": "spring-boot", "repository": { @@ -53,10 +72,10 @@ }, "preRelease": false, "generalAvailability": false, - "versionDisplayName": "1.3.8", + "versionDisplayName": "2.3.8", "current": false, "snapshot": true, - "version": "1.3.8.BUILD-SNAPSHOT" + "version": "2.3.8.BUILD-SNAPSHOT" }, { "releaseStatus": "GENERAL_AVAILABILITY", @@ -67,10 +86,10 @@ "repository": null, "preRelease": false, "generalAvailability": true, - "versionDisplayName": "1.3.7", + "versionDisplayName": "2.3.7", "current": false, "snapshot": false, - "version": "1.3.7.RELEASE" + "version": "2.3.7.RELEASE" } ], "aggregator": false,