Merge branch '2.6.x' into 2.7.x

Closes gh-30780
pull/30823/head
Moritz Halbritter 3 years ago
commit 6eb3607399

@ -31,6 +31,7 @@ import org.springframework.web.client.RestTemplate;
* Central class for interacting with SDKMAN's API. * Central class for interacting with SDKMAN's API.
* *
* @author Madhura Bhave * @author Madhura Bhave
* @author Moritz Halbritter
*/ */
@Component @Component
public class SdkmanService { public class SdkmanService {
@ -42,6 +43,8 @@ public class SdkmanService {
private static final String DOWNLOAD_URL = "https://repo.spring.io/simple/libs-release-local/org/springframework/boot/spring-boot-cli/" private static final String DOWNLOAD_URL = "https://repo.spring.io/simple/libs-release-local/org/springframework/boot/spring-boot-cli/"
+ "%s/spring-boot-cli-%s-bin.zip"; + "%s/spring-boot-cli-%s-bin.zip";
private static final String CHANGELOG_URL = "https://github.com/spring-projects/spring-boot/releases/tag/v%s";
private static final String SPRING_BOOT = "springboot"; private static final String SPRING_BOOT = "springboot";
private final RestTemplate restTemplate; private final RestTemplate restTemplate;
@ -66,7 +69,7 @@ public class SdkmanService {
} }
private void broadcast(String version) { private void broadcast(String version) {
BroadcastRequest broadcastRequest = new BroadcastRequest(version); BroadcastRequest broadcastRequest = new BroadcastRequest(version, String.format(CHANGELOG_URL, version));
RequestEntity<BroadcastRequest> broadcastEntity = RequestEntity.post(URI.create(SDKMAN_URL + "announce/struct")) RequestEntity<BroadcastRequest> broadcastEntity = RequestEntity.post(URI.create(SDKMAN_URL + "announce/struct"))
.header(CONSUMER_KEY_HEADER, this.properties.getConsumerKey()) .header(CONSUMER_KEY_HEADER, this.properties.getConsumerKey())
.header(CONSUMER_TOKEN_HEADER, this.properties.getConsumerToken()) .header(CONSUMER_TOKEN_HEADER, this.properties.getConsumerToken())
@ -135,14 +138,21 @@ public class SdkmanService {
private final String hashtag = SPRING_BOOT; private final String hashtag = SPRING_BOOT;
BroadcastRequest(String version) { private final String url;
BroadcastRequest(String version, String url) {
super(version); super(version);
this.url = url;
} }
public String getHashtag() { public String getHashtag() {
return this.hashtag; return this.hashtag;
} }
public String getUrl() {
return url;
}
} }
} }

@ -44,9 +44,6 @@ class SdkmanServiceTests {
@Autowired @Autowired
private SdkmanService service; private SdkmanService service;
@Autowired
private SdkmanProperties properties;
@Autowired @Autowired
private MockRestServiceServer server; private MockRestServiceServer server;
@ -56,23 +53,23 @@ class SdkmanServiceTests {
} }
@Test @Test
void publishWhenMakeDefaultTrue() throws Exception { void publishWhenMakeDefaultTrue() {
setupExpectation("https://vendors.sdkman.io/release", setupExpectation("https://vendors.sdkman.io/release",
"{\"candidate\": \"springboot\", \"version\": \"1.2.3\", \"url\": \"https://repo.spring.io/simple/libs-release-local/org/springframework/boot/spring-boot-cli/1.2.3/spring-boot-cli-1.2.3-bin.zip\"}"); "{\"candidate\": \"springboot\", \"version\": \"1.2.3\", \"url\": \"https://repo.spring.io/simple/libs-release-local/org/springframework/boot/spring-boot-cli/1.2.3/spring-boot-cli-1.2.3-bin.zip\"}");
setupExpectation("https://vendors.sdkman.io/default", "{\"candidate\": \"springboot\", \"version\": \"1.2.3\"}", setupExpectation("https://vendors.sdkman.io/default", "{\"candidate\": \"springboot\", \"version\": \"1.2.3\"}",
HttpMethod.PUT); HttpMethod.PUT);
setupExpectation("https://vendors.sdkman.io/announce/struct", setupExpectation("https://vendors.sdkman.io/announce/struct",
"{\"candidate\": \"springboot\", \"version\": \"1.2.3\", \"hashtag\": \"springboot\"}"); "{\"candidate\": \"springboot\", \"version\": \"1.2.3\", \"hashtag\": \"springboot\", \"url\": \"https://github.com/spring-projects/spring-boot/releases/tag/v1.2.3\"}");
this.service.publish("1.2.3", true); this.service.publish("1.2.3", true);
this.server.verify(); this.server.verify();
} }
@Test @Test
void publishWhenMakeDefaultFalse() throws Exception { void publishWhenMakeDefaultFalse() {
setupExpectation("https://vendors.sdkman.io/release", setupExpectation("https://vendors.sdkman.io/release",
"{\"candidate\": \"springboot\", \"version\": \"1.2.3\", \"url\": \"https://repo.spring.io/simple/libs-release-local/org/springframework/boot/spring-boot-cli/1.2.3/spring-boot-cli-1.2.3-bin.zip\"}"); "{\"candidate\": \"springboot\", \"version\": \"1.2.3\", \"url\": \"https://repo.spring.io/simple/libs-release-local/org/springframework/boot/spring-boot-cli/1.2.3/spring-boot-cli-1.2.3-bin.zip\"}");
setupExpectation("https://vendors.sdkman.io/announce/struct", setupExpectation("https://vendors.sdkman.io/announce/struct",
"{\"candidate\": \"springboot\", \"version\": \"1.2.3\", \"hashtag\": \"springboot\"}"); "{\"candidate\": \"springboot\", \"version\": \"1.2.3\", \"hashtag\": \"springboot\", \"url\": \"https://github.com/spring-projects/spring-boot/releases/tag/v1.2.3\"}");
this.service.publish("1.2.3", false); this.service.publish("1.2.3", false);
this.server.verify(); this.server.verify();
} }

Loading…
Cancel
Save