Add extra attributes to the init command

Update the CLI init command to expose additional attributes supported
by Spring Initializr. These are: groupId, artifactId, version, name,
description and language.

Closes gh-2793 and gh-2907
This commit is contained in:
Eddú Meléndez
2015-05-04 09:15:56 -05:00
committed by Stephane Nicoll
parent d4dfa8d979
commit 0b8fd67507
4 changed files with 174 additions and 2 deletions

View File

@@ -49,6 +49,7 @@ import static org.mockito.Mockito.verify;
* Tests for {@link InitCommand}
*
* @author Stephane Nicoll
* @author Eddú Meléndez
*/
public class InitCommandTests extends AbstractHttpClientMockTests {
@@ -280,8 +281,9 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
@Test
public void parseProjectOptions() throws Exception {
this.handler.disableProjectGeneration();
this.command.run("-b=1.2.0.RELEASE", "-d=web,data-jpa", "-j=1.9", "-p=war",
"--build=grunt", "--format=web", "-t=ant-project");
this.command.run("-b=1.2.0.RELEASE", "-d=web,data-jpa", "-j=1.9", "-p=war", "--build=grunt",
"--format=web", "-t=ant-project", "-lang=groovy", "-g=org.test", "-a=demo", "-n=demo",
"-v=0.0.1-SNAPSHOT", "-des=Demo project for Spring Boot");
assertEquals("1.2.0.RELEASE", this.handler.lastRequest.getBootVersion());
List<String> dependencies = this.handler.lastRequest.getDependencies();
assertEquals(2, dependencies.size());
@@ -292,6 +294,12 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
assertEquals("grunt", this.handler.lastRequest.getBuild());
assertEquals("web", this.handler.lastRequest.getFormat());
assertEquals("ant-project", this.handler.lastRequest.getType());
assertEquals("groovy", this.handler.lastRequest.getLanguage());
assertEquals("org.test", this.handler.lastRequest.getGroupId());
assertEquals("demo", this.handler.lastRequest.getArtifactId());
assertEquals("demo", this.handler.lastRequest.getName());
assertEquals("0.0.1-SNAPSHOT", this.handler.lastRequest.getVersion());
assertEquals("Demo project for Spring Boot", this.handler.lastRequest.getDescription());
}
@Test

View File

@@ -37,6 +37,7 @@ import static org.junit.Assert.assertEquals;
* Tests for {@link ProjectGenerationRequest}
*
* @author Stephane Nicoll
* @author Eddú Meléndez
*/
public class ProjectGenerationRequestTests {
@@ -112,6 +113,24 @@ public class ProjectGenerationRequestTests {
this.request.generateUrl(metadata));
}
@Test
public void customLanguage() {
this.request.setLanguage("java");
assertEquals(createDefaultUrl("?language=java&type=test-type"),
this.request.generateUrl(createDefaultMetadata()));
}
@Test
public void customProjectInfo() {
this.request.setGroupId("org.test");
this.request.setArtifactId("demo");
this.request.setVersion("0.0.1-SNAPSHOT");
this.request.setDescription("Spring Boot Demo");
assertEquals(createDefaultUrl("?artifactId=demo&description=Spring+Boot+Demo"
+ "&groupId=org.test&type=test-type&version=0.0.1-SNAPSHOT"),
this.request.generateUrl(createDefaultMetadata()));
}
@Test
public void buildNoMatch() {
InitializrServiceMetadata metadata = readMetadata();