PT 173730396 - Initial implementation of generations validation
Includes parsing of spring boot projects from spring.io/api, as well as spring boot project generations from sample code, and relevant junits.
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.generations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.Generations;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.Link;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.Links;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.SpringProject;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.SpringProjects;
|
||||
|
||||
public class SpringProjectIndex {
|
||||
|
||||
private final SpringProjectsClient client;
|
||||
|
||||
public SpringProjectIndex(SpringProjectsClient client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public SpringProjects getProjects() throws Exception {
|
||||
return client.getSpringProjects();
|
||||
}
|
||||
|
||||
public Generations getGenerations(SpringProject project) throws Exception {
|
||||
if (project != null) {
|
||||
Links _links = project.get_links();
|
||||
if (_links != null) {
|
||||
Link genLink = _links.getGenerations();
|
||||
if (genLink != null) {
|
||||
return client.getGenerations(genLink.getHref());
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param projectSlug slug used by Spring projects metadata, for example
|
||||
* "spring-boot" for Spring Boot projects
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public SpringProject getProject(String projectSlug) throws Exception {
|
||||
SpringProjects springProjects = getProjects();
|
||||
List<SpringProject> projects = springProjects.getProjects();
|
||||
SpringProject prj = null;
|
||||
for (SpringProject project : projects) {
|
||||
if (project.getSlug().equals(projectSlug)) {
|
||||
prj = project;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return prj;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.generations;
|
||||
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.Generations;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.GenerationsEmbedded;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.JsonHalEmbedded;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.SpringProjects;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.SpringProjectsEmbedded;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
public class SpringProjectsClient {
|
||||
|
||||
private final String url;
|
||||
|
||||
public SpringProjectsClient(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public SpringProjects getSpringProjects() throws Exception {
|
||||
return getEmbedded(url, SpringProjectsEmbedded.class);
|
||||
}
|
||||
|
||||
public Generations getGenerations(String generationsUrl) throws Exception {
|
||||
return getEmbedded(generationsUrl, GenerationsEmbedded.class);
|
||||
}
|
||||
|
||||
private <T> T getEmbedded(String url, Class<? extends JsonHalEmbedded<T>> clazz) throws Exception {
|
||||
if (url != null) {
|
||||
JsonHalEmbedded<T> embedded = get(url, clazz);
|
||||
if (embedded != null) {
|
||||
return embedded.get_embedded();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private <T> T get(String url, Class<T> clazz) throws Exception {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
headers.setAccept(MediaType.parseMediaTypes("application/hal+json"));
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
HttpEntity<?> entity = new HttpEntity(headers);
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
ResponseEntity<T> response = restTemplate.exchange(url, HttpMethod.GET, entity, clazz);
|
||||
|
||||
return response.getBody();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
|
||||
public class Generation extends JsonHalLinks {
|
||||
|
||||
private String name;
|
||||
private String ossSupportEndDate;
|
||||
private String commercialSupportEndDate;
|
||||
private String initialReleaseDate;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getOssSupportEndDate() {
|
||||
return ossSupportEndDate;
|
||||
}
|
||||
|
||||
public void setOssSupportEndDate(String ossSupportEndDate) {
|
||||
this.ossSupportEndDate = ossSupportEndDate;
|
||||
}
|
||||
|
||||
public String getCommercialSupportEndDate() {
|
||||
return commercialSupportEndDate;
|
||||
}
|
||||
|
||||
public void setCommercialSupportEndDate(String commercialSupportEndDate) {
|
||||
this.commercialSupportEndDate = commercialSupportEndDate;
|
||||
}
|
||||
|
||||
public String getInitialReleaseDate() {
|
||||
return initialReleaseDate;
|
||||
}
|
||||
|
||||
public void setInitialReleaseDate(String initialReleaseDate) {
|
||||
this.initialReleaseDate = initialReleaseDate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Generations {
|
||||
|
||||
private List<Generation> generations;
|
||||
|
||||
public List<Generation> getGenerations() {
|
||||
return generations;
|
||||
}
|
||||
|
||||
public void setGenerations(List<Generation> generations) {
|
||||
this.generations = generations;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
|
||||
public class GenerationsEmbedded extends JsonHalLinks implements JsonHalEmbedded<Generations> {
|
||||
|
||||
|
||||
private Generations _embedded;
|
||||
|
||||
public Generations get_embedded() {
|
||||
return _embedded;
|
||||
}
|
||||
|
||||
public void set_embedded(Generations _embedded) {
|
||||
this._embedded = _embedded;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
|
||||
public interface JsonHalEmbedded<T> {
|
||||
|
||||
T get_embedded();
|
||||
|
||||
void set_embedded(T _embedded);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
|
||||
public class JsonHalLinks {
|
||||
|
||||
private Links _links;
|
||||
|
||||
public Links get_links() {
|
||||
return _links;
|
||||
}
|
||||
|
||||
public void set_links(Links _links) {
|
||||
this._links = _links;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class JsonHalParser {
|
||||
|
||||
public <T> T getEmbedded(String json, Class<? extends JsonHalEmbedded<T>> clazz) throws Exception {
|
||||
if (json != null) {
|
||||
Gson gson = new Gson();
|
||||
JsonHalEmbedded<T> embedded = gson.fromJson(json, clazz);
|
||||
return embedded.get_embedded();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
|
||||
public class Link {
|
||||
|
||||
private String href;
|
||||
|
||||
public void setHref(String href) {
|
||||
this.href = href;
|
||||
}
|
||||
|
||||
public String getHref() {
|
||||
return this.href;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
|
||||
public class Links {
|
||||
|
||||
private Link self;
|
||||
private Link releases;
|
||||
private Link generations;
|
||||
private Link parent;
|
||||
private Link project;
|
||||
|
||||
public Link getSelf() {
|
||||
return self;
|
||||
}
|
||||
|
||||
public void setSelf(Link self) {
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public Link getReleases() {
|
||||
return releases;
|
||||
}
|
||||
|
||||
public void setReleases(Link releases) {
|
||||
this.releases = releases;
|
||||
}
|
||||
|
||||
public Link getGenerations() {
|
||||
return generations;
|
||||
}
|
||||
|
||||
public void setGenerations(Link generations) {
|
||||
this.generations = generations;
|
||||
}
|
||||
|
||||
public Link getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(Link parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public Link getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Link project) {
|
||||
this.project = project;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
|
||||
public class SpringProject extends JsonHalLinks {
|
||||
|
||||
private String name;
|
||||
private String slug;
|
||||
private String status;
|
||||
private String repositoryUrl;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSlug() {
|
||||
return slug;
|
||||
}
|
||||
|
||||
public void setSlug(String slug) {
|
||||
this.slug = slug;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getRepositoryUrl() {
|
||||
return repositoryUrl;
|
||||
}
|
||||
|
||||
public void setRepositoryUrl(String repositoryUrl) {
|
||||
this.repositoryUrl = repositoryUrl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SpringProjects {
|
||||
private List<SpringProject> projects;
|
||||
|
||||
public List<SpringProject> getProjects() {
|
||||
return projects;
|
||||
}
|
||||
|
||||
public void setProjects(List<SpringProject> projects) {
|
||||
this.projects = projects;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.generations.json;
|
||||
|
||||
public class SpringProjectsEmbedded extends JsonHalLinks implements JsonHalEmbedded<SpringProjects> {
|
||||
|
||||
private SpringProjects _embedded;
|
||||
|
||||
public SpringProjects get_embedded() {
|
||||
return _embedded;
|
||||
}
|
||||
|
||||
public void set_embedded(SpringProjects _embedded) {
|
||||
this._embedded = _embedded;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2020 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* https://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.validation.test;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.SpringProjectIndex;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.SpringProjectsClient;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.Generation;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.Generations;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.GenerationsEmbedded;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.JsonHalParser;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.Link;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.SpringProject;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.SpringProjects;
|
||||
import org.springframework.ide.vscode.boot.validation.generations.json.SpringProjectsEmbedded;
|
||||
|
||||
public class ProjectGenerationsValidationTest {
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProjectsInfoFromSpringIo() throws Exception {
|
||||
String url = "https://spring.io/api/projects";
|
||||
SpringProjectsClient client = new SpringProjectsClient(url);
|
||||
SpringProjectIndex projectIndex = new SpringProjectIndex(client);
|
||||
|
||||
SpringProjects springProjects = projectIndex.getProjects();
|
||||
assertNotNull(springProjects);
|
||||
assertTrue(!springProjects.getProjects().isEmpty());
|
||||
|
||||
SpringProject project = projectIndex.getProject("spring-boot");
|
||||
assertNotNull(project);
|
||||
assertEquals("Spring Boot", project.getName());
|
||||
assertEquals("spring-boot", project.getSlug());
|
||||
|
||||
project = projectIndex.getProject("spring-integration");
|
||||
assertNotNull(project);
|
||||
assertEquals("Spring Integration", project.getName());
|
||||
assertEquals("spring-integration", project.getSlug());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenerationsFromSpringIo() throws Exception {
|
||||
String url = "https://spring.io/api/projects";
|
||||
SpringProjectsClient client = new SpringProjectsClient(url);
|
||||
SpringProjectIndex projectIndex = new SpringProjectIndex(client);
|
||||
|
||||
SpringProject project = projectIndex.getProject("spring-boot");
|
||||
assertNotNull(project);
|
||||
Link generationsUrl = project.get_links().getGenerations();
|
||||
assertNotNull(generationsUrl);
|
||||
assertEquals("https://spring.io/api/projects/spring-boot/generations", generationsUrl.getHref());
|
||||
|
||||
Generations generations = projectIndex.getGenerations(project);
|
||||
|
||||
// NOTE: at the moment Generations are not available from spring.io API. Enable
|
||||
// when they are
|
||||
// assertNotNull(generations);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenerationsFromSample() throws Exception {
|
||||
SpringProjectsClient client = getMockClient();
|
||||
|
||||
SpringProjectIndex projectIndex = new SpringProjectIndex(client);
|
||||
|
||||
SpringProject project = projectIndex.getProject("spring-boot");
|
||||
assertNotNull(project);
|
||||
|
||||
Generations generations = projectIndex.getGenerations(project);
|
||||
assertNotNull(generations);
|
||||
|
||||
List<Generation> genList = generations.getGenerations();
|
||||
|
||||
assertNotNull(genList);
|
||||
assertTrue(genList.size() > 0);
|
||||
|
||||
Generation generation = genList.get(0);
|
||||
assertEquals("2.1.x", generation.getName());
|
||||
assertEquals("2019-01-01", generation.getInitialReleaseDate());
|
||||
assertEquals("2020-01-01", generation.getOssSupportEndDate());
|
||||
assertEquals("2021-01-01", generation.getCommercialSupportEndDate());
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* Helper methods
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
protected SpringProjectsClient getMockClient() throws Exception {
|
||||
return new SpringProjectsClient(null) {
|
||||
|
||||
@Override
|
||||
public SpringProjects getSpringProjects() throws Exception {
|
||||
return getProjectsFromSampleJson();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Generations getGenerations(String generationsUrl) throws Exception {
|
||||
return getGenerationsFromSampleJson(generationsUrl);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected SpringProjects getProjectsFromSampleJson() throws Exception {
|
||||
JsonHalParser parser = new JsonHalParser();
|
||||
return parser.getEmbedded(SpringProjectsTestSamples.SPRING_PROJECTS_JSON_SAMPLE, SpringProjectsEmbedded.class);
|
||||
}
|
||||
|
||||
protected Generations getGenerationsFromSampleJson(String genUrl) throws Exception {
|
||||
String json = null;
|
||||
if ("https://spring.io/api/projects/spring-boot/generations".equals(genUrl)) {
|
||||
json = SpringProjectsTestSamples.SPRING_BOOT_PROJECT_GENERATIONS;
|
||||
}
|
||||
|
||||
if (json != null) {
|
||||
JsonHalParser parser = new JsonHalParser();
|
||||
return parser.getEmbedded(json, GenerationsEmbedded.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.springframework.ide.vscode.boot.validation.test;
|
||||
|
||||
public class SpringProjectsTestSamples {
|
||||
|
||||
public static final String SPRING_BOOT_PROJECT_GENERATIONS = "{\n" + " \"_embedded\" : {\n"
|
||||
+ " \"generations\" : [ {\n" + " \"name\" : \"2.1.x\",\n"
|
||||
+ " \"initialReleaseDate\" : \"2019-01-01\",\n" + " \"ossSupportEndDate\" : \"2020-01-01\",\n"
|
||||
+ " \"commercialSupportEndDate\" : \"2021-01-01\",\n" + " \"_links\" : {\n"
|
||||
+ " \"self\" : {\n"
|
||||
+ " \"href\" : \"https://spring.io/api/projects/spring-boot/generations/2.1.x\"\n" + " },\n"
|
||||
+ " \"project\" : {\n" + " \"href\" : \"https://spring.io/api/projects/spring-boot\"\n"
|
||||
+ " }\n" + " }\n" + " }, {\n" + " \"name\" : \"2.2.x\",\n"
|
||||
+ " \"initialReleaseDate\" : \"2020-01-01\",\n" + " \"ossSupportEndDate\" : \"2021-01-01\",\n"
|
||||
+ " \"commercialSupportEndDate\" : \"2022-01-01\",\n" + " \"_links\" : {\n"
|
||||
+ " \"self\" : {\n"
|
||||
+ " \"href\" : \"https://spring.io/api/projects/spring-boot/generations/2.2.x\"\n" + " },\n"
|
||||
+ " \"project\" : {\n" + " \"href\" : \"https://spring.io/api/projects/spring-boot\"\n"
|
||||
+ " }\n" + " }\n" + " } ]\n" + " },\n" + " \"_links\" : {\n" + " \"project\" : {\n"
|
||||
+ " \"href\" : \"https://spring.io/api/projects/spring-boot\"\n" + " }\n" + " }\n" + "}";
|
||||
|
||||
|
||||
public static final String SPRING_PROJECTS_JSON_SAMPLE = "{\n" + " \"_embedded\" : {\n"
|
||||
+ " \"projects\" : [ {\n" + " \"name\" : \"Spring Boot\",\n" + " \"slug\" : \"spring-boot\",\n"
|
||||
+ " \"repositoryUrl\" : \"https://github.com/spring-projects/spring-boot\",\n"
|
||||
+ " \"status\" : \"ACTIVE\",\n" + " \"_links\" : {\n" + " \"self\" : {\n"
|
||||
+ " \"href\" : \"https://spring.io/api/projects/spring-boot\"\n" + " },\n"
|
||||
+ " \"releases\" : {\n"
|
||||
+ " \"href\" : \"https://spring.io/api/projects/spring-boot/releases\"\n" + " },\n"
|
||||
+ " \"generations\" : {\n"
|
||||
+ " \"href\" : \"https://spring.io/api/projects/spring-boot/generations\"\n" + " }\n"
|
||||
+ " }\n" + " }, {\n" + " \"name\" : \"Spring Data\",\n" + " \"slug\" : \"spring-data\",\n"
|
||||
+ " \"repositoryUrl\" : \"https://github.com/spring-projects/spring-data\",\n"
|
||||
+ " \"status\" : \"ACTIVE\",\n" + " \"_links\" : {\n" + " \"self\" : {\n"
|
||||
+ " \"href\" : \"https://spring.io/api/projects/spring-data\"\n" + " },\n"
|
||||
+ " \"releases\" : {\n"
|
||||
+ " \"href\" : \"https://spring.io/api/projects/spring-data/releases\"\n" + " },\n"
|
||||
+ " \"generations\" : {\n"
|
||||
+ " \"href\" : \"https://spring.io/api/projects/spring-data/generations\"\n" + " }\n"
|
||||
+ " }\n" + " }, {\n" + " \"name\" : \"Spring Data Elasticsearch\",\n"
|
||||
+ " \"slug\" : \"spring-data-elasticsearch\",\n"
|
||||
+ " \"repositoryUrl\" : \"https://github.com/spring-projects/spring-data-elasticsearch\",\n"
|
||||
+ " \"status\" : \"ACTIVE\",\n" + " \"_links\" : {\n" + " \"self\" : {\n"
|
||||
+ " \"href\" : \"https://spring.io/api/projects/spring-data-elasticsearch\"\n" + " },\n"
|
||||
+ " \"releases\" : {\n"
|
||||
+ " \"href\" : \"https://spring.io/api/projects/spring-data-elasticsearch/releases\"\n"
|
||||
+ " },\n" + " \"generations\" : {\n"
|
||||
+ " \"href\" : \"https://spring.io/api/projects/spring-data-elasticsearch/generations\"\n"
|
||||
+ " },\n" + " \"parent\" : {\n"
|
||||
+ " \"href\" : \"https://spring.io/api/projects/spring-data\"\n" + " }\n" + " }\n"
|
||||
+ " } ]\n" + " }\n" + "}";
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user