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