Skip to content

Commit

Permalink
Merge branch '2.6.x' into 2.7.x
Browse files Browse the repository at this point in the history
Closes gh-30780
  • Loading branch information
mhalbritter committed Apr 25, 2022
2 parents ce683c3 + 078104f commit 6eb3607
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Expand Up @@ -31,6 +31,7 @@
* Central class for interacting with SDKMAN's API.
*
* @author Madhura Bhave
* @author Moritz Halbritter
*/
@Component
public class SdkmanService {
Expand All @@ -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/"
+ "%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 final RestTemplate restTemplate;
Expand All @@ -66,7 +69,7 @@ public void publish(String version, boolean makeDefault) {
}

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"))
.header(CONSUMER_KEY_HEADER, this.properties.getConsumerKey())
.header(CONSUMER_TOKEN_HEADER, this.properties.getConsumerToken())
Expand Down Expand Up @@ -135,14 +138,21 @@ static class BroadcastRequest extends Request {

private final String hashtag = SPRING_BOOT;

BroadcastRequest(String version) {
private final String url;

BroadcastRequest(String version, String url) {
super(version);
this.url = url;
}

public String getHashtag() {
return this.hashtag;
}

public String getUrl() {
return url;
}

}

}
Expand Up @@ -44,9 +44,6 @@ class SdkmanServiceTests {
@Autowired
private SdkmanService service;

@Autowired
private SdkmanProperties properties;

@Autowired
private MockRestServiceServer server;

Expand All @@ -56,23 +53,23 @@ void tearDown() {
}

@Test
void publishWhenMakeDefaultTrue() throws Exception {
void publishWhenMakeDefaultTrue() {
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\"}");
setupExpectation("https://vendors.sdkman.io/default", "{\"candidate\": \"springboot\", \"version\": \"1.2.3\"}",
HttpMethod.PUT);
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.server.verify();
}

@Test
void publishWhenMakeDefaultFalse() throws Exception {
void publishWhenMakeDefaultFalse() {
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\"}");
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.server.verify();
}
Expand Down

0 comments on commit 6eb3607

Please sign in to comment.