polishing

This commit is contained in:
Stephane Nicoll
2014-08-19 02:56:49 +02:00
parent c22e357ee9
commit 964aef8bdb
9 changed files with 43 additions and 27 deletions

View File

@@ -34,7 +34,7 @@ class InitializrMetadata {
final List<BootVersion> bootVersions = new ArrayList<BootVersion>()
final Defaults defaults = new Defaults();
final Defaults defaults = new Defaults()
/**
* Initializes a {@link ProjectRequest} instance with the defaults

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2012-2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.spring.initializr.web
import io.spring.initializr.InitializrMetadata
@@ -39,7 +55,7 @@ class MainController {
@ModelAttribute
ProjectRequest projectRequest() {
ProjectRequest request = new ProjectRequest();
ProjectRequest request = new ProjectRequest()
metadata.initializeProjectRequest(request)
request
}

View File

@@ -26,14 +26,14 @@ import static org.junit.Assert.assertEquals
class InitializrMetadataTests {
@Test
public void getDefaultNoDefault() {
void getDefaultNoDefault() {
List elements = []
elements << createJavaVersion('one', false) << createJavaVersion('two', false)
assertEquals 'three', InitializrMetadata.getDefault(elements, 'three')
}
@Test
public void getDefaultWithDefault() {
void getDefaultWithDefault() {
List elements = []
elements << createJavaVersion('one', false) << createJavaVersion('two', true)
assertEquals 'two', InitializrMetadata.getDefault(elements, 'three')

View File

@@ -36,14 +36,14 @@ class ProjectGeneratorTests {
}
@Test
public void defaultMavenPom() {
void defaultMavenPom() {
ProjectRequest request = createProjectRequest('web')
generateMavenPom(request).hasStartClass('demo.Application')
.hasNoRepository().hasSpringBootStarterDependency('web')
}
@Test
public void mavenPomWithBootSnapshot() {
void mavenPomWithBootSnapshot() {
ProjectRequest request = createProjectRequest('web')
request.bootVersion = '1.0.1.BUILD-SNAPSHOT'
generateMavenPom(request).hasStartClass('demo.Application')
@@ -51,7 +51,7 @@ class ProjectGeneratorTests {
}
@Test
public void mavenWarPomWithoutWebFacet() {
void mavenWarPomWithoutWebFacet() {
ProjectRequest request = createProjectRequest('data-jpa')
request.packaging = 'war'
generateMavenPom(request).hasStartClass('demo.Application')

View File

@@ -61,7 +61,7 @@ class InitializrMetadataBuilder {
}
InitializrMetadataBuilder addType(String id, boolean defaultValue, String action) {
InitializrMetadata.Type type = new InitializrMetadata.Type();
InitializrMetadata.Type type = new InitializrMetadata.Type()
type.id = id
type.name = id
type.default = defaultValue
@@ -75,7 +75,7 @@ class InitializrMetadataBuilder {
}
InitializrMetadataBuilder addPackaging(String id, boolean defaultValue) {
InitializrMetadata.Packaging packaging = new InitializrMetadata.Packaging();
InitializrMetadata.Packaging packaging = new InitializrMetadata.Packaging()
packaging.id = id
packaging.name = id
packaging.default = defaultValue
@@ -88,7 +88,7 @@ class InitializrMetadataBuilder {
}
InitializrMetadataBuilder addJavaVersion(String version, boolean defaultValue) {
InitializrMetadata.JavaVersion javaVersion = new InitializrMetadata.JavaVersion();
InitializrMetadata.JavaVersion javaVersion = new InitializrMetadata.JavaVersion()
javaVersion.id = version
javaVersion.name = version
javaVersion.default = defaultValue
@@ -101,7 +101,7 @@ class InitializrMetadataBuilder {
}
InitializrMetadataBuilder addLanguage(String id, boolean defaultValue) {
InitializrMetadata.Language language = new InitializrMetadata.Language();
InitializrMetadata.Language language = new InitializrMetadata.Language()
language.id = id
language.name = id
language.default = defaultValue
@@ -115,7 +115,7 @@ class InitializrMetadataBuilder {
}
InitializrMetadataBuilder addBootVersion(String id, boolean defaultValue) {
InitializrMetadata.BootVersion bootVersion = new InitializrMetadata.BootVersion();
InitializrMetadata.BootVersion bootVersion = new InitializrMetadata.BootVersion()
bootVersion.id = id
bootVersion.name = id
bootVersion.default = defaultValue

View File

@@ -44,7 +44,7 @@ class PomAssert {
context.put 'pom', 'http://maven.apache.org/POM/4.0.0'
SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(context)
eng.namespaceContext = namespaceContext
doc = XMLUnit.buildControlDocument(content);
doc = XMLUnit.buildControlDocument(content)
parseDependencies()
}
@@ -59,32 +59,32 @@ class PomAssert {
}
PomAssert hasGroupId(String groupId) {
assertEquals groupId, eng.evaluate(createRootNodeXPath('groupId'), doc);
assertEquals groupId, eng.evaluate(createRootNodeXPath('groupId'), doc)
this
}
PomAssert hasArtifactId(String artifactId) {
assertEquals artifactId, eng.evaluate(createRootNodeXPath('artifactId'), doc);
assertEquals artifactId, eng.evaluate(createRootNodeXPath('artifactId'), doc)
this
}
PomAssert hasVersion(String version) {
assertEquals version, eng.evaluate(createRootNodeXPath('version'), doc);
assertEquals version, eng.evaluate(createRootNodeXPath('version'), doc)
this
}
PomAssert hasPackaging(String packaging) {
assertEquals packaging, eng.evaluate(createRootNodeXPath('packaging'), doc);
assertEquals packaging, eng.evaluate(createRootNodeXPath('packaging'), doc)
this
}
PomAssert hasName(String name) {
assertEquals name, eng.evaluate(createRootNodeXPath('name'), doc);
assertEquals name, eng.evaluate(createRootNodeXPath('name'), doc)
this
}
PomAssert hasDescription(String description) {
assertEquals description, eng.evaluate(createRootNodeXPath('description'), doc);
assertEquals description, eng.evaluate(createRootNodeXPath('description'), doc)
this
}
@@ -141,7 +141,7 @@ class PomAssert {
def nodes = eng.getMatchingNodes(createRootNodeXPath('repositories/pom:repository/pom:id'), doc)
for (int i = 0; i < nodes.getLength(); i++) {
if (name.equals(nodes.item(i).getTextContent())) {
return;
return
}
}
throw new IllegalArgumentException('No repository found with id ' + name)
@@ -151,7 +151,7 @@ class PomAssert {
def nodes = eng.getMatchingNodes(createRootNodeXPath('pluginRepositories/pom:pluginRepository/pom:id'), doc)
for (int i = 0; i < nodes.getLength(); i++) {
if (name.equals(nodes.item(i).getTextContent())) {
return;
return
}
}
throw new IllegalArgumentException('No plugin repository found with id ' + name)

View File

@@ -26,7 +26,7 @@ import static org.junit.Assert.assertEquals
*/
class ProjectAssert {
final File dir;
final File dir
/**
* Create a new instance with the directory holding the generated project.

View File

@@ -42,7 +42,7 @@ import org.springframework.web.client.RestTemplate
abstract class AbstractMainControllerIntegrationTests {
@Rule
public final TemporaryFolder folder = new TemporaryFolder();
public final TemporaryFolder folder = new TemporaryFolder()
@Value('${local.server.port}')
private int port

View File

@@ -32,7 +32,7 @@ import static org.junit.Assert.*
class MainControllerIntegrationTests extends AbstractMainControllerIntegrationTests {
@Test
public void simpleZipProject() {
void simpleZipProject() {
downloadZip('/starter.zip?style=web&style=jpa').isJavaProject().isMavenProject()
.hasStaticAndTemplatesResources(true).pomAssert()
.hasDependenciesCount(3)
@@ -42,7 +42,7 @@ class MainControllerIntegrationTests extends AbstractMainControllerIntegrationTe
}
@Test
public void simpleTgzProject() {
void simpleTgzProject() {
downloadTgz('/starter.tgz?style=data-jpa').isJavaProject().isMavenProject()
.hasStaticAndTemplatesResources(false).pomAssert()
.hasDependenciesCount(2)
@@ -50,7 +50,7 @@ class MainControllerIntegrationTests extends AbstractMainControllerIntegrationTe
}
@Test
public void gradleWarProject() {
void gradleWarProject() {
downloadZip('/starter.zip?style=web&style=security&packaging=war&type=gradle.zip').isJavaWarProject()
.isGradleProject()
}
@@ -132,7 +132,7 @@ class MainControllerIntegrationTests extends AbstractMainControllerIntegrationTe
File tgzFile = writeArchive(body)
def project = folder.newFolder()
new AntBuilder().untar(dest: project, src: tgzFile, compression: 'gzip');
new AntBuilder().untar(dest: project, src: tgzFile, compression: 'gzip')
new ProjectAssert(project)
}