From 4ce9c412bb53024833f49c9b540bd395b20d35cf Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 5 Jan 2016 14:48:32 +0000 Subject: [PATCH] Polish contribution Closes gh-173 --- README.adoc | 9 ++-- .../initializr/test/ProjectAssert.groovy | 8 +--- .../web/ProjectGenerationSmokeTests.groovy | 42 ++++++++++++++++++- .../initializr/web/test/HomePage.groovy | 4 +- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/README.adoc b/README.adoc index 6dd82f63..1243f028 100644 --- a/README.adoc +++ b/README.adoc @@ -83,15 +83,18 @@ via a plain HTTP call. [[customize-form]] == Customize form inputs -You can share or bookmark URL that will customize automatically form inputs with this kind of hashbang parameters: +You can share or bookmark URLs that will automatically customize form inputs. For instance, +the following URL from the default instance uses `groovy` by default and set the name +to `Groovy Sample`: [source,bash] ---- https://start.spring.io/#!language=groovy&name=Groovy%20Sample ---- -`type`, `groupId`, `artifactId`, `name`, `description`, `packageName`, -`packaging`, `javaVersion` and `language` parameters are supported. +The following hashbang parameters are supported: `type`, `groupId`, `artifactId`, `name`, +`description`, `packageName`, `packaging`, `javaVersion` and `language`. Review the section +above for a description of each of them. [[meta-data]] == Service meta-data diff --git a/initializr/src/test/groovy/io/spring/initializr/test/ProjectAssert.groovy b/initializr/src/test/groovy/io/spring/initializr/test/ProjectAssert.groovy index 2377b4fd..f5162c37 100644 --- a/initializr/src/test/groovy/io/spring/initializr/test/ProjectAssert.groovy +++ b/initializr/src/test/groovy/io/spring/initializr/test/ProjectAssert.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ class ProjectAssert { public static final DEFAULT_PACKAGE_NAME = 'com.example' - private static final DEFAULT_APPLICATION_NAME = generateDefaultApplicationName() + public static final DEFAULT_APPLICATION_NAME = 'DemoApplication' final File dir Boolean mavenProject @@ -159,8 +159,4 @@ class ProjectAssert { new File(dir, localPath) } - private static generateDefaultApplicationName() { - 'DemoApplication' - } - } diff --git a/initializr/src/test/groovy/io/spring/initializr/web/ProjectGenerationSmokeTests.groovy b/initializr/src/test/groovy/io/spring/initializr/web/ProjectGenerationSmokeTests.groovy index ed215e57..ba7acce1 100644 --- a/initializr/src/test/groovy/io/spring/initializr/web/ProjectGenerationSmokeTests.groovy +++ b/initializr/src/test/groovy/io/spring/initializr/web/ProjectGenerationSmokeTests.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.openqa.selenium.interactions.Actions import org.springframework.test.context.ActiveProfiles +import static org.junit.Assert.assertEquals import static org.junit.Assert.assertTrue /** @@ -310,8 +311,45 @@ class ProjectGenerationSmokeTests extends AbstractInitializrControllerIntegratio } } + @Test + void customizationShowsUpInDefaultView() { + toHome('/#!language=groovy&packageName=com.example.acme') { + assertEquals 'groovy', page.language.value() + assertEquals 'com.example.acme', page.packageName.value() + page.generateProject.click() + at HomePage + def projectAssert = zipProjectAssert(from('demo.zip')) + projectAssert.hasBaseDir('demo') + .isMavenProject() + .isGroovyProject('com.example.acme', ProjectAssert.DEFAULT_APPLICATION_NAME ) + .hasStaticAndTemplatesResources(false) + .pomAssert().hasDependenciesCount(3) + .hasSpringBootStarterRootDependency().hasSpringBootStarterTest() + .hasDependency('org.codehaus.groovy', 'groovy') + + } + } + + @Test + void customizationsShowsUpWhenViewIsSwitched() { + toHome('/#!packaging=war&javaVersion=1.7') { + assertEquals 'war', page.packaging.value() + assertEquals '1.7', page.javaVersion.value() + page.advanced().click() + assertEquals 'war', page.packaging.value() + assertEquals '1.7', page.javaVersion.value() + page.simple().click() + assertEquals 'war', page.packaging.value() + assertEquals '1.7', page.javaVersion.value() + } + } + private Browser toHome(Closure script) { - browser.go("http://localhost:" + port + "/") + toHome('/', script) + } + + private Browser toHome(String uri, Closure script) { + browser.go("http://localhost:$port$uri") browser.at HomePage script.delegate = browser script() diff --git a/initializr/src/test/groovy/io/spring/initializr/web/test/HomePage.groovy b/initializr/src/test/groovy/io/spring/initializr/web/test/HomePage.groovy index 7376f18d..f23fd95f 100644 --- a/initializr/src/test/groovy/io/spring/initializr/web/test/HomePage.groovy +++ b/initializr/src/test/groovy/io/spring/initializr/web/test/HomePage.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ class HomePage extends Page { static at = { title == 'Spring Initializr' } static content = { advanced { $('.tofullversion a') } - simple { $('tosimpleversion a') } + simple { $('.tosimpleversion a') } // Simple view groupId { $('form').groupId() }