Apply eclipse formatting rules
Apply eclipse formatting rules to b2fe2dd9
.
See gh-1751
This commit is contained in:
parent
8e16dfc951
commit
b89e5e0ab7
|
@ -40,7 +40,8 @@ public class DefaultCommandFactory implements CommandFactory {
|
|||
|
||||
private static final List<Command> DEFAULT_COMMANDS = Arrays.<Command> asList(
|
||||
new VersionCommand(), new RunCommand(), new TestCommand(), new GrabCommand(),
|
||||
new JarCommand(), new InstallCommand(), new UninstallCommand(), new InitCommand());
|
||||
new JarCommand(), new InstallCommand(), new UninstallCommand(),
|
||||
new InitCommand());
|
||||
|
||||
@Override
|
||||
public Collection<Command> getCommands() {
|
||||
|
|
|
@ -31,7 +31,7 @@ class Dependency {
|
|||
private String description;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
|
@ -39,7 +39,7 @@ class Dependency {
|
|||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
|
@ -47,10 +47,11 @@ class Dependency {
|
|||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.springframework.boot.cli.command.init;
|
||||
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.OptionParsingCommand;
|
||||
|
||||
|
@ -30,7 +29,8 @@ import org.springframework.boot.cli.command.OptionParsingCommand;
|
|||
public class InitCommand extends OptionParsingCommand {
|
||||
|
||||
InitCommand(InitCommandOptionHandler handler) {
|
||||
super("init", "Initialize a new project structure using Spring Initializr", handler);
|
||||
super("init", "Initialize a new project structure from Spring Initializr",
|
||||
handler);
|
||||
}
|
||||
|
||||
public InitCommand() {
|
||||
|
|
|
@ -27,8 +27,8 @@ import java.util.zip.ZipInputStream;
|
|||
|
||||
import joptsimple.OptionSet;
|
||||
import joptsimple.OptionSpec;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.springframework.boot.cli.command.options.OptionHandler;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
import org.springframework.boot.cli.util.Log;
|
||||
|
@ -78,46 +78,61 @@ public class InitCommandOptionHandler extends OptionHandler {
|
|||
|
||||
@Override
|
||||
protected void options() {
|
||||
this.target = option(Arrays.asList("target"),
|
||||
"URL of the service to use").withRequiredArg().defaultsTo(ProjectGenerationRequest.DEFAULT_SERVICE_URL);
|
||||
this.listMetadata = option(Arrays.asList("list", "l"), "List the capabilities of the service. Use it to " +
|
||||
"discover the dependencies and the types that are available.");
|
||||
this.target = option(Arrays.asList("target"), "URL of the service to use")
|
||||
.withRequiredArg().defaultsTo(
|
||||
ProjectGenerationRequest.DEFAULT_SERVICE_URL);
|
||||
this.listMetadata = option(Arrays.asList("list", "l"),
|
||||
"List the capabilities of the service. Use it to "
|
||||
+ "discover the dependencies and the types that are available.");
|
||||
|
||||
// Project generation settings
|
||||
this.bootVersion = option(Arrays.asList("boot-version", "bv"),
|
||||
"Spring Boot version to use (e.g. 1.2.0.RELEASE)").withRequiredArg();
|
||||
this.dependencies = option(Arrays.asList("dependencies", "d"),
|
||||
"Comma separated list of dependencies to include in the generated project").withRequiredArg();
|
||||
"Comma separated list of dependencies to include in the generated project")
|
||||
.withRequiredArg();
|
||||
this.javaVersion = option(Arrays.asList("java-version", "jv"),
|
||||
"Java version to use (e.g. 1.8)").withRequiredArg();
|
||||
this.packaging = option(Arrays.asList("packaging", "p"), "Packaging type to use (e.g. jar)").withRequiredArg();
|
||||
this.packaging = option(Arrays.asList("packaging", "p"),
|
||||
"Packaging type to use (e.g. jar)").withRequiredArg();
|
||||
|
||||
this.build = option("build", "The build system to use (e.g. maven, gradle). To be used alongside " +
|
||||
"--format to uniquely identify one type that is supported by the service. " +
|
||||
"Use --type in case of conflict").withRequiredArg().defaultsTo("maven");
|
||||
this.format = option("format", "The format of the generated content (e.g. build for a build file, " +
|
||||
"project for a project archive). To be used alongside --build to uniquely identify one type " +
|
||||
"that is supported by the service. Use --type in case of conflict")
|
||||
this.build = option(
|
||||
"build",
|
||||
"The build system to use (e.g. maven, gradle). To be used alongside "
|
||||
+ "--format to uniquely identify one type that is supported by the service. "
|
||||
+ "Use --type in case of conflict").withRequiredArg().defaultsTo(
|
||||
"maven");
|
||||
this.format = option(
|
||||
"format",
|
||||
"The format of the generated content (e.g. build for a build file, "
|
||||
+ "project for a project archive). To be used alongside --build to uniquely identify one type "
|
||||
+ "that is supported by the service. Use --type in case of conflict")
|
||||
.withRequiredArg().defaultsTo("project");
|
||||
this.type = option(Arrays.asList("type", "t"), "The project type to use. Not normally needed if you " +
|
||||
"use --build and/or --format. Check the capabilities of the service (--list) for " +
|
||||
"more details.").withRequiredArg();
|
||||
this.type = option(
|
||||
Arrays.asList("type", "t"),
|
||||
"The project type to use. Not normally needed if you "
|
||||
+ "use --build and/or --format. Check the capabilities of the service (--list) for "
|
||||
+ "more details.").withRequiredArg();
|
||||
|
||||
// Others
|
||||
this.extract = option(Arrays.asList("extract", "x"), "Extract the project archive");
|
||||
this.force = option(Arrays.asList("force", "f"), "Force overwrite of existing files");
|
||||
this.output = option(Arrays.asList("output", "o"),
|
||||
"Location of the generated project. Can be an absolute or a relative reference and " +
|
||||
"should refer to a directory when --extract is used.").withRequiredArg();
|
||||
this.extract = option(Arrays.asList("extract", "x"),
|
||||
"Extract the project archive");
|
||||
this.force = option(Arrays.asList("force", "f"),
|
||||
"Force overwrite of existing files");
|
||||
this.output = option(
|
||||
Arrays.asList("output", "o"),
|
||||
"Location of the generated project. Can be an absolute or a relative reference and "
|
||||
+ "should refer to a directory when --extract is used.")
|
||||
.withRequiredArg();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExitStatus run(OptionSet options) throws Exception {
|
||||
if (options.has(listMetadata)) {
|
||||
return listServiceCapabilities(options, httpClient);
|
||||
if (options.has(this.listMetadata)) {
|
||||
return listServiceCapabilities(options, this.httpClient);
|
||||
}
|
||||
else {
|
||||
return generateProject(options, httpClient);
|
||||
return generateProject(options, this.httpClient);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +166,8 @@ public class InitCommandOptionHandler extends OptionHandler {
|
|||
return request;
|
||||
}
|
||||
|
||||
protected ExitStatus listServiceCapabilities(OptionSet options, CloseableHttpClient httpClient) throws IOException {
|
||||
protected ExitStatus listServiceCapabilities(OptionSet options,
|
||||
CloseableHttpClient httpClient) throws IOException {
|
||||
ListMetadataCommand command = new ListMetadataCommand(httpClient);
|
||||
Log.info(command.generateReport(determineServiceUrl(options)));
|
||||
return ExitStatus.OK;
|
||||
|
@ -161,19 +177,22 @@ public class InitCommandOptionHandler extends OptionHandler {
|
|||
ProjectGenerationRequest request = createProjectGenerationRequest(options);
|
||||
boolean forceValue = options.has(this.force);
|
||||
try {
|
||||
ProjectGenerationResponse entity = new InitializrServiceHttpInvoker(httpClient).generate(request);
|
||||
ProjectGenerationResponse entity = new InitializrServiceHttpInvoker(
|
||||
httpClient).generate(request);
|
||||
if (options.has(this.extract)) {
|
||||
if (isZipArchive(entity)) {
|
||||
return extractProject(entity, options.valueOf(this.output), forceValue);
|
||||
return extractProject(entity, options.valueOf(this.output),
|
||||
forceValue);
|
||||
}
|
||||
else {
|
||||
Log.info("Could not extract '" + entity.getContentType() + "'");
|
||||
}
|
||||
}
|
||||
String outputFileName = entity.getFileName() != null ? entity.getFileName() : options.valueOf(this.output);
|
||||
String outputFileName = entity.getFileName() != null ? entity.getFileName()
|
||||
: options.valueOf(this.output);
|
||||
if (outputFileName == null) {
|
||||
Log.error("Could not save the project, the server did not set a preferred " +
|
||||
"file name. Use --output to specify the output location for the project.");
|
||||
Log.error("Could not save the project, the server did not set a preferred "
|
||||
+ "file name. Use --output to specify the output location for the project.");
|
||||
return ExitStatus.ERROR;
|
||||
}
|
||||
return writeProject(entity, outputFileName, forceValue);
|
||||
|
@ -192,8 +211,8 @@ public class InitCommandOptionHandler extends OptionHandler {
|
|||
return options.valueOf(this.target);
|
||||
}
|
||||
|
||||
private ExitStatus writeProject(ProjectGenerationResponse entity, String outputFileName, boolean overwrite)
|
||||
throws IOException {
|
||||
private ExitStatus writeProject(ProjectGenerationResponse entity,
|
||||
String outputFileName, boolean overwrite) throws IOException {
|
||||
|
||||
File f = new File(outputFileName);
|
||||
if (f.exists()) {
|
||||
|
@ -204,8 +223,9 @@ public class InitCommandOptionHandler extends OptionHandler {
|
|||
}
|
||||
}
|
||||
else {
|
||||
Log.error("File '" + f.getName() + "' already exists. Use --force if you want to " +
|
||||
"overwrite or --output to specify an alternate location.");
|
||||
Log.error("File '" + f.getName()
|
||||
+ "' already exists. Use --force if you want to "
|
||||
+ "overwrite or --output to specify an alternate location.");
|
||||
return ExitStatus.ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -232,12 +252,15 @@ public class InitCommandOptionHandler extends OptionHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private ExitStatus extractProject(ProjectGenerationResponse entity, String outputValue, boolean overwrite) throws IOException {
|
||||
File output = outputValue != null ? new File(outputValue) : new File(System.getProperty("user.dir"));
|
||||
private ExitStatus extractProject(ProjectGenerationResponse entity,
|
||||
String outputValue, boolean overwrite) throws IOException {
|
||||
File output = outputValue != null ? new File(outputValue) : new File(
|
||||
System.getProperty("user.dir"));
|
||||
if (!output.exists()) {
|
||||
output.mkdirs();
|
||||
}
|
||||
ZipInputStream zipIn = new ZipInputStream(new ByteArrayInputStream(entity.getContent()));
|
||||
ZipInputStream zipIn = new ZipInputStream(new ByteArrayInputStream(
|
||||
entity.getContent()));
|
||||
try {
|
||||
ZipEntry entry = zipIn.getNextEntry();
|
||||
while (entry != null) {
|
||||
|
@ -245,8 +268,10 @@ public class InitCommandOptionHandler extends OptionHandler {
|
|||
if (f.exists() && !overwrite) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(f.isDirectory() ? "Directory" : "File")
|
||||
.append(" '").append(f.getName()).append("' already exists. Use --force if you want to " +
|
||||
"overwrite or --output to specify an alternate location.");
|
||||
.append(" '")
|
||||
.append(f.getName())
|
||||
.append("' already exists. Use --force if you want to "
|
||||
+ "overwrite or --output to specify an alternate location.");
|
||||
Log.error(sb.toString());
|
||||
return ExitStatus.ERROR;
|
||||
}
|
||||
|
@ -268,7 +293,8 @@ public class InitCommandOptionHandler extends OptionHandler {
|
|||
}
|
||||
|
||||
private void extractZipEntry(ZipInputStream in, File outputFile) throws IOException {
|
||||
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile));
|
||||
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(
|
||||
outputFile));
|
||||
try {
|
||||
StreamUtils.copy(in, out);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|||
import org.apache.http.message.BasicHeader;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import org.springframework.boot.cli.util.Log;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
@ -57,7 +56,8 @@ class InitializrServiceHttpInvoker {
|
|||
* Generate a project based on the specified {@link ProjectGenerationRequest}
|
||||
* @return an entity defining the project
|
||||
*/
|
||||
ProjectGenerationResponse generate(ProjectGenerationRequest request) throws IOException {
|
||||
ProjectGenerationResponse generate(ProjectGenerationRequest request)
|
||||
throws IOException {
|
||||
Log.info("Using service at " + request.getServiceUrl());
|
||||
InitializrServiceMetadata metadata = loadMetadata(request.getServiceUrl());
|
||||
URI url = request.generateUrl(metadata);
|
||||
|
@ -65,7 +65,8 @@ class InitializrServiceHttpInvoker {
|
|||
|
||||
HttpEntity httpEntity = httpResponse.getEntity();
|
||||
if (httpEntity == null) {
|
||||
throw new ProjectGenerationException("No content received from server using '" + url + "'");
|
||||
throw new ProjectGenerationException(
|
||||
"No content received from server using '" + url + "'");
|
||||
}
|
||||
if (httpResponse.getStatusLine().getStatusCode() != 200) {
|
||||
throw buildProjectGenerationException(request.getServiceUrl(), httpResponse);
|
||||
|
@ -79,23 +80,26 @@ class InitializrServiceHttpInvoker {
|
|||
InitializrServiceMetadata loadMetadata(String serviceUrl) throws IOException {
|
||||
CloseableHttpResponse httpResponse = executeInitializrMetadataRetrieval(serviceUrl);
|
||||
if (httpResponse.getEntity() == null) {
|
||||
throw new ProjectGenerationException("No content received from server using '" + serviceUrl + "'");
|
||||
throw new ProjectGenerationException(
|
||||
"No content received from server using '" + serviceUrl + "'");
|
||||
}
|
||||
if (httpResponse.getStatusLine().getStatusCode() != 200) {
|
||||
throw buildProjectGenerationException(serviceUrl, httpResponse);
|
||||
}
|
||||
try {
|
||||
HttpEntity httpEntity = httpResponse.getEntity();
|
||||
JSONObject root = getContentAsJson(getContent(httpEntity), getContentType(httpEntity));
|
||||
JSONObject root = getContentAsJson(getContent(httpEntity),
|
||||
getContentType(httpEntity));
|
||||
return new InitializrServiceMetadata(root);
|
||||
}
|
||||
catch (JSONException e) {
|
||||
throw new ProjectGenerationException("Invalid content received from server (" + e.getMessage() + ")");
|
||||
throw new ProjectGenerationException("Invalid content received from server ("
|
||||
+ e.getMessage() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
private ProjectGenerationResponse createResponse(CloseableHttpResponse httpResponse, HttpEntity httpEntity)
|
||||
throws IOException {
|
||||
private ProjectGenerationResponse createResponse(CloseableHttpResponse httpResponse,
|
||||
HttpEntity httpEntity) throws IOException {
|
||||
ProjectGenerationResponse response = new ProjectGenerationResponse();
|
||||
ContentType contentType = ContentType.getOrDefault(httpEntity);
|
||||
response.setContentType(contentType);
|
||||
|
@ -108,7 +112,8 @@ class InitializrServiceHttpInvoker {
|
|||
in.close();
|
||||
}
|
||||
|
||||
String detectedFileName = extractFileName(httpResponse.getFirstHeader("Content-Disposition"));
|
||||
String detectedFileName = extractFileName(httpResponse
|
||||
.getFirstHeader("Content-Disposition"));
|
||||
if (detectedFileName != null) {
|
||||
response.setFileName(detectedFileName);
|
||||
}
|
||||
|
@ -124,8 +129,8 @@ class InitializrServiceHttpInvoker {
|
|||
return this.httpClient.execute(get);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new ProjectGenerationException(
|
||||
"Failed to invoke server at '" + url + "' (" + e.getMessage() + ")");
|
||||
throw new ProjectGenerationException("Failed to invoke server at '" + url
|
||||
+ "' (" + e.getMessage() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,11 +145,11 @@ class InitializrServiceHttpInvoker {
|
|||
}
|
||||
catch (IOException e) {
|
||||
throw new ProjectGenerationException(
|
||||
"Failed to retrieve metadata from service at '" + serviceUrl + "' (" + e.getMessage() + ")");
|
||||
"Failed to retrieve metadata from service at '" + serviceUrl + "' ("
|
||||
+ e.getMessage() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private byte[] getContent(HttpEntity httpEntity) throws IOException {
|
||||
InputStream in = httpEntity.getContent();
|
||||
try {
|
||||
|
@ -160,12 +165,14 @@ class InitializrServiceHttpInvoker {
|
|||
}
|
||||
|
||||
private JSONObject getContentAsJson(byte[] content, ContentType contentType) {
|
||||
Charset charset = contentType.getCharset() != null ? contentType.getCharset() : Charset.forName("UTF-8");
|
||||
Charset charset = contentType.getCharset() != null ? contentType.getCharset()
|
||||
: Charset.forName("UTF-8");
|
||||
String data = new String(content, charset);
|
||||
return new JSONObject(data);
|
||||
}
|
||||
|
||||
private ProjectGenerationException buildProjectGenerationException(String url, CloseableHttpResponse httpResponse) {
|
||||
private ProjectGenerationException buildProjectGenerationException(String url,
|
||||
CloseableHttpResponse httpResponse) {
|
||||
StringBuilder sb = new StringBuilder("Project generation failed using '");
|
||||
sb.append(url).append("' - service returned ")
|
||||
.append(httpResponse.getStatusLine().getReasonPhrase());
|
||||
|
@ -174,7 +181,9 @@ class InitializrServiceHttpInvoker {
|
|||
sb.append(": '").append(error).append("'");
|
||||
}
|
||||
else {
|
||||
sb.append(" (unexpected ").append(httpResponse.getStatusLine().getStatusCode()).append(" error)");
|
||||
sb.append(" (unexpected ")
|
||||
.append(httpResponse.getStatusLine().getStatusCode())
|
||||
.append(" error)");
|
||||
}
|
||||
throw new ProjectGenerationException(sb.toString());
|
||||
}
|
||||
|
@ -184,7 +193,8 @@ class InitializrServiceHttpInvoker {
|
|||
return null;
|
||||
}
|
||||
try {
|
||||
JSONObject error = getContentAsJson(getContent(entity), getContentType(entity));
|
||||
JSONObject error = getContentAsJson(getContent(entity),
|
||||
getContentType(entity));
|
||||
if (error.has("message")) {
|
||||
return error.getString("message");
|
||||
}
|
||||
|
|
|
@ -50,14 +50,12 @@ class InitializrServiceMetadata {
|
|||
|
||||
private static final String DEFAULT_ATTRIBUTE = "default";
|
||||
|
||||
|
||||
private final Map<String, Dependency> dependencies;
|
||||
|
||||
private final MetadataHolder<String, ProjectType> projectTypes;
|
||||
|
||||
private final Map<String, String> defaults;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance using the specified root {@link JSONObject}.
|
||||
*/
|
||||
|
@ -70,7 +68,8 @@ class InitializrServiceMetadata {
|
|||
InitializrServiceMetadata(ProjectType defaultProjectType) {
|
||||
this.dependencies = new HashMap<String, Dependency>();
|
||||
this.projectTypes = new MetadataHolder<String, ProjectType>();
|
||||
this.projectTypes.getContent().put(defaultProjectType.getId(), defaultProjectType);
|
||||
this.projectTypes.getContent()
|
||||
.put(defaultProjectType.getId(), defaultProjectType);
|
||||
this.projectTypes.setDefaultItem(defaultProjectType);
|
||||
this.defaults = new HashMap<String, String>();
|
||||
}
|
||||
|
@ -79,35 +78,35 @@ class InitializrServiceMetadata {
|
|||
* Return the dependencies supported by the service.
|
||||
*/
|
||||
public Collection<Dependency> getDependencies() {
|
||||
return dependencies.values();
|
||||
return this.dependencies.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the dependency with the specified id or {@code null} if no
|
||||
* such dependency exists.
|
||||
* Return the dependency with the specified id or {@code null} if no such dependency
|
||||
* exists.
|
||||
*/
|
||||
public Dependency getDependency(String id) {
|
||||
return dependencies.get(id);
|
||||
return this.dependencies.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the project types supported by the service.
|
||||
*/
|
||||
public Map<String, ProjectType> getProjectTypes() {
|
||||
return projectTypes.getContent();
|
||||
return this.projectTypes.getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default type to use or {@code null} or the metadata does
|
||||
* not define any default.
|
||||
* Return the default type to use or {@code null} or the metadata does not define any
|
||||
* default.
|
||||
*/
|
||||
public ProjectType getDefaultType() {
|
||||
if (projectTypes.getDefaultItem() != null) {
|
||||
return projectTypes.getDefaultItem();
|
||||
if (this.projectTypes.getDefaultItem() != null) {
|
||||
return this.projectTypes.getDefaultItem();
|
||||
}
|
||||
String defaultTypeId = getDefaults().get("type");
|
||||
if (defaultTypeId != null) {
|
||||
return projectTypes.getContent().get(defaultTypeId);
|
||||
return this.projectTypes.getContent().get(defaultTypeId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -116,7 +115,7 @@ class InitializrServiceMetadata {
|
|||
* Returns the defaults applicable to the service.
|
||||
*/
|
||||
public Map<String, String> getDefaults() {
|
||||
return defaults;
|
||||
return this.defaults;
|
||||
}
|
||||
|
||||
private Map<String, Dependency> parseDependencies(JSONObject root) {
|
||||
|
@ -221,11 +220,11 @@ class InitializrServiceMetadata {
|
|||
}
|
||||
|
||||
public Map<K, T> getContent() {
|
||||
return content;
|
||||
return this.content;
|
||||
}
|
||||
|
||||
public T getDefaultItem() {
|
||||
return defaultItem;
|
||||
return this.defaultItem;
|
||||
}
|
||||
|
||||
public void setDefaultItem(T defaultItem) {
|
||||
|
|
|
@ -51,19 +51,19 @@ class ListMetadataCommand {
|
|||
* capabilities as advertized by the root endpoint.
|
||||
*/
|
||||
String generateReport(String serviceUrl) throws IOException {
|
||||
InitializrServiceMetadata metadata = initializrServiceInvoker.loadMetadata(serviceUrl);
|
||||
InitializrServiceMetadata metadata = this.initializrServiceInvoker
|
||||
.loadMetadata(serviceUrl);
|
||||
String header = "Capabilities of " + serviceUrl;
|
||||
int size = header.length();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(StringUtils.repeat("=", size)).append(NEW_LINE)
|
||||
.append(header).append(NEW_LINE)
|
||||
.append(StringUtils.repeat("=", size)).append(NEW_LINE)
|
||||
.append(NEW_LINE)
|
||||
.append("Available dependencies:").append(NEW_LINE)
|
||||
sb.append(StringUtils.repeat("=", size)).append(NEW_LINE).append(header)
|
||||
.append(NEW_LINE).append(StringUtils.repeat("=", size)).append(NEW_LINE)
|
||||
.append(NEW_LINE).append("Available dependencies:").append(NEW_LINE)
|
||||
.append("-----------------------").append(NEW_LINE);
|
||||
|
||||
List<Dependency> dependencies = new ArrayList<Dependency>(metadata.getDependencies());
|
||||
List<Dependency> dependencies = new ArrayList<Dependency>(
|
||||
metadata.getDependencies());
|
||||
Collections.sort(dependencies, new Comparator<Dependency>() {
|
||||
@Override
|
||||
public int compare(Dependency o1, Dependency o2) {
|
||||
|
@ -78,8 +78,7 @@ class ListMetadataCommand {
|
|||
sb.append(NEW_LINE);
|
||||
}
|
||||
|
||||
sb.append(NEW_LINE)
|
||||
.append("Available project types:").append(NEW_LINE)
|
||||
sb.append(NEW_LINE).append("Available project types:").append(NEW_LINE)
|
||||
.append("------------------------").append(NEW_LINE);
|
||||
List<String> typeIds = new ArrayList<String>(metadata.getProjectTypes().keySet());
|
||||
Collections.sort(typeIds);
|
||||
|
@ -88,7 +87,8 @@ class ListMetadataCommand {
|
|||
sb.append(typeId).append(" - ").append(type.getName());
|
||||
if (!type.getTags().isEmpty()) {
|
||||
sb.append(" [");
|
||||
Iterator<Map.Entry<String, String>> it = type.getTags().entrySet().iterator();
|
||||
Iterator<Map.Entry<String, String>> it = type.getTags().entrySet()
|
||||
.iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, String> entry = it.next();
|
||||
sb.append(entry.getKey()).append(":").append(entry.getValue());
|
||||
|
@ -104,14 +104,14 @@ class ListMetadataCommand {
|
|||
sb.append(NEW_LINE);
|
||||
}
|
||||
|
||||
sb.append(NEW_LINE)
|
||||
.append("Defaults:").append(NEW_LINE)
|
||||
.append("---------").append(NEW_LINE);
|
||||
sb.append(NEW_LINE).append("Defaults:").append(NEW_LINE).append("---------")
|
||||
.append(NEW_LINE);
|
||||
|
||||
List<String> defaultsKeys = new ArrayList<String>(metadata.getDefaults().keySet());
|
||||
Collections.sort(defaultsKeys);
|
||||
for (String defaultsKey : defaultsKeys) {
|
||||
sb.append(defaultsKey).append(": ").append(metadata.getDefaults().get(defaultsKey)).append(NEW_LINE);
|
||||
sb.append(defaultsKey).append(": ")
|
||||
.append(metadata.getDefaults().get(defaultsKey)).append(NEW_LINE);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class ProjectGenerationRequest {
|
|||
* @see #DEFAULT_SERVICE_URL
|
||||
*/
|
||||
public String getServiceUrl() {
|
||||
return serviceUrl;
|
||||
return this.serviceUrl;
|
||||
}
|
||||
|
||||
public void setServiceUrl(String serviceUrl) {
|
||||
|
@ -69,10 +69,10 @@ class ProjectGenerationRequest {
|
|||
}
|
||||
|
||||
/**
|
||||
* The location of the generated project.
|
||||
* The location of the generated project.
|
||||
*/
|
||||
public String getOutput() {
|
||||
return output;
|
||||
return this.output;
|
||||
}
|
||||
|
||||
public void setOutput(String output) {
|
||||
|
@ -83,7 +83,7 @@ class ProjectGenerationRequest {
|
|||
* The Spring Boot version to use or {@code null} if it should not be customized.
|
||||
*/
|
||||
public String getBootVersion() {
|
||||
return bootVersion;
|
||||
return this.bootVersion;
|
||||
}
|
||||
|
||||
public void setBootVersion(String bootVersion) {
|
||||
|
@ -94,14 +94,14 @@ class ProjectGenerationRequest {
|
|||
* The identifiers of the dependencies to include in the project.
|
||||
*/
|
||||
public List<String> getDependencies() {
|
||||
return dependencies;
|
||||
return this.dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Java version to use or {@code null} if it should not be customized.
|
||||
*/
|
||||
public String getJavaVersion() {
|
||||
return javaVersion;
|
||||
return this.javaVersion;
|
||||
}
|
||||
|
||||
public void setJavaVersion(String javaVersion) {
|
||||
|
@ -112,7 +112,7 @@ class ProjectGenerationRequest {
|
|||
* The packaging type or {@code null} if it should not be customized.
|
||||
*/
|
||||
public String getPackaging() {
|
||||
return packaging;
|
||||
return this.packaging;
|
||||
}
|
||||
|
||||
public void setPackaging(String packaging) {
|
||||
|
@ -120,11 +120,11 @@ class ProjectGenerationRequest {
|
|||
}
|
||||
|
||||
/**
|
||||
* The build type to use. Ignored if a type is set. Can be used alongside
|
||||
* the {@link #getFormat() format} to identify the type to use.
|
||||
* The build type to use. Ignored if a type is set. Can be used alongside the
|
||||
* {@link #getFormat() format} to identify the type to use.
|
||||
*/
|
||||
public String getBuild() {
|
||||
return build;
|
||||
return this.build;
|
||||
}
|
||||
|
||||
public void setBuild(String build) {
|
||||
|
@ -132,11 +132,11 @@ class ProjectGenerationRequest {
|
|||
}
|
||||
|
||||
/**
|
||||
* The project format to use. Ignored if a type is set. Can be used alongside
|
||||
* the {@link #getBuild() build} to identify the type to use.
|
||||
* The project format to use. Ignored if a type is set. Can be used alongside the
|
||||
* {@link #getBuild() build} to identify the type to use.
|
||||
*/
|
||||
public String getFormat() {
|
||||
return format;
|
||||
return this.format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
|
@ -144,11 +144,10 @@ class ProjectGenerationRequest {
|
|||
}
|
||||
|
||||
/**
|
||||
* Specify if the type should be detected based on the build
|
||||
* and format value.
|
||||
* Specify if the type should be detected based on the build and format value.
|
||||
*/
|
||||
public boolean isDetectType() {
|
||||
return detectType;
|
||||
return this.detectType;
|
||||
}
|
||||
|
||||
public void setDetectType(boolean detectType) {
|
||||
|
@ -156,12 +155,11 @@ class ProjectGenerationRequest {
|
|||
}
|
||||
|
||||
/**
|
||||
* The type of project to generate. Should match one of the advertized type
|
||||
* that the service supports. If not set, the default is retrieved from
|
||||
* the service metadata.
|
||||
* The type of project to generate. Should match one of the advertized type that the
|
||||
* service supports. If not set, the default is retrieved from the service metadata.
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
|
@ -169,12 +167,11 @@ class ProjectGenerationRequest {
|
|||
}
|
||||
|
||||
/**
|
||||
* Generates the URL to use to generate a project represented
|
||||
* by this request
|
||||
* Generates the URL to use to generate a project represented by this request
|
||||
*/
|
||||
URI generateUrl(InitializrServiceMetadata metadata) {
|
||||
try {
|
||||
URIBuilder builder = new URIBuilder(serviceUrl);
|
||||
URIBuilder builder = new URIBuilder(this.serviceUrl);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (builder.getPath() != null) {
|
||||
sb.append(builder.getPath());
|
||||
|
@ -188,7 +185,7 @@ class ProjectGenerationRequest {
|
|||
if (this.bootVersion != null) {
|
||||
builder.setParameter("bootVersion", this.bootVersion);
|
||||
}
|
||||
for (String dependency : dependencies) {
|
||||
for (String dependency : this.dependencies) {
|
||||
builder.addParameter("style", dependency);
|
||||
}
|
||||
if (this.javaVersion != null) {
|
||||
|
@ -204,7 +201,8 @@ class ProjectGenerationRequest {
|
|||
return builder.build();
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
throw new ProjectGenerationException("Invalid service URL (" + e.getMessage() + ")");
|
||||
throw new ProjectGenerationException("Invalid service URL (" + e.getMessage()
|
||||
+ ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,12 +210,13 @@ class ProjectGenerationRequest {
|
|||
if (this.type != null) {
|
||||
ProjectType result = metadata.getProjectTypes().get(this.type);
|
||||
if (result == null) {
|
||||
throw new ProjectGenerationException(("No project type with id '" + this.type +
|
||||
"' - check the service capabilities (--list)"));
|
||||
throw new ProjectGenerationException(("No project type with id '"
|
||||
+ this.type + "' - check the service capabilities (--list)"));
|
||||
}
|
||||
}
|
||||
if (isDetectType()) {
|
||||
Map<String, ProjectType> types = new HashMap<String, ProjectType>(metadata.getProjectTypes());
|
||||
Map<String, ProjectType> types = new HashMap<String, ProjectType>(
|
||||
metadata.getProjectTypes());
|
||||
if (this.build != null) {
|
||||
filter(types, "build", this.build);
|
||||
}
|
||||
|
@ -228,24 +227,29 @@ class ProjectGenerationRequest {
|
|||
return types.values().iterator().next();
|
||||
}
|
||||
else if (types.size() == 0) {
|
||||
throw new ProjectGenerationException("No type found with build '" + this.build + "' and format '"
|
||||
+ this.format + "' check the service capabilities (--list)");
|
||||
throw new ProjectGenerationException("No type found with build '"
|
||||
+ this.build + "' and format '" + this.format
|
||||
+ "' check the service capabilities (--list)");
|
||||
}
|
||||
else {
|
||||
throw new ProjectGenerationException("Multiple types found with build '" + this.build
|
||||
+ "' and format '" + this.format + "' use --type with a more specific value " + types.keySet());
|
||||
throw new ProjectGenerationException("Multiple types found with build '"
|
||||
+ this.build + "' and format '" + this.format
|
||||
+ "' use --type with a more specific value " + types.keySet());
|
||||
}
|
||||
}
|
||||
ProjectType defaultType = metadata.getDefaultType();
|
||||
if (defaultType == null) {
|
||||
throw new ProjectGenerationException(("No project type is set and no default is defined. " +
|
||||
"Check the service capabilities (--list)"));
|
||||
throw new ProjectGenerationException(
|
||||
("No project type is set and no default is defined. "
|
||||
+ "Check the service capabilities (--list)"));
|
||||
}
|
||||
return defaultType;
|
||||
}
|
||||
|
||||
private static void filter(Map<String, ProjectType> projects, String tag, String tagValue) {
|
||||
for (Iterator<Map.Entry<String, ProjectType>> it = projects.entrySet().iterator(); it.hasNext(); ) {
|
||||
private static void filter(Map<String, ProjectType> projects, String tag,
|
||||
String tagValue) {
|
||||
for (Iterator<Map.Entry<String, ProjectType>> it = projects.entrySet().iterator(); it
|
||||
.hasNext();) {
|
||||
Map.Entry<String, ProjectType> entry = it.next();
|
||||
String value = entry.getValue().getTags().get(tag);
|
||||
if (!tagValue.equals(value)) {
|
||||
|
|
|
@ -50,7 +50,7 @@ class ProjectGenerationResponse {
|
|||
* The generated project archive or file.
|
||||
*/
|
||||
public byte[] getContent() {
|
||||
return content;
|
||||
return this.content;
|
||||
}
|
||||
|
||||
public void setContent(byte[] content) {
|
||||
|
@ -58,11 +58,11 @@ class ProjectGenerationResponse {
|
|||
}
|
||||
|
||||
/**
|
||||
* The preferred file name to use to store the entity on disk or {@code null}
|
||||
* if no preferred value has been set.
|
||||
* The preferred file name to use to store the entity on disk or {@code null} if no
|
||||
* preferred value has been set.
|
||||
*/
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
|
|
|
@ -38,7 +38,8 @@ class ProjectType {
|
|||
|
||||
private final Map<String, String> tags = new HashMap<String, String>();
|
||||
|
||||
public ProjectType(String id, String name, String action, boolean defaultType, Map<String, String> tags) {
|
||||
public ProjectType(String id, String name, String action, boolean defaultType,
|
||||
Map<String, String> tags) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.action = action;
|
||||
|
@ -49,22 +50,22 @@ class ProjectType {
|
|||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public boolean isDefaultType() {
|
||||
return defaultType;
|
||||
return this.defaultType;
|
||||
}
|
||||
|
||||
public Map<String, String> getTags() {
|
||||
return Collections.unmodifiableMap(tags);
|
||||
return Collections.unmodifiableMap(this.tags);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,12 +30,14 @@ import org.apache.http.message.BasicHeader;
|
|||
import org.hamcrest.Matcher;
|
||||
import org.json.JSONObject;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.Matchers.argThat;
|
||||
import static org.mockito.Matchers.isA;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -51,14 +53,16 @@ public abstract class AbstractHttpClientMockTests {
|
|||
|
||||
protected void mockSuccessfulMetadataGet(String version) throws IOException {
|
||||
CloseableHttpResponse response = mock(CloseableHttpResponse.class);
|
||||
Resource resource = new ClassPathResource("metadata/service-metadata-" + version + ".json");
|
||||
Resource resource = new ClassPathResource("metadata/service-metadata-" + version
|
||||
+ ".json");
|
||||
byte[] content = StreamUtils.copyToByteArray(resource.getInputStream());
|
||||
mockHttpEntity(response, content, "application/json");
|
||||
mockStatus(response, 200);
|
||||
when(httpClient.execute(argThat(getForJsonData()))).thenReturn(response);
|
||||
when(this.httpClient.execute(argThat(getForJsonData()))).thenReturn(response);
|
||||
}
|
||||
|
||||
protected void mockSuccessfulProjectGeneration(MockHttpProjectGenerationRequest request) throws IOException {
|
||||
protected void mockSuccessfulProjectGeneration(
|
||||
MockHttpProjectGenerationRequest request) throws IOException {
|
||||
// Required for project generation as the metadata is read first
|
||||
mockSuccessfulMetadataGet();
|
||||
|
||||
|
@ -66,33 +70,39 @@ public abstract class AbstractHttpClientMockTests {
|
|||
mockHttpEntity(response, request.content, request.contentType);
|
||||
mockStatus(response, 200);
|
||||
|
||||
String header = request.fileName != null ? contentDispositionValue(request.fileName) : null;
|
||||
String header = request.fileName != null ? contentDispositionValue(request.fileName)
|
||||
: null;
|
||||
mockHttpHeader(response, "Content-Disposition", header);
|
||||
when(httpClient.execute(argThat(getForNonJsonData()))).thenReturn(response);
|
||||
when(this.httpClient.execute(argThat(getForNonJsonData()))).thenReturn(response);
|
||||
}
|
||||
|
||||
protected void mockProjectGenerationError(int status, String message) throws IOException {
|
||||
protected void mockProjectGenerationError(int status, String message)
|
||||
throws IOException {
|
||||
// Required for project generation as the metadata is read first
|
||||
mockSuccessfulMetadataGet();
|
||||
|
||||
CloseableHttpResponse response = mock(CloseableHttpResponse.class);
|
||||
mockHttpEntity(response, createJsonError(status, message).getBytes(), "application/json");
|
||||
mockHttpEntity(response, createJsonError(status, message).getBytes(),
|
||||
"application/json");
|
||||
mockStatus(response, status);
|
||||
when(httpClient.execute(isA(HttpGet.class))).thenReturn(response);
|
||||
when(this.httpClient.execute(isA(HttpGet.class))).thenReturn(response);
|
||||
}
|
||||
|
||||
protected void mockMetadataGetError(int status, String message) throws IOException {
|
||||
CloseableHttpResponse response = mock(CloseableHttpResponse.class);
|
||||
mockHttpEntity(response, createJsonError(status, message).getBytes(), "application/json");
|
||||
mockHttpEntity(response, createJsonError(status, message).getBytes(),
|
||||
"application/json");
|
||||
mockStatus(response, status);
|
||||
when(httpClient.execute(isA(HttpGet.class))).thenReturn(response);
|
||||
when(this.httpClient.execute(isA(HttpGet.class))).thenReturn(response);
|
||||
}
|
||||
|
||||
protected HttpEntity mockHttpEntity(CloseableHttpResponse response, byte[] content, String contentType) {
|
||||
protected HttpEntity mockHttpEntity(CloseableHttpResponse response, byte[] content,
|
||||
String contentType) {
|
||||
try {
|
||||
HttpEntity entity = mock(HttpEntity.class);
|
||||
when(entity.getContent()).thenReturn(new ByteArrayInputStream(content));
|
||||
Header contentTypeHeader = contentType != null ? new BasicHeader("Content-Type", contentType) : null;
|
||||
Header contentTypeHeader = contentType != null ? new BasicHeader(
|
||||
"Content-Type", contentType) : null;
|
||||
when(entity.getContentType()).thenReturn(contentTypeHeader);
|
||||
when(response.getEntity()).thenReturn(entity);
|
||||
return entity;
|
||||
|
@ -108,7 +118,8 @@ public abstract class AbstractHttpClientMockTests {
|
|||
when(response.getStatusLine()).thenReturn(statusLine);
|
||||
}
|
||||
|
||||
protected void mockHttpHeader(CloseableHttpResponse response, String headerName, String value) {
|
||||
protected void mockHttpHeader(CloseableHttpResponse response, String headerName,
|
||||
String value) {
|
||||
Header header = value != null ? new BasicHeader(headerName, value) : null;
|
||||
when(response.getFirstHeader(headerName)).thenReturn(header);
|
||||
}
|
||||
|
@ -140,16 +151,17 @@ public abstract class AbstractHttpClientMockTests {
|
|||
|
||||
String fileName;
|
||||
|
||||
byte[] content = new byte[] {0, 0, 0, 0};
|
||||
byte[] content = new byte[] { 0, 0, 0, 0 };
|
||||
|
||||
public MockHttpProjectGenerationRequest(String contentType, String fileName, byte[] content) {
|
||||
public MockHttpProjectGenerationRequest(String contentType, String fileName,
|
||||
byte[] content) {
|
||||
this.contentType = contentType;
|
||||
this.fileName = fileName;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public MockHttpProjectGenerationRequest(String contentType, String fileName) {
|
||||
this(contentType, fileName, new byte[] {0, 0, 0, 0});
|
||||
this(contentType, fileName, new byte[] { 0, 0, 0, 0 });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,11 +183,12 @@ public abstract class AbstractHttpClientMockTests {
|
|||
}
|
||||
HttpGet get = (HttpGet) argument;
|
||||
Header acceptHeader = get.getFirstHeader(HttpHeaders.ACCEPT);
|
||||
if (shouldMatch) {
|
||||
return acceptHeader != null && value.equals(acceptHeader.getValue());
|
||||
if (this.shouldMatch) {
|
||||
return acceptHeader != null && this.value.equals(acceptHeader.getValue());
|
||||
}
|
||||
else {
|
||||
return acceptHeader == null || !value.equals(acceptHeader.getValue());
|
||||
return acceptHeader == null
|
||||
|| !this.value.equals(acceptHeader.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,14 +25,17 @@ import java.util.zip.ZipEntry;
|
|||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import joptsimple.OptionSet;
|
||||
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for {@link InitCommand}
|
||||
|
@ -44,14 +47,15 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
|
|||
@Rule
|
||||
public final TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
private final TestableInitCommandOptionHandler handler = new TestableInitCommandOptionHandler(httpClient);
|
||||
private final TestableInitCommandOptionHandler handler = new TestableInitCommandOptionHandler(
|
||||
this.httpClient);
|
||||
|
||||
private final InitCommand command = new InitCommand(handler);
|
||||
private final InitCommand command = new InitCommand(this.handler);
|
||||
|
||||
@Test
|
||||
public void listServiceCapabilities() throws Exception {
|
||||
mockSuccessfulMetadataGet();
|
||||
command.run("--list", "--target=http://fake-service");
|
||||
this.command.run("--list", "--target=http://fake-service");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -60,12 +64,12 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
|
|||
File f = new File(fileName);
|
||||
assertFalse("file should not exist", f.exists());
|
||||
|
||||
MockHttpProjectGenerationRequest mockHttpRequest =
|
||||
new MockHttpProjectGenerationRequest("application/zip", fileName);
|
||||
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
|
||||
"application/zip", fileName);
|
||||
mockSuccessfulProjectGeneration(mockHttpRequest);
|
||||
|
||||
try {
|
||||
assertEquals(ExitStatus.OK, command.run());
|
||||
assertEquals(ExitStatus.OK, this.command.run());
|
||||
assertTrue("file should have been created", f.exists());
|
||||
}
|
||||
finally {
|
||||
|
@ -75,40 +79,44 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
|
|||
|
||||
@Test
|
||||
public void generateProjectNoFileNameAvailable() throws Exception {
|
||||
MockHttpProjectGenerationRequest mockHttpRequest =
|
||||
new MockHttpProjectGenerationRequest("application/zip", null);
|
||||
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
|
||||
"application/zip", null);
|
||||
mockSuccessfulProjectGeneration(mockHttpRequest);
|
||||
assertEquals(ExitStatus.ERROR, command.run());
|
||||
assertEquals(ExitStatus.ERROR, this.command.run());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateProjectAndExtract() throws Exception {
|
||||
File f = folder.newFolder();
|
||||
File f = this.folder.newFolder();
|
||||
|
||||
byte[] archive = createFakeZipArchive("test.txt", "Fake content");
|
||||
MockHttpProjectGenerationRequest mockHttpRequest =
|
||||
new MockHttpProjectGenerationRequest("application/zip", "demo.zip", archive);
|
||||
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
|
||||
"application/zip", "demo.zip", archive);
|
||||
mockSuccessfulProjectGeneration(mockHttpRequest);
|
||||
|
||||
assertEquals(ExitStatus.OK, command.run("--extract", "--output=" + f.getAbsolutePath()));
|
||||
assertEquals(ExitStatus.OK,
|
||||
this.command.run("--extract", "--output=" + f.getAbsolutePath()));
|
||||
File archiveFile = new File(f, "test.txt");
|
||||
assertTrue("Archive not extracted properly " + f.getAbsolutePath() + " not found", archiveFile.exists());
|
||||
assertTrue(
|
||||
"Archive not extracted properly " + f.getAbsolutePath() + " not found",
|
||||
archiveFile.exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateProjectAndExtractUnsupportedArchive() throws Exception {
|
||||
File f = folder.newFolder();
|
||||
File f = this.folder.newFolder();
|
||||
String fileName = UUID.randomUUID().toString() + ".zip";
|
||||
File archiveFile = new File(fileName);
|
||||
assertFalse("file should not exist", archiveFile.exists());
|
||||
|
||||
try {
|
||||
byte[] archive = createFakeZipArchive("test.txt", "Fake content");
|
||||
MockHttpProjectGenerationRequest mockHttpRequest =
|
||||
new MockHttpProjectGenerationRequest("application/foobar", fileName, archive);
|
||||
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
|
||||
"application/foobar", fileName, archive);
|
||||
mockSuccessfulProjectGeneration(mockHttpRequest);
|
||||
|
||||
assertEquals(ExitStatus.OK, command.run("--extract", "--output=" + f.getAbsolutePath()));
|
||||
assertEquals(ExitStatus.OK,
|
||||
this.command.run("--extract", "--output=" + f.getAbsolutePath()));
|
||||
assertTrue("file should have been saved instead", archiveFile.exists());
|
||||
}
|
||||
finally {
|
||||
|
@ -118,18 +126,19 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
|
|||
|
||||
@Test
|
||||
public void generateProjectAndExtractUnknownContentType() throws Exception {
|
||||
File f = folder.newFolder();
|
||||
File f = this.folder.newFolder();
|
||||
String fileName = UUID.randomUUID().toString() + ".zip";
|
||||
File archiveFile = new File(fileName);
|
||||
assertFalse("file should not exist", archiveFile.exists());
|
||||
|
||||
try {
|
||||
byte[] archive = createFakeZipArchive("test.txt", "Fake content");
|
||||
MockHttpProjectGenerationRequest mockHttpRequest =
|
||||
new MockHttpProjectGenerationRequest(null, fileName, archive);
|
||||
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
|
||||
null, fileName, archive);
|
||||
mockSuccessfulProjectGeneration(mockHttpRequest);
|
||||
|
||||
assertEquals(ExitStatus.OK, command.run("--extract", "--output=" + f.getAbsolutePath()));
|
||||
assertEquals(ExitStatus.OK,
|
||||
this.command.run("--extract", "--output=" + f.getAbsolutePath()));
|
||||
assertTrue("file should have been saved instead", archiveFile.exists());
|
||||
}
|
||||
finally {
|
||||
|
@ -139,120 +148,125 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
|
|||
|
||||
@Test
|
||||
public void fileNotOverwrittenByDefault() throws Exception {
|
||||
File f = folder.newFile();
|
||||
File f = this.folder.newFile();
|
||||
long fileLength = f.length();
|
||||
|
||||
MockHttpProjectGenerationRequest mockHttpRequest =
|
||||
new MockHttpProjectGenerationRequest("application/zip", f.getAbsolutePath());
|
||||
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
|
||||
"application/zip", f.getAbsolutePath());
|
||||
mockSuccessfulProjectGeneration(mockHttpRequest);
|
||||
|
||||
assertEquals("Should have failed", ExitStatus.ERROR, command.run());
|
||||
assertEquals("Should have failed", ExitStatus.ERROR, this.command.run());
|
||||
assertEquals("File should not have changed", fileLength, f.length());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overwriteFile() throws Exception {
|
||||
File f = folder.newFile();
|
||||
File f = this.folder.newFile();
|
||||
long fileLength = f.length();
|
||||
|
||||
MockHttpProjectGenerationRequest mockHttpRequest =
|
||||
new MockHttpProjectGenerationRequest("application/zip", f.getAbsolutePath());
|
||||
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
|
||||
"application/zip", f.getAbsolutePath());
|
||||
mockSuccessfulProjectGeneration(mockHttpRequest);
|
||||
assertEquals("Should not have failed", ExitStatus.OK, command.run("--force"));
|
||||
assertEquals("Should not have failed", ExitStatus.OK, this.command.run("--force"));
|
||||
assertTrue("File should have changed", fileLength != f.length());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fileInArchiveNotOverwrittenByDefault() throws Exception {
|
||||
File f = folder.newFolder();
|
||||
File f = this.folder.newFolder();
|
||||
File conflict = new File(f, "test.txt");
|
||||
assertTrue("Should have been able to create file", conflict.createNewFile());
|
||||
long fileLength = conflict.length();
|
||||
|
||||
// also contains test.txt
|
||||
byte[] archive = createFakeZipArchive("test.txt", "Fake content");
|
||||
MockHttpProjectGenerationRequest mockHttpRequest =
|
||||
new MockHttpProjectGenerationRequest("application/zip", "demo.zip", archive);
|
||||
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
|
||||
"application/zip", "demo.zip", archive);
|
||||
mockSuccessfulProjectGeneration(mockHttpRequest);
|
||||
|
||||
assertEquals(ExitStatus.ERROR, command.run("--extract", "--output=" + f.getAbsolutePath()));
|
||||
assertEquals(ExitStatus.ERROR,
|
||||
this.command.run("--extract", "--output=" + f.getAbsolutePath()));
|
||||
assertEquals("File should not have changed", fileLength, conflict.length());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void overwriteFileInArchive() throws Exception {
|
||||
File f = folder.newFolder();
|
||||
File f = this.folder.newFolder();
|
||||
File conflict = new File(f, "test.txt");
|
||||
assertTrue("Should have been able to create file", conflict.createNewFile());
|
||||
long fileLength = conflict.length();
|
||||
|
||||
// also contains test.txt
|
||||
byte[] archive = createFakeZipArchive("test.txt", "Fake content");
|
||||
MockHttpProjectGenerationRequest mockHttpRequest =
|
||||
new MockHttpProjectGenerationRequest("application/zip", "demo.zip", archive);
|
||||
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
|
||||
"application/zip", "demo.zip", archive);
|
||||
mockSuccessfulProjectGeneration(mockHttpRequest);
|
||||
|
||||
assertEquals(ExitStatus.OK, command.run("--force", "--extract", "--output=" + f.getAbsolutePath()));
|
||||
assertEquals(
|
||||
ExitStatus.OK,
|
||||
this.command.run("--force", "--extract",
|
||||
"--output=" + f.getAbsolutePath()));
|
||||
assertTrue("File should have changed", fileLength != conflict.length());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseProjectOptions() throws Exception {
|
||||
handler.disableProjectGeneration();
|
||||
command.run("-bv=1.2.0.RELEASE", "-d=web,data-jpa", "-jv=1.9", "-p=war",
|
||||
this.handler.disableProjectGeneration();
|
||||
this.command.run("-bv=1.2.0.RELEASE", "-d=web,data-jpa", "-jv=1.9", "-p=war",
|
||||
"--build=grunt", "--format=web", "-t=ant-project");
|
||||
|
||||
assertEquals("1.2.0.RELEASE", handler.lastRequest.getBootVersion());
|
||||
List<String> dependencies = handler.lastRequest.getDependencies();
|
||||
assertEquals("1.2.0.RELEASE", this.handler.lastRequest.getBootVersion());
|
||||
List<String> dependencies = this.handler.lastRequest.getDependencies();
|
||||
assertEquals(2, dependencies.size());
|
||||
assertTrue(dependencies.contains("web"));
|
||||
assertTrue(dependencies.contains("data-jpa"));
|
||||
assertEquals("1.9", handler.lastRequest.getJavaVersion());
|
||||
assertEquals("war", handler.lastRequest.getPackaging());
|
||||
assertEquals("grunt", handler.lastRequest.getBuild());
|
||||
assertEquals("web", handler.lastRequest.getFormat());
|
||||
assertEquals("ant-project", handler.lastRequest.getType());
|
||||
assertEquals("1.9", this.handler.lastRequest.getJavaVersion());
|
||||
assertEquals("war", this.handler.lastRequest.getPackaging());
|
||||
assertEquals("grunt", this.handler.lastRequest.getBuild());
|
||||
assertEquals("web", this.handler.lastRequest.getFormat());
|
||||
assertEquals("ant-project", this.handler.lastRequest.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseTypeOnly() throws Exception {
|
||||
handler.disableProjectGeneration();
|
||||
command.run("-t=ant-project");
|
||||
assertEquals("maven", handler.lastRequest.getBuild());
|
||||
assertEquals("project", handler.lastRequest.getFormat());
|
||||
assertFalse(handler.lastRequest.isDetectType());
|
||||
assertEquals("ant-project", handler.lastRequest.getType());
|
||||
this.handler.disableProjectGeneration();
|
||||
this.command.run("-t=ant-project");
|
||||
assertEquals("maven", this.handler.lastRequest.getBuild());
|
||||
assertEquals("project", this.handler.lastRequest.getFormat());
|
||||
assertFalse(this.handler.lastRequest.isDetectType());
|
||||
assertEquals("ant-project", this.handler.lastRequest.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseBuildOnly() throws Exception {
|
||||
handler.disableProjectGeneration();
|
||||
command.run("--build=ant");
|
||||
assertEquals("ant", handler.lastRequest.getBuild());
|
||||
assertEquals("project", handler.lastRequest.getFormat());
|
||||
assertTrue(handler.lastRequest.isDetectType());
|
||||
assertNull(handler.lastRequest.getType());
|
||||
this.handler.disableProjectGeneration();
|
||||
this.command.run("--build=ant");
|
||||
assertEquals("ant", this.handler.lastRequest.getBuild());
|
||||
assertEquals("project", this.handler.lastRequest.getFormat());
|
||||
assertTrue(this.handler.lastRequest.isDetectType());
|
||||
assertNull(this.handler.lastRequest.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseFormatOnly() throws Exception {
|
||||
handler.disableProjectGeneration();
|
||||
command.run("--format=web");
|
||||
assertEquals("maven", handler.lastRequest.getBuild());
|
||||
assertEquals("web", handler.lastRequest.getFormat());
|
||||
assertTrue(handler.lastRequest.isDetectType());
|
||||
assertNull(handler.lastRequest.getType());
|
||||
this.handler.disableProjectGeneration();
|
||||
this.command.run("--format=web");
|
||||
assertEquals("maven", this.handler.lastRequest.getBuild());
|
||||
assertEquals("web", this.handler.lastRequest.getFormat());
|
||||
assertTrue(this.handler.lastRequest.isDetectType());
|
||||
assertNull(this.handler.lastRequest.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseOutput() throws Exception {
|
||||
handler.disableProjectGeneration();
|
||||
command.run("--output=foobar.zip");
|
||||
this.handler.disableProjectGeneration();
|
||||
this.command.run("--output=foobar.zip");
|
||||
|
||||
assertEquals("foobar.zip", handler.lastRequest.getOutput());
|
||||
assertEquals("foobar.zip", this.handler.lastRequest.getOutput());
|
||||
}
|
||||
|
||||
private byte[] createFakeZipArchive(String fileName, String content) throws IOException {
|
||||
private byte[] createFakeZipArchive(String fileName, String content)
|
||||
throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ZipOutputStream zos = new ZipOutputStream(out);
|
||||
try {
|
||||
|
@ -268,8 +282,8 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
|
|||
return out.toByteArray();
|
||||
}
|
||||
|
||||
|
||||
private static class TestableInitCommandOptionHandler extends InitCommandOptionHandler {
|
||||
private static class TestableInitCommandOptionHandler extends
|
||||
InitCommandOptionHandler {
|
||||
|
||||
private boolean disableProjectGeneration;
|
||||
|
||||
|
@ -280,13 +294,14 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
|
|||
}
|
||||
|
||||
void disableProjectGeneration() {
|
||||
disableProjectGeneration = true;
|
||||
this.disableProjectGeneration = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExitStatus generateProject(OptionSet options, CloseableHttpClient httpClient) {
|
||||
lastRequest = createProjectGenerationRequest(options);
|
||||
if (!disableProjectGeneration) {
|
||||
protected ExitStatus generateProject(OptionSet options,
|
||||
CloseableHttpClient httpClient) {
|
||||
this.lastRequest = createProjectGenerationRequest(options);
|
||||
if (!this.disableProjectGeneration) {
|
||||
return super.generateProject(options, httpClient);
|
||||
}
|
||||
return ExitStatus.OK;
|
||||
|
|
|
@ -25,11 +25,12 @@ import org.junit.Test;
|
|||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import static junit.framework.TestCase.assertNotNull;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.Matchers.isA;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Tests for {@link InitializrServiceHttpInvoker}
|
||||
|
@ -41,20 +42,21 @@ public class InitializrServiceHttpInvokerTests extends AbstractHttpClientMockTes
|
|||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private final InitializrServiceHttpInvoker invoker = new InitializrServiceHttpInvoker(httpClient);
|
||||
private final InitializrServiceHttpInvoker invoker = new InitializrServiceHttpInvoker(
|
||||
this.httpClient);
|
||||
|
||||
@Test
|
||||
public void loadMetadata() throws IOException {
|
||||
mockSuccessfulMetadataGet();
|
||||
InitializrServiceMetadata metadata = invoker.loadMetadata("http://foo/bar");
|
||||
InitializrServiceMetadata metadata = this.invoker.loadMetadata("http://foo/bar");
|
||||
assertNotNull(metadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateSimpleProject() throws IOException {
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
MockHttpProjectGenerationRequest mockHttpRequest =
|
||||
new MockHttpProjectGenerationRequest("application/xml", "foo.zip");
|
||||
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
|
||||
"application/xml", "foo.zip");
|
||||
ProjectGenerationResponse entity = generateProject(request, mockHttpRequest);
|
||||
assertProjectEntity(entity, mockHttpRequest.contentType, mockHttpRequest.fileName);
|
||||
}
|
||||
|
@ -63,8 +65,8 @@ public class InitializrServiceHttpInvokerTests extends AbstractHttpClientMockTes
|
|||
public void generateProjectCustomTargetFilename() throws IOException {
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
request.setOutput("bar.zip");
|
||||
MockHttpProjectGenerationRequest mockHttpRequest =
|
||||
new MockHttpProjectGenerationRequest("application/xml", null);
|
||||
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
|
||||
"application/xml", null);
|
||||
ProjectGenerationResponse entity = generateProject(request, mockHttpRequest);
|
||||
assertProjectEntity(entity, mockHttpRequest.contentType, null);
|
||||
}
|
||||
|
@ -72,8 +74,8 @@ public class InitializrServiceHttpInvokerTests extends AbstractHttpClientMockTes
|
|||
@Test
|
||||
public void generateProjectNoDefaultFileName() throws IOException {
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
MockHttpProjectGenerationRequest mockHttpRequest =
|
||||
new MockHttpProjectGenerationRequest("application/xml", null);
|
||||
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
|
||||
"application/xml", null);
|
||||
ProjectGenerationResponse entity = generateProject(request, mockHttpRequest);
|
||||
assertProjectEntity(entity, mockHttpRequest.contentType, null);
|
||||
}
|
||||
|
@ -85,9 +87,9 @@ public class InitializrServiceHttpInvokerTests extends AbstractHttpClientMockTes
|
|||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
request.getDependencies().add("foo:bar");
|
||||
|
||||
thrown.expect(ProjectGenerationException.class);
|
||||
thrown.expectMessage(jsonMessage);
|
||||
invoker.generate(request);
|
||||
this.thrown.expect(ProjectGenerationException.class);
|
||||
this.thrown.expectMessage(jsonMessage);
|
||||
this.invoker.generate(request);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -95,9 +97,9 @@ public class InitializrServiceHttpInvokerTests extends AbstractHttpClientMockTes
|
|||
mockProjectGenerationError(400, null);
|
||||
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
thrown.expect(ProjectGenerationException.class);
|
||||
thrown.expectMessage("unexpected 400 error");
|
||||
invoker.generate(request);
|
||||
this.thrown.expect(ProjectGenerationException.class);
|
||||
this.thrown.expectMessage("unexpected 400 error");
|
||||
this.invoker.generate(request);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -106,25 +108,24 @@ public class InitializrServiceHttpInvokerTests extends AbstractHttpClientMockTes
|
|||
|
||||
CloseableHttpResponse response = mock(CloseableHttpResponse.class);
|
||||
mockStatus(response, 500);
|
||||
when(httpClient.execute(isA(HttpGet.class))).thenReturn(response);
|
||||
when(this.httpClient.execute(isA(HttpGet.class))).thenReturn(response);
|
||||
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
|
||||
thrown.expect(ProjectGenerationException.class);
|
||||
thrown.expectMessage("No content received from server");
|
||||
invoker.generate(request);
|
||||
this.thrown.expect(ProjectGenerationException.class);
|
||||
this.thrown.expectMessage("No content received from server");
|
||||
this.invoker.generate(request);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void loadMetadataBadRequest() throws IOException {
|
||||
String jsonMessage = "whatever error on the server";
|
||||
mockMetadataGetError(500, jsonMessage);
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
|
||||
thrown.expect(ProjectGenerationException.class);
|
||||
thrown.expectMessage(jsonMessage);
|
||||
invoker.generate(request);
|
||||
this.thrown.expect(ProjectGenerationException.class);
|
||||
this.thrown.expectMessage(jsonMessage);
|
||||
this.invoker.generate(request);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -132,44 +133,43 @@ public class InitializrServiceHttpInvokerTests extends AbstractHttpClientMockTes
|
|||
CloseableHttpResponse response = mock(CloseableHttpResponse.class);
|
||||
mockHttpEntity(response, "Foo-Bar-Not-JSON".getBytes(), "application/json");
|
||||
mockStatus(response, 200);
|
||||
when(httpClient.execute(isA(HttpGet.class))).thenReturn(response);
|
||||
when(this.httpClient.execute(isA(HttpGet.class))).thenReturn(response);
|
||||
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
thrown.expect(ProjectGenerationException.class);
|
||||
thrown.expectMessage("Invalid content received from server");
|
||||
invoker.generate(request);
|
||||
this.thrown.expect(ProjectGenerationException.class);
|
||||
this.thrown.expectMessage("Invalid content received from server");
|
||||
this.invoker.generate(request);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadMetadataNoContent() throws IOException {
|
||||
CloseableHttpResponse response = mock(CloseableHttpResponse.class);
|
||||
mockStatus(response, 500);
|
||||
when(httpClient.execute(isA(HttpGet.class))).thenReturn(response);
|
||||
when(this.httpClient.execute(isA(HttpGet.class))).thenReturn(response);
|
||||
|
||||
ProjectGenerationRequest request = new ProjectGenerationRequest();
|
||||
|
||||
thrown.expect(ProjectGenerationException.class);
|
||||
thrown.expectMessage("No content received from server");
|
||||
invoker.generate(request);
|
||||
this.thrown.expect(ProjectGenerationException.class);
|
||||
this.thrown.expectMessage("No content received from server");
|
||||
this.invoker.generate(request);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private ProjectGenerationResponse generateProject(ProjectGenerationRequest request,
|
||||
MockHttpProjectGenerationRequest mockRequest) throws IOException {
|
||||
mockSuccessfulProjectGeneration(mockRequest);
|
||||
ProjectGenerationResponse entity = invoker.generate(request);
|
||||
ProjectGenerationResponse entity = this.invoker.generate(request);
|
||||
assertArrayEquals("wrong body content", mockRequest.content, entity.getContent());
|
||||
return entity;
|
||||
}
|
||||
|
||||
private static void assertProjectEntity(ProjectGenerationResponse entity, String mimeType, String fileName) {
|
||||
private static void assertProjectEntity(ProjectGenerationResponse entity,
|
||||
String mimeType, String fileName) {
|
||||
if (mimeType == null) {
|
||||
assertNull("No content type expected", entity.getContentType());
|
||||
}
|
||||
else {
|
||||
assertEquals("wrong mime type", mimeType, entity.getContentType().getMimeType());
|
||||
assertEquals("wrong mime type", mimeType, entity.getContentType()
|
||||
.getMimeType());
|
||||
}
|
||||
assertEquals("wrong filename", fileName, entity.getFileName());
|
||||
}
|
||||
|
|
|
@ -22,12 +22,12 @@ import java.nio.charset.Charset;
|
|||
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Tests for {@link InitializrServiceMetadata}
|
||||
|
@ -36,7 +36,6 @@ import static org.junit.Assert.*;
|
|||
*/
|
||||
public class InitializrServiceMetadataTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void parseDefaults() {
|
||||
InitializrServiceMetadata metadata = createInstance("1.0.0");
|
||||
|
@ -53,7 +52,8 @@ public class InitializrServiceMetadataTests {
|
|||
// Security description
|
||||
assertEquals("AOP", metadata.getDependency("aop").getName());
|
||||
assertEquals("Security", metadata.getDependency("security").getName());
|
||||
assertEquals("Security description", metadata.getDependency("security").getDescription());
|
||||
assertEquals("Security description", metadata.getDependency("security")
|
||||
.getDescription());
|
||||
assertEquals("JDBC", metadata.getDependency("jdbc").getName());
|
||||
assertEquals("JPA", metadata.getDependency("data-jpa").getName());
|
||||
assertEquals("MongoDB", metadata.getDependency("data-mongodb").getName());
|
||||
|
@ -76,7 +76,6 @@ public class InitializrServiceMetadataTests {
|
|||
assertEquals("project", projectType.getTags().get("format"));
|
||||
}
|
||||
|
||||
|
||||
private static InitializrServiceMetadata createInstance(String version) {
|
||||
try {
|
||||
return new InitializrServiceMetadata(readJson(version));
|
||||
|
@ -87,7 +86,8 @@ public class InitializrServiceMetadataTests {
|
|||
}
|
||||
|
||||
private static JSONObject readJson(String version) throws IOException {
|
||||
Resource resource = new ClassPathResource("metadata/service-metadata-" + version + ".json");
|
||||
Resource resource = new ClassPathResource("metadata/service-metadata-" + version
|
||||
+ ".json");
|
||||
InputStream stream = resource.getInputStream();
|
||||
try {
|
||||
String json = StreamUtils.copyToString(stream, Charset.forName("UTF-8"));
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.io.IOException;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for {@link ListMetadataCommand}
|
||||
|
@ -29,12 +29,12 @@ import static org.junit.Assert.*;
|
|||
*/
|
||||
public class ListMetadataCommandTests extends AbstractHttpClientMockTests {
|
||||
|
||||
private final ListMetadataCommand command = new ListMetadataCommand(httpClient);
|
||||
private final ListMetadataCommand command = new ListMetadataCommand(this.httpClient);
|
||||
|
||||
@Test
|
||||
public void listMetadata() throws IOException {
|
||||
mockSuccessfulMetadataGet();
|
||||
String content = command.generateReport("http://localhost");
|
||||
String content = this.command.generateReport("http://localhost");
|
||||
|
||||
assertTrue(content.contains("aop - AOP"));
|
||||
assertTrue(content.contains("security - Security: Security description"));
|
||||
|
|
|
@ -27,12 +27,11 @@ import org.json.JSONObject;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests for {@link ProjectGenerationRequest}
|
||||
|
@ -41,7 +40,8 @@ import static org.junit.Assert.*;
|
|||
*/
|
||||
public class ProjectGenerationRequestTests {
|
||||
|
||||
public static final Map<String, String> EMPTY_TAGS = Collections.<String, String>emptyMap();
|
||||
public static final Map<String, String> EMPTY_TAGS = Collections
|
||||
.<String, String> emptyMap();
|
||||
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
@ -50,63 +50,66 @@ public class ProjectGenerationRequestTests {
|
|||
|
||||
@Test
|
||||
public void defaultSettings() {
|
||||
assertEquals(createDefaultUrl("?type=test-type"), request.generateUrl(createDefaultMetadata()));
|
||||
assertEquals(createDefaultUrl("?type=test-type"),
|
||||
this.request.generateUrl(createDefaultMetadata()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customServer() throws URISyntaxException {
|
||||
String customServerUrl = "http://foo:8080/initializr";
|
||||
request.setServiceUrl(customServerUrl);
|
||||
request.getDependencies().add("security");
|
||||
assertEquals(new URI(customServerUrl + "/starter.zip?style=security&type=test-type"),
|
||||
request.generateUrl(createDefaultMetadata()));
|
||||
this.request.setServiceUrl(customServerUrl);
|
||||
this.request.getDependencies().add("security");
|
||||
assertEquals(new URI(customServerUrl
|
||||
+ "/starter.zip?style=security&type=test-type"),
|
||||
this.request.generateUrl(createDefaultMetadata()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customBootVersion() {
|
||||
request.setBootVersion("1.2.0.RELEASE");
|
||||
this.request.setBootVersion("1.2.0.RELEASE");
|
||||
assertEquals(createDefaultUrl("?bootVersion=1.2.0.RELEASE&type=test-type"),
|
||||
request.generateUrl(createDefaultMetadata()));
|
||||
this.request.generateUrl(createDefaultMetadata()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singleDependency() {
|
||||
request.getDependencies().add("web");
|
||||
this.request.getDependencies().add("web");
|
||||
assertEquals(createDefaultUrl("?style=web&type=test-type"),
|
||||
request.generateUrl(createDefaultMetadata()));
|
||||
this.request.generateUrl(createDefaultMetadata()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipleDependencies() {
|
||||
request.getDependencies().add("web");
|
||||
request.getDependencies().add("data-jpa");
|
||||
this.request.getDependencies().add("web");
|
||||
this.request.getDependencies().add("data-jpa");
|
||||
assertEquals(createDefaultUrl("?style=web&style=data-jpa&type=test-type"),
|
||||
request.generateUrl(createDefaultMetadata()));
|
||||
this.request.generateUrl(createDefaultMetadata()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customJavaVersion() {
|
||||
request.setJavaVersion("1.8");
|
||||
this.request.setJavaVersion("1.8");
|
||||
assertEquals(createDefaultUrl("?javaVersion=1.8&type=test-type"),
|
||||
request.generateUrl(createDefaultMetadata()));
|
||||
this.request.generateUrl(createDefaultMetadata()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customPackaging() {
|
||||
request.setPackaging("war");
|
||||
this.request.setPackaging("war");
|
||||
assertEquals(createDefaultUrl("?packaging=war&type=test-type"),
|
||||
request.generateUrl(createDefaultMetadata()));
|
||||
this.request.generateUrl(createDefaultMetadata()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customType() throws URISyntaxException {
|
||||
ProjectType projectType = new ProjectType("custom", "Custom Type", "/foo", true, EMPTY_TAGS);
|
||||
ProjectType projectType = new ProjectType("custom", "Custom Type", "/foo", true,
|
||||
EMPTY_TAGS);
|
||||
InitializrServiceMetadata metadata = new InitializrServiceMetadata(projectType);
|
||||
|
||||
request.setType("custom");
|
||||
request.getDependencies().add("data-rest");
|
||||
assertEquals(new URI(ProjectGenerationRequest.DEFAULT_SERVICE_URL + "/foo?style=data-rest&type=custom"),
|
||||
request.generateUrl(metadata));
|
||||
this.request.setType("custom");
|
||||
this.request.getDependencies().add("data-rest");
|
||||
assertEquals(new URI(ProjectGenerationRequest.DEFAULT_SERVICE_URL
|
||||
+ "/foo?style=data-rest&type=custom"), this.request.generateUrl(metadata));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -114,9 +117,9 @@ public class ProjectGenerationRequestTests {
|
|||
InitializrServiceMetadata metadata = readMetadata();
|
||||
setBuildAndFormat("does-not-exist", null);
|
||||
|
||||
thrown.expect(ProjectGenerationException.class);
|
||||
thrown.expectMessage("does-not-exist");
|
||||
request.generateUrl(metadata);
|
||||
this.thrown.expect(ProjectGenerationException.class);
|
||||
this.thrown.expectMessage("does-not-exist");
|
||||
this.request.generateUrl(metadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -124,10 +127,10 @@ public class ProjectGenerationRequestTests {
|
|||
InitializrServiceMetadata metadata = readMetadata("types-conflict");
|
||||
setBuildAndFormat("gradle", null);
|
||||
|
||||
thrown.expect(ProjectGenerationException.class);
|
||||
thrown.expectMessage("gradle-project");
|
||||
thrown.expectMessage("gradle-project-2");
|
||||
request.generateUrl(metadata);
|
||||
this.thrown.expect(ProjectGenerationException.class);
|
||||
this.thrown.expectMessage("gradle-project");
|
||||
this.thrown.expectMessage("gradle-project-2");
|
||||
this.request.generateUrl(metadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -135,29 +138,30 @@ public class ProjectGenerationRequestTests {
|
|||
InitializrServiceMetadata metadata = readMetadata();
|
||||
setBuildAndFormat("gradle", null);
|
||||
|
||||
assertEquals(createDefaultUrl("?type=gradle-project"), request.generateUrl(metadata));
|
||||
assertEquals(createDefaultUrl("?type=gradle-project"),
|
||||
this.request.generateUrl(metadata));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidType() throws URISyntaxException {
|
||||
request.setType("does-not-exist");
|
||||
this.request.setType("does-not-exist");
|
||||
|
||||
thrown.expect(ProjectGenerationException.class);
|
||||
request.generateUrl(createDefaultMetadata());
|
||||
this.thrown.expect(ProjectGenerationException.class);
|
||||
this.request.generateUrl(createDefaultMetadata());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noTypeAndNoDefault() throws URISyntaxException {
|
||||
|
||||
thrown.expect(ProjectGenerationException.class);
|
||||
thrown.expectMessage("no default is defined");
|
||||
request.generateUrl(readMetadata("types-conflict"));
|
||||
this.thrown.expect(ProjectGenerationException.class);
|
||||
this.thrown.expectMessage("no default is defined");
|
||||
this.request.generateUrl(readMetadata("types-conflict"));
|
||||
}
|
||||
|
||||
|
||||
private static URI createDefaultUrl(String param) {
|
||||
try {
|
||||
return new URI(ProjectGenerationRequest.DEFAULT_SERVICE_URL + "/starter.zip" + param);
|
||||
return new URI(ProjectGenerationRequest.DEFAULT_SERVICE_URL + "/starter.zip"
|
||||
+ param);
|
||||
}
|
||||
catch (URISyntaxException e) {
|
||||
throw new IllegalStateException(e);
|
||||
|
@ -165,13 +169,14 @@ public class ProjectGenerationRequestTests {
|
|||
}
|
||||
|
||||
public void setBuildAndFormat(String build, String format) {
|
||||
request.setBuild(build != null ? build : "maven");
|
||||
request.setFormat(format != null ? format : "project");
|
||||
request.setDetectType(true);
|
||||
this.request.setBuild(build != null ? build : "maven");
|
||||
this.request.setFormat(format != null ? format : "project");
|
||||
this.request.setDetectType(true);
|
||||
}
|
||||
|
||||
private static InitializrServiceMetadata createDefaultMetadata() {
|
||||
ProjectType projectType = new ProjectType("test-type", "The test type", "/starter.zip", true, EMPTY_TAGS);
|
||||
ProjectType projectType = new ProjectType("test-type", "The test type",
|
||||
"/starter.zip", true, EMPTY_TAGS);
|
||||
return new InitializrServiceMetadata(projectType);
|
||||
}
|
||||
|
||||
|
@ -181,8 +186,10 @@ public class ProjectGenerationRequestTests {
|
|||
|
||||
private static InitializrServiceMetadata readMetadata(String version) {
|
||||
try {
|
||||
Resource resource = new ClassPathResource("metadata/service-metadata-" + version + ".json");
|
||||
String content = StreamUtils.copyToString(resource.getInputStream(), Charset.forName("UTF-8"));
|
||||
Resource resource = new ClassPathResource("metadata/service-metadata-"
|
||||
+ version + ".json");
|
||||
String content = StreamUtils.copyToString(resource.getInputStream(),
|
||||
Charset.forName("UTF-8"));
|
||||
JSONObject json = new JSONObject(content);
|
||||
return new InitializrServiceMetadata(json);
|
||||
}
|
||||
|
|
|
@ -1,134 +1,134 @@
|
|||
{"dependencies": [
|
||||
{
|
||||
"name": "Core",
|
||||
"content": [
|
||||
{
|
||||
"name": "Security",
|
||||
"id": "security",
|
||||
"description": "Security description"
|
||||
},
|
||||
{
|
||||
"name": "AOP",
|
||||
"id": "aop"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Data",
|
||||
"content": [
|
||||
{
|
||||
"name": "JDBC",
|
||||
"id": "jdbc"
|
||||
},
|
||||
{
|
||||
"name": "JPA",
|
||||
"id": "data-jpa"
|
||||
},
|
||||
{
|
||||
"name": "MongoDB",
|
||||
"id": "data-mongodb"
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"name": "Core",
|
||||
"content": [
|
||||
{
|
||||
"name": "Security",
|
||||
"id": "security",
|
||||
"description": "Security description"
|
||||
},
|
||||
{
|
||||
"name": "AOP",
|
||||
"id": "aop"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Data",
|
||||
"content": [
|
||||
{
|
||||
"name": "JDBC",
|
||||
"id": "jdbc"
|
||||
},
|
||||
{
|
||||
"name": "JPA",
|
||||
"id": "data-jpa"
|
||||
},
|
||||
{
|
||||
"name": "MongoDB",
|
||||
"id": "data-mongodb"
|
||||
}
|
||||
]
|
||||
}
|
||||
], "types": [
|
||||
{
|
||||
"name": "Maven POM",
|
||||
"id": "maven-build",
|
||||
"action": "/pom.xml",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Maven Project",
|
||||
"id": "maven-project",
|
||||
"action": "/starter.zip",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "Gradle Config",
|
||||
"id": "gradle-build",
|
||||
"action": "/build.gradle",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Gradle Project",
|
||||
"id": "gradle-project",
|
||||
"action": "/starter.zip",
|
||||
"default": false
|
||||
}
|
||||
{
|
||||
"name": "Maven POM",
|
||||
"id": "maven-build",
|
||||
"action": "/pom.xml",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Maven Project",
|
||||
"id": "maven-project",
|
||||
"action": "/starter.zip",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "Gradle Config",
|
||||
"id": "gradle-build",
|
||||
"action": "/build.gradle",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Gradle Project",
|
||||
"id": "gradle-project",
|
||||
"action": "/starter.zip",
|
||||
"default": false
|
||||
}
|
||||
], "packagings": [
|
||||
{
|
||||
"name": "Jar",
|
||||
"id": "jar",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "War",
|
||||
"id": "war",
|
||||
"default": false
|
||||
}
|
||||
{
|
||||
"name": "Jar",
|
||||
"id": "jar",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "War",
|
||||
"id": "war",
|
||||
"default": false
|
||||
}
|
||||
], "javaVersions": [
|
||||
{
|
||||
"name": "1.6",
|
||||
"id": "1.6",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.7",
|
||||
"id": "1.7",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "1.8",
|
||||
"id": "1.8",
|
||||
"default": false
|
||||
}
|
||||
{
|
||||
"name": "1.6",
|
||||
"id": "1.6",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.7",
|
||||
"id": "1.7",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "1.8",
|
||||
"id": "1.8",
|
||||
"default": false
|
||||
}
|
||||
], "languages": [
|
||||
{
|
||||
"name": "Groovy",
|
||||
"id": "groovy",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Java",
|
||||
"id": "java",
|
||||
"default": true
|
||||
}
|
||||
{
|
||||
"name": "Groovy",
|
||||
"id": "groovy",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Java",
|
||||
"id": "java",
|
||||
"default": true
|
||||
}
|
||||
], "bootVersions": [
|
||||
{
|
||||
"name": "1.2.0 M2",
|
||||
"id": "1.2.0.M2",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.2.0 (SNAPSHOT)",
|
||||
"id": "1.2.0.BUILD-SNAPSHOT",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.1.8",
|
||||
"id": "1.1.8.RELEASE",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "1.1.8 (SNAPSHOT)",
|
||||
"id": "1.1.8.BUILD-SNAPSHOT",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.0.2",
|
||||
"id": "1.0.2.RELEASE",
|
||||
"default": false
|
||||
}
|
||||
{
|
||||
"name": "1.2.0 M2",
|
||||
"id": "1.2.0.M2",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.2.0 (SNAPSHOT)",
|
||||
"id": "1.2.0.BUILD-SNAPSHOT",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.1.8",
|
||||
"id": "1.1.8.RELEASE",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "1.1.8 (SNAPSHOT)",
|
||||
"id": "1.1.8.BUILD-SNAPSHOT",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.0.2",
|
||||
"id": "1.0.2.RELEASE",
|
||||
"default": false
|
||||
}
|
||||
], "defaults": {
|
||||
"groupId": "org.test",
|
||||
"artifactId": "demo",
|
||||
"version": "0.0.1-SNAPSHOT",
|
||||
"name": "demo",
|
||||
"description": "Demo project for Spring Boot",
|
||||
"packageName": "demo",
|
||||
"type": "maven-project",
|
||||
"packaging": "jar",
|
||||
"javaVersion": "1.7",
|
||||
"language": "java",
|
||||
"bootVersion": "1.1.8.RELEASE"
|
||||
}}
|
||||
"groupId": "org.test",
|
||||
"artifactId": "demo",
|
||||
"version": "0.0.1-SNAPSHOT",
|
||||
"name": "demo",
|
||||
"description": "Demo project for Spring Boot",
|
||||
"packageName": "demo",
|
||||
"type": "maven-project",
|
||||
"packaging": "jar",
|
||||
"javaVersion": "1.7",
|
||||
"language": "java",
|
||||
"bootVersion": "1.1.8.RELEASE"
|
||||
}}
|
||||
|
|
|
@ -1,150 +1,150 @@
|
|||
{"dependencies": [
|
||||
{
|
||||
"name": "Core",
|
||||
"content": [
|
||||
{
|
||||
"name": "Security",
|
||||
"id": "security",
|
||||
"description": "Security description"
|
||||
},
|
||||
{
|
||||
"name": "AOP",
|
||||
"id": "aop"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Data",
|
||||
"content": [
|
||||
{
|
||||
"name": "JDBC",
|
||||
"id": "jdbc"
|
||||
},
|
||||
{
|
||||
"name": "JPA",
|
||||
"id": "data-jpa"
|
||||
},
|
||||
{
|
||||
"name": "MongoDB",
|
||||
"id": "data-mongodb"
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"name": "Core",
|
||||
"content": [
|
||||
{
|
||||
"name": "Security",
|
||||
"id": "security",
|
||||
"description": "Security description"
|
||||
},
|
||||
{
|
||||
"name": "AOP",
|
||||
"id": "aop"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Data",
|
||||
"content": [
|
||||
{
|
||||
"name": "JDBC",
|
||||
"id": "jdbc"
|
||||
},
|
||||
{
|
||||
"name": "JPA",
|
||||
"id": "data-jpa"
|
||||
},
|
||||
{
|
||||
"name": "MongoDB",
|
||||
"id": "data-mongodb"
|
||||
}
|
||||
]
|
||||
}
|
||||
], "types": [
|
||||
{
|
||||
"name": "Maven POM",
|
||||
"id": "maven-build",
|
||||
"action": "/pom.xml",
|
||||
"tags": {
|
||||
"build": "maven",
|
||||
"format": "build"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Maven Project",
|
||||
"id": "maven-project",
|
||||
"action": "/starter.zip",
|
||||
"tags": {
|
||||
"build": "maven",
|
||||
"format": "project"
|
||||
},
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "Gradle Config",
|
||||
"id": "gradle-build",
|
||||
"action": "/build.gradle",
|
||||
"tags": {
|
||||
"build": "gradle",
|
||||
"format": "build"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Gradle Project",
|
||||
"id": "gradle-project",
|
||||
"action": "/starter.zip",
|
||||
"tags": {
|
||||
"build": "gradle",
|
||||
"format": "project"
|
||||
},
|
||||
"default": false
|
||||
}
|
||||
{
|
||||
"name": "Maven POM",
|
||||
"id": "maven-build",
|
||||
"action": "/pom.xml",
|
||||
"tags": {
|
||||
"build": "maven",
|
||||
"format": "build"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Maven Project",
|
||||
"id": "maven-project",
|
||||
"action": "/starter.zip",
|
||||
"tags": {
|
||||
"build": "maven",
|
||||
"format": "project"
|
||||
},
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "Gradle Config",
|
||||
"id": "gradle-build",
|
||||
"action": "/build.gradle",
|
||||
"tags": {
|
||||
"build": "gradle",
|
||||
"format": "build"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Gradle Project",
|
||||
"id": "gradle-project",
|
||||
"action": "/starter.zip",
|
||||
"tags": {
|
||||
"build": "gradle",
|
||||
"format": "project"
|
||||
},
|
||||
"default": false
|
||||
}
|
||||
], "packagings": [
|
||||
{
|
||||
"name": "Jar",
|
||||
"id": "jar",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "War",
|
||||
"id": "war",
|
||||
"default": false
|
||||
}
|
||||
{
|
||||
"name": "Jar",
|
||||
"id": "jar",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "War",
|
||||
"id": "war",
|
||||
"default": false
|
||||
}
|
||||
], "javaVersions": [
|
||||
{
|
||||
"name": "1.6",
|
||||
"id": "1.6",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.7",
|
||||
"id": "1.7",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "1.8",
|
||||
"id": "1.8",
|
||||
"default": false
|
||||
}
|
||||
{
|
||||
"name": "1.6",
|
||||
"id": "1.6",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.7",
|
||||
"id": "1.7",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "1.8",
|
||||
"id": "1.8",
|
||||
"default": false
|
||||
}
|
||||
], "languages": [
|
||||
{
|
||||
"name": "Groovy",
|
||||
"id": "groovy",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Java",
|
||||
"id": "java",
|
||||
"default": true
|
||||
}
|
||||
{
|
||||
"name": "Groovy",
|
||||
"id": "groovy",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Java",
|
||||
"id": "java",
|
||||
"default": true
|
||||
}
|
||||
], "bootVersions": [
|
||||
{
|
||||
"name": "1.2.0 M2",
|
||||
"id": "1.2.0.M2",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.2.0 (SNAPSHOT)",
|
||||
"id": "1.2.0.BUILD-SNAPSHOT",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.1.8",
|
||||
"id": "1.1.8.RELEASE",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "1.1.8 (SNAPSHOT)",
|
||||
"id": "1.1.8.BUILD-SNAPSHOT",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.0.2",
|
||||
"id": "1.0.2.RELEASE",
|
||||
"default": false
|
||||
}
|
||||
{
|
||||
"name": "1.2.0 M2",
|
||||
"id": "1.2.0.M2",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.2.0 (SNAPSHOT)",
|
||||
"id": "1.2.0.BUILD-SNAPSHOT",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.1.8",
|
||||
"id": "1.1.8.RELEASE",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "1.1.8 (SNAPSHOT)",
|
||||
"id": "1.1.8.BUILD-SNAPSHOT",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.0.2",
|
||||
"id": "1.0.2.RELEASE",
|
||||
"default": false
|
||||
}
|
||||
], "defaults": {
|
||||
"groupId": "org.test",
|
||||
"artifactId": "demo",
|
||||
"version": "0.0.1-SNAPSHOT",
|
||||
"name": "demo",
|
||||
"description": "Demo project for Spring Boot",
|
||||
"packageName": "demo",
|
||||
"type": "maven-project",
|
||||
"packaging": "jar",
|
||||
"javaVersion": "1.7",
|
||||
"language": "java",
|
||||
"bootVersion": "1.1.8.RELEASE"
|
||||
}}
|
||||
"groupId": "org.test",
|
||||
"artifactId": "demo",
|
||||
"version": "0.0.1-SNAPSHOT",
|
||||
"name": "demo",
|
||||
"description": "Demo project for Spring Boot",
|
||||
"packageName": "demo",
|
||||
"type": "maven-project",
|
||||
"packaging": "jar",
|
||||
"javaVersion": "1.7",
|
||||
"language": "java",
|
||||
"bootVersion": "1.1.8.RELEASE"
|
||||
}}
|
||||
|
|
|
@ -1,169 +1,169 @@
|
|||
{"dependencies": [
|
||||
{
|
||||
"name": "Core",
|
||||
"content": [
|
||||
{
|
||||
"name": "Security",
|
||||
"id": "security",
|
||||
"description": "Security description"
|
||||
},
|
||||
{
|
||||
"name": "AOP",
|
||||
"id": "aop"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Data",
|
||||
"content": [
|
||||
{
|
||||
"name": "JDBC",
|
||||
"id": "jdbc"
|
||||
},
|
||||
{
|
||||
"name": "JPA",
|
||||
"id": "data-jpa"
|
||||
},
|
||||
{
|
||||
"name": "MongoDB",
|
||||
"id": "data-mongodb"
|
||||
}
|
||||
]
|
||||
}
|
||||
{
|
||||
"name": "Core",
|
||||
"content": [
|
||||
{
|
||||
"name": "Security",
|
||||
"id": "security",
|
||||
"description": "Security description"
|
||||
},
|
||||
{
|
||||
"name": "AOP",
|
||||
"id": "aop"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Data",
|
||||
"content": [
|
||||
{
|
||||
"name": "JDBC",
|
||||
"id": "jdbc"
|
||||
},
|
||||
{
|
||||
"name": "JPA",
|
||||
"id": "data-jpa"
|
||||
},
|
||||
{
|
||||
"name": "MongoDB",
|
||||
"id": "data-mongodb"
|
||||
}
|
||||
]
|
||||
}
|
||||
], "types": [
|
||||
{
|
||||
"name": "Maven POM",
|
||||
"id": "maven-build",
|
||||
"action": "/pom.xml",
|
||||
"tags": {
|
||||
"build": "maven",
|
||||
"format": "build"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Maven Project",
|
||||
"id": "maven-project",
|
||||
"action": "/starter.zip",
|
||||
"tags": {
|
||||
"build": "maven",
|
||||
"format": "project"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Another Maven Project",
|
||||
"id": "maven-project-2",
|
||||
"action": "/starter.zip",
|
||||
"tags": {
|
||||
"build": "maven",
|
||||
"format": "project"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Gradle Config",
|
||||
"id": "gradle-build",
|
||||
"action": "/build.gradle",
|
||||
"tags": {
|
||||
"build": "gradle",
|
||||
"format": "build"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Gradle Project",
|
||||
"id": "gradle-project",
|
||||
"action": "/starter.zip",
|
||||
"tags": {
|
||||
"build": "gradle",
|
||||
"format": "project"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Another gradle Project",
|
||||
"id": "gradle-project-2",
|
||||
"action": "/starter.zip",
|
||||
"tags": {
|
||||
"build": "gradle",
|
||||
"format": "project"
|
||||
},
|
||||
"default": false
|
||||
}
|
||||
{
|
||||
"name": "Maven POM",
|
||||
"id": "maven-build",
|
||||
"action": "/pom.xml",
|
||||
"tags": {
|
||||
"build": "maven",
|
||||
"format": "build"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Maven Project",
|
||||
"id": "maven-project",
|
||||
"action": "/starter.zip",
|
||||
"tags": {
|
||||
"build": "maven",
|
||||
"format": "project"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Another Maven Project",
|
||||
"id": "maven-project-2",
|
||||
"action": "/starter.zip",
|
||||
"tags": {
|
||||
"build": "maven",
|
||||
"format": "project"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Gradle Config",
|
||||
"id": "gradle-build",
|
||||
"action": "/build.gradle",
|
||||
"tags": {
|
||||
"build": "gradle",
|
||||
"format": "build"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Gradle Project",
|
||||
"id": "gradle-project",
|
||||
"action": "/starter.zip",
|
||||
"tags": {
|
||||
"build": "gradle",
|
||||
"format": "project"
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Another gradle Project",
|
||||
"id": "gradle-project-2",
|
||||
"action": "/starter.zip",
|
||||
"tags": {
|
||||
"build": "gradle",
|
||||
"format": "project"
|
||||
},
|
||||
"default": false
|
||||
}
|
||||
], "packagings": [
|
||||
{
|
||||
"name": "Jar",
|
||||
"id": "jar",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "War",
|
||||
"id": "war",
|
||||
"default": false
|
||||
}
|
||||
{
|
||||
"name": "Jar",
|
||||
"id": "jar",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "War",
|
||||
"id": "war",
|
||||
"default": false
|
||||
}
|
||||
], "javaVersions": [
|
||||
{
|
||||
"name": "1.6",
|
||||
"id": "1.6",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.7",
|
||||
"id": "1.7",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "1.8",
|
||||
"id": "1.8",
|
||||
"default": false
|
||||
}
|
||||
{
|
||||
"name": "1.6",
|
||||
"id": "1.6",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.7",
|
||||
"id": "1.7",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "1.8",
|
||||
"id": "1.8",
|
||||
"default": false
|
||||
}
|
||||
], "languages": [
|
||||
{
|
||||
"name": "Groovy",
|
||||
"id": "groovy",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Java",
|
||||
"id": "java",
|
||||
"default": true
|
||||
}
|
||||
{
|
||||
"name": "Groovy",
|
||||
"id": "groovy",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "Java",
|
||||
"id": "java",
|
||||
"default": true
|
||||
}
|
||||
], "bootVersions": [
|
||||
{
|
||||
"name": "1.2.0 M2",
|
||||
"id": "1.2.0.M2",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.2.0 (SNAPSHOT)",
|
||||
"id": "1.2.0.BUILD-SNAPSHOT",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.1.8",
|
||||
"id": "1.1.8.RELEASE",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "1.1.8 (SNAPSHOT)",
|
||||
"id": "1.1.8.BUILD-SNAPSHOT",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.0.2",
|
||||
"id": "1.0.2.RELEASE",
|
||||
"default": false
|
||||
}
|
||||
{
|
||||
"name": "1.2.0 M2",
|
||||
"id": "1.2.0.M2",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.2.0 (SNAPSHOT)",
|
||||
"id": "1.2.0.BUILD-SNAPSHOT",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.1.8",
|
||||
"id": "1.1.8.RELEASE",
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"name": "1.1.8 (SNAPSHOT)",
|
||||
"id": "1.1.8.BUILD-SNAPSHOT",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"name": "1.0.2",
|
||||
"id": "1.0.2.RELEASE",
|
||||
"default": false
|
||||
}
|
||||
], "defaults": {
|
||||
"groupId": "org.test",
|
||||
"artifactId": "demo",
|
||||
"version": "0.0.1-SNAPSHOT",
|
||||
"name": "demo",
|
||||
"description": "Demo project for Spring Boot",
|
||||
"packageName": "demo",
|
||||
"packaging": "jar",
|
||||
"javaVersion": "1.7",
|
||||
"language": "java",
|
||||
"bootVersion": "1.1.8.RELEASE"
|
||||
}}
|
||||
"groupId": "org.test",
|
||||
"artifactId": "demo",
|
||||
"version": "0.0.1-SNAPSHOT",
|
||||
"name": "demo",
|
||||
"description": "Demo project for Spring Boot",
|
||||
"packageName": "demo",
|
||||
"packaging": "jar",
|
||||
"javaVersion": "1.7",
|
||||
"language": "java",
|
||||
"bootVersion": "1.1.8.RELEASE"
|
||||
}}
|
||||
|
|
Loading…
Reference in New Issue