mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-19 01:58:16 +08:00
Code formatting
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>io.spring.initializr</groupId>
|
||||
|
@@ -21,13 +21,13 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.metadata.Type;
|
||||
import io.spring.initializr.util.TemplateRenderer;
|
||||
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
|
||||
/**
|
||||
* Generate help pages for command-line clients.
|
||||
*
|
||||
|
@@ -28,16 +28,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import io.spring.initializr.InitializrException;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrConfiguration.Env.Maven.ParentPom;
|
||||
@@ -45,6 +35,16 @@ import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.metadata.InitializrMetadataProvider;
|
||||
import io.spring.initializr.util.TemplateRenderer;
|
||||
import io.spring.initializr.util.Version;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
* Generate a project based on the configured metadata.
|
||||
@@ -384,17 +384,17 @@ public class ProjectGenerator {
|
||||
|
||||
Map<String, String> versions = new LinkedHashMap<String, String>();
|
||||
model.put("buildPropertiesVersions", versions.entrySet());
|
||||
request.getBuildProperties().getVersions().forEach((k,v) -> {
|
||||
request.getBuildProperties().getVersions().forEach((k, v) -> {
|
||||
versions.put(k, v.get());
|
||||
});
|
||||
Map<String, String> gradle = new LinkedHashMap<String, String>();
|
||||
model.put("buildPropertiesGradle", gradle.entrySet());
|
||||
request.getBuildProperties().getGradle().forEach((k,v) -> {
|
||||
request.getBuildProperties().getGradle().forEach((k, v) -> {
|
||||
gradle.put(k, v.get());
|
||||
});
|
||||
Map<String, String> maven = new LinkedHashMap<String, String>();
|
||||
model.put("buildPropertiesMaven", maven.entrySet());
|
||||
request.getBuildProperties().getMaven().forEach((k,v) -> {
|
||||
request.getBuildProperties().getMaven().forEach((k, v) -> {
|
||||
maven.put(k, v.get());
|
||||
});
|
||||
|
||||
@@ -404,7 +404,7 @@ public class ProjectGenerator {
|
||||
model.put("kotlinVersion",
|
||||
metadata.getConfiguration().getEnv().getKotlin().getVersion());
|
||||
if ("kotlin".equals(request.getLanguage())) {
|
||||
model.put("kotlin", true);
|
||||
model.put("kotlin", true);
|
||||
}
|
||||
if ("groovy".equals(request.getLanguage())) {
|
||||
model.put("groovy", true);
|
||||
@@ -423,7 +423,7 @@ public class ProjectGenerator {
|
||||
model.put("springBootPluginName",
|
||||
(VERSION_1_4_2_M1
|
||||
.compareTo(Version.safeParse(request.getBootVersion())) <= 0
|
||||
? "org.springframework.boot" : "spring-boot"));
|
||||
? "org.springframework.boot" : "spring-boot"));
|
||||
|
||||
// New testing stuff
|
||||
model.put("newTestInfrastructure", isNewTestInfrastructureAvailable(request));
|
||||
|
@@ -22,9 +22,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import io.spring.initializr.metadata.BillOfMaterials;
|
||||
import io.spring.initializr.metadata.DefaultMetadataElement;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
@@ -33,6 +30,9 @@ import io.spring.initializr.metadata.Repository;
|
||||
import io.spring.initializr.metadata.Type;
|
||||
import io.spring.initializr.util.Version;
|
||||
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* A request to generate a project.
|
||||
*
|
||||
|
@@ -1,12 +1,28 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Resolve {@link ProjectRequest} instances, honouring callback hook points.
|
||||
*
|
||||
|
@@ -22,7 +22,6 @@ import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.spring.initializr.util.InvalidVersionException;
|
||||
import io.spring.initializr.util.Version;
|
||||
import io.spring.initializr.util.VersionParser;
|
||||
|
@@ -45,7 +45,7 @@ public class DefaultMetadataElement extends MetadataElement {
|
||||
public boolean isDefault() {
|
||||
return this.defaultValue;
|
||||
}
|
||||
|
||||
|
||||
public static DefaultMetadataElement create(String id, boolean defaultValue) {
|
||||
return new DefaultMetadataElement(id, defaultValue);
|
||||
}
|
||||
|
@@ -24,7 +24,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import io.spring.initializr.util.VersionParser;
|
||||
|
||||
/**
|
||||
|
@@ -21,16 +21,15 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.spring.initializr.util.InvalidVersionException;
|
||||
import io.spring.initializr.util.Version;
|
||||
import io.spring.initializr.util.VersionParser;
|
||||
import io.spring.initializr.util.VersionRange;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Meta-data for a dependency. Each dependency has a primary identifier and an arbitrary
|
||||
* number of {@code aliases}.
|
||||
@@ -38,7 +37,6 @@ import io.spring.initializr.util.VersionRange;
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
// @AutoClone(style = AutoCloneStyle.COPY_CONSTRUCTOR)
|
||||
public class Dependency extends MetadataElement implements Describable {
|
||||
|
||||
public static final String SCOPE_COMPILE = "compile";
|
||||
@@ -249,7 +247,7 @@ public class Dependency extends MetadataElement implements Describable {
|
||||
* Specify if this dependency is available for the specified Spring Boot version.
|
||||
*/
|
||||
public boolean match(Version version) {
|
||||
if (range!=null) {
|
||||
if (range != null) {
|
||||
return range.match(version);
|
||||
}
|
||||
return true;
|
||||
|
@@ -55,7 +55,7 @@ public class DependencyGroup {
|
||||
private String repository;
|
||||
|
||||
final List<Dependency> content = new ArrayList<>();
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -96,6 +96,6 @@ public class DependencyGroup {
|
||||
DependencyGroup group = new DependencyGroup();
|
||||
group.setName(name);
|
||||
return group;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ public class DependencyMetadata {
|
||||
}
|
||||
|
||||
public DependencyMetadata(Version bootVersion, Map<String, Dependency> dependencies,
|
||||
Map<String, Repository> repositories, Map<String, BillOfMaterials> boms) {
|
||||
Map<String, Repository> repositories, Map<String, BillOfMaterials> boms) {
|
||||
this.bootVersion = bootVersion;
|
||||
this.dependencies = dependencies;
|
||||
this.repositories = repositories;
|
||||
|
@@ -462,8 +462,8 @@ public class InitializrConfiguration {
|
||||
&& !StringUtils.hasText(artifactId)
|
||||
&& !StringUtils.hasText(version))
|
||||
|| (StringUtils.hasText(groupId)
|
||||
&& StringUtils.hasText(artifactId)
|
||||
&& StringUtils.hasText(version)))) {
|
||||
&& StringUtils.hasText(artifactId)
|
||||
&& StringUtils.hasText(version)))) {
|
||||
throw new InvalidInitializrMetadataException("Custom maven pom "
|
||||
+ "requires groupId, artifactId and version");
|
||||
}
|
||||
|
@@ -20,14 +20,14 @@ import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* Builder for {@link InitializrMetadata}. Allows to read metadata from any arbitrary
|
||||
* resource, including remote URLs.
|
||||
|
@@ -19,11 +19,11 @@ package io.spring.initializr.metadata;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* Configuration of the initializr service.
|
||||
*
|
||||
|
@@ -68,14 +68,14 @@ public class Link {
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private String description;
|
||||
|
||||
|
||||
public Link() {
|
||||
}
|
||||
|
||||
private Link(String rel, String href) {
|
||||
this(rel, href, (String)null);
|
||||
this(rel, href, null);
|
||||
}
|
||||
|
||||
|
||||
private Link(String rel, String href, String description) {
|
||||
this.rel = rel;
|
||||
this.href = href;
|
||||
@@ -124,11 +124,11 @@ public class Link {
|
||||
}
|
||||
|
||||
public void resolve() {
|
||||
if (rel==null) {
|
||||
if (rel == null) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"Invalid link " + this + ": rel attribute is mandatory");
|
||||
}
|
||||
if (href==null) {
|
||||
if (href == null) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"Invalid link " + this + ": href attribute is mandatory");
|
||||
}
|
||||
@@ -147,13 +147,13 @@ public class Link {
|
||||
*/
|
||||
public URI expand(Map<String, String> parameters) {
|
||||
AtomicReference<String> result = new AtomicReference<String>(href);
|
||||
templateVariables.forEach( var -> {
|
||||
templateVariables.forEach(var -> {
|
||||
Object value = parameters.get(var);
|
||||
if (value==null) {
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Could not expand " + href + ", missing value for '" + var + "'");
|
||||
}
|
||||
result.set(result.get().replace("{" + var+"}", value.toString()));
|
||||
result.set(result.get().replace("{" + var + "}", value.toString()));
|
||||
});
|
||||
try {
|
||||
return new URI(result.get());
|
||||
|
@@ -33,7 +33,7 @@ public class MetadataElement {
|
||||
* The unique id of this element for a given capability.
|
||||
*/
|
||||
private String id;
|
||||
|
||||
|
||||
public MetadataElement() {
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class MetadataElement {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name!=null ? name: id;
|
||||
return name != null ? name : id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@@ -16,12 +16,12 @@
|
||||
|
||||
package io.spring.initializr.metadata;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Defines a capability of the initializr service. Each capability is defined by a id and
|
||||
* a {@link ServiceCapabilityType type}.
|
||||
|
@@ -56,7 +56,7 @@ public class TypeCapability extends ServiceCapability<List<Type>> implements Def
|
||||
@Override
|
||||
public void merge(List<Type> otherContent) {
|
||||
otherContent.forEach(it -> {
|
||||
if (get(it.getId())==null) {
|
||||
if (get(it.getId()) == null) {
|
||||
content.add(it);
|
||||
}
|
||||
});
|
||||
|
@@ -22,16 +22,16 @@ import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
|
||||
import com.samskivert.mustache.Mustache;
|
||||
import com.samskivert.mustache.Mustache.Compiler;
|
||||
import com.samskivert.mustache.Mustache.TemplateLoader;
|
||||
import com.samskivert.mustache.Template;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
|
@@ -81,9 +81,9 @@ public final class Version implements Serializable, Comparable<Version> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return major + "." + minor + "." + patch +
|
||||
(qualifier!=null ? "." + qualifier.qualifier +
|
||||
(qualifier.version!=null ? qualifier.version : "") : "");
|
||||
return major + "." + minor + "." + patch +
|
||||
(qualifier != null ? "." + qualifier.qualifier +
|
||||
(qualifier.version != null ? qualifier.version : "") : "");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +109,8 @@ public final class Version implements Serializable, Comparable<Version> {
|
||||
public static Version safeParse(String text) {
|
||||
try {
|
||||
return parse(text);
|
||||
} catch (InvalidVersionException e) {
|
||||
}
|
||||
catch (InvalidVersionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -135,37 +136,45 @@ public final class Version implements Serializable, Comparable<Version> {
|
||||
}
|
||||
|
||||
private static int safeCompare(Integer first, Integer second) {
|
||||
Integer firstIndex = first !=null ? first : 0;
|
||||
Integer secondIndex = second !=null ? second : 0;
|
||||
Integer firstIndex = first != null ? first : 0;
|
||||
Integer secondIndex = second != null ? second : 0;
|
||||
return firstIndex.compareTo(secondIndex);
|
||||
}
|
||||
|
||||
public static class Qualifier {
|
||||
public Qualifier() {
|
||||
}
|
||||
|
||||
public Qualifier(String qualifier) {
|
||||
this.qualifier = qualifier;
|
||||
}
|
||||
|
||||
String qualifier;
|
||||
Integer version;
|
||||
|
||||
public String getQualifier() {
|
||||
return qualifier;
|
||||
}
|
||||
|
||||
public void setQualifier(String qualifier) {
|
||||
this.qualifier = qualifier;
|
||||
}
|
||||
|
||||
public Integer getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Integer version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Qualifier ["
|
||||
+ (qualifier != null ? "qualifier=" + qualifier + ", " : "")
|
||||
+ (version != null ? "version=" + version : "") + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
@@ -174,6 +183,7 @@ public final class Version implements Serializable, Comparable<Version> {
|
||||
result = prime * result + ((version == null) ? 0 : version.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
@@ -258,16 +268,16 @@ public final class Version implements Serializable, Comparable<Version> {
|
||||
|
||||
@Override
|
||||
public int compare(Qualifier o1, Qualifier o2) {
|
||||
Qualifier first = o1!=null ? o1 : new Qualifier(RELEASE);
|
||||
Qualifier second = o2!=null ? o2 : new Qualifier(RELEASE);
|
||||
Qualifier first = o1 != null ? o1 : new Qualifier(RELEASE);
|
||||
Qualifier second = o2 != null ? o2 : new Qualifier(RELEASE);
|
||||
|
||||
int qualifier = compareQualifier(first, second);
|
||||
return qualifier!=0 ? qualifier : compareQualifierVersion(first, second);
|
||||
return qualifier != 0 ? qualifier : compareQualifierVersion(first, second);
|
||||
}
|
||||
|
||||
private static int compareQualifierVersion(Qualifier first, Qualifier second) {
|
||||
Integer firstVersion = first.getVersion()!=null ? first.getVersion() : 0;
|
||||
Integer secondVersion = second.getVersion()!=null ? second.getVersion(): 0;
|
||||
Integer firstVersion = first.getVersion() != null ? first.getVersion() : 0;
|
||||
Integer secondVersion = second.getVersion() != null ? second.getVersion() : 0;
|
||||
return firstVersion.compareTo(secondVersion);
|
||||
}
|
||||
|
||||
@@ -277,13 +287,15 @@ public final class Version implements Serializable, Comparable<Version> {
|
||||
|
||||
if (firstIndex == -1 && secondIndex == -1) { // Unknown qualifier, alphabetic ordering
|
||||
return first.qualifier.compareTo(second.qualifier);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return firstIndex.compareTo(secondIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private static int getQualifierIndex(String qualifier) {
|
||||
return StringUtils.hasText(qualifier) ? KNOWN_QUALIFIERS.indexOf(qualifier) : 0;
|
||||
return StringUtils.hasText(qualifier) ? KNOWN_QUALIFIERS.indexOf(qualifier)
|
||||
: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -22,11 +22,11 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.spring.initializr.util.Version.Qualifier;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import io.spring.initializr.util.Version.Qualifier;
|
||||
|
||||
/**
|
||||
* Parser for {@link Version} and {@link VersionRange} that allows to resolve the minor
|
||||
* and patch value against a configurable list of "latest versions".
|
||||
@@ -84,12 +84,14 @@ public class VersionParser {
|
||||
if ("x".equals(minor) || "x".equals(patch)) {
|
||||
Integer minorInt = "x".equals(minor) ? null : Integer.parseInt(minor);
|
||||
Version latest = findLatestVersion(major, minorInt, qualifier);
|
||||
if (latest==null) {
|
||||
return new Version(major, ("x".equals(minor) ? 999 : Integer.parseInt(minor)),
|
||||
if (latest == null) {
|
||||
return new Version(major, ("x".equals(minor) ? 999
|
||||
: Integer.parseInt(minor)),
|
||||
("x".equals(patch) ? 999 : Integer.parseInt(patch)), qualifier);
|
||||
}
|
||||
return new Version(major, latest.getMinor(), latest.getPatch(), latest.getQualifier());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return new Version(major, Integer.parseInt(minor), Integer.parseInt(patch), qualifier);
|
||||
}
|
||||
}
|
||||
@@ -105,7 +107,8 @@ public class VersionParser {
|
||||
public Version safeParse(String text) {
|
||||
try {
|
||||
return parse(text);
|
||||
} catch (InvalidVersionException ex) {
|
||||
}
|
||||
catch (InvalidVersionException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -133,15 +136,15 @@ public class VersionParser {
|
||||
}
|
||||
|
||||
private Version findLatestVersion(Integer major, Integer minor,
|
||||
Version.Qualifier qualifier) {
|
||||
Version.Qualifier qualifier) {
|
||||
List<Version> matches = this.latestVersions.stream().filter(it -> {
|
||||
if (major!=null && !major.equals(it.getMajor())) {
|
||||
if (major != null && !major.equals(it.getMajor())) {
|
||||
return false;
|
||||
}
|
||||
if (minor!=null && !minor.equals(it.getMinor())) {
|
||||
if (minor != null && !minor.equals(it.getMinor())) {
|
||||
return false;
|
||||
}
|
||||
if (qualifier!=null && !qualifier.equals(it.getQualifier())) {
|
||||
if (qualifier != null && !qualifier.equals(it.getQualifier())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@@ -40,7 +40,7 @@ public class VersionRange {
|
||||
final boolean lowerInclusive;
|
||||
final Version higherVersion;
|
||||
final boolean higherInclusive;
|
||||
|
||||
|
||||
// For Jackson
|
||||
@SuppressWarnings("unused")
|
||||
private VersionRange() {
|
||||
@@ -48,7 +48,7 @@ public class VersionRange {
|
||||
}
|
||||
|
||||
protected VersionRange(Version lowerVersion, boolean lowerInclusive,
|
||||
Version higherVersion, boolean higherInclusive) {
|
||||
Version higherVersion, boolean higherInclusive) {
|
||||
this.lowerVersion = lowerVersion;
|
||||
this.lowerInclusive = lowerInclusive;
|
||||
this.higherVersion = higherVersion;
|
||||
@@ -64,14 +64,16 @@ public class VersionRange {
|
||||
int lower = lowerVersion.compareTo(version);
|
||||
if (lower > 0) {
|
||||
return false;
|
||||
} else if (!lowerInclusive && lower == 0) {
|
||||
}
|
||||
else if (!lowerInclusive && lower == 0) {
|
||||
return false;
|
||||
}
|
||||
if (higherVersion!=null) {
|
||||
if (higherVersion != null) {
|
||||
int higher = higherVersion.compareTo(version);
|
||||
if (higher < 0) {
|
||||
return false;
|
||||
} else if (!higherInclusive && higher == 0) {
|
||||
}
|
||||
else if (!higherInclusive && higher == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -95,13 +97,12 @@ public class VersionRange {
|
||||
}
|
||||
|
||||
@Override
|
||||
public
|
||||
String toString() {
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (lowerVersion!=null) {
|
||||
if (lowerVersion != null) {
|
||||
sb.append((lowerInclusive ? ">=" : ">") + lowerVersion);
|
||||
}
|
||||
if (higherVersion!=null) {
|
||||
if (higherVersion != null) {
|
||||
sb.append(" and " + (higherInclusive ? "<=" : "<") + higherVersion);
|
||||
}
|
||||
return sb.toString();
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -16,22 +16,11 @@
|
||||
|
||||
package io.spring.initializr.generator;
|
||||
|
||||
import static org.mockito.Matchers.argThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.metadata.SimpleInitializrMetadataProvider;
|
||||
@@ -39,6 +28,17 @@ import io.spring.initializr.test.generator.GradleBuildAssert;
|
||||
import io.spring.initializr.test.generator.PomAssert;
|
||||
import io.spring.initializr.test.generator.ProjectAssert;
|
||||
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
|
||||
import static org.mockito.Matchers.argThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -97,8 +97,7 @@ public abstract class AbstractProjectGeneratorTests {
|
||||
projectGenerator.setMetadataProvider(new SimpleInitializrMetadataProvider(metadata));
|
||||
}
|
||||
|
||||
protected void verifyProjectSuccessfulEventFor(ProjectRequest request)
|
||||
{
|
||||
protected void verifyProjectSuccessfulEventFor(ProjectRequest request) {
|
||||
verify(eventPublisher, times(1)).publishEvent(argThat(new ProjectGeneratedEventMatcher(request)));
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -16,18 +16,17 @@
|
||||
|
||||
package io.spring.initializr.generator;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.metadata.Type;
|
||||
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
|
||||
import io.spring.initializr.util.TemplateRenderer;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
@@ -35,7 +34,7 @@ import io.spring.initializr.util.TemplateRenderer;
|
||||
public class CommandLineHelpGeneratorTests {
|
||||
|
||||
private CommandLineHelpGenerator generator;
|
||||
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
generator = new CommandLineHelpGenerator(new TemplateRenderer());
|
||||
@@ -111,7 +110,7 @@ public class CommandLineHelpGeneratorTests {
|
||||
createDependency("id-b", "depB"),
|
||||
createDependency("id-a", "depA", "and some description")).build();
|
||||
String content = generator.generateSpringBootCliCapabilities(metadata, "https://fake-service");
|
||||
assertThat(content, containsString("| Id"));
|
||||
assertThat(content, containsString("| Id"));
|
||||
assertThat(content, containsString("| Tags"));
|
||||
assertThat(content, containsString("id-a | and some description |"));
|
||||
assertThat(content, containsString("id-b | depB"));
|
||||
|
@@ -16,16 +16,16 @@
|
||||
|
||||
package io.spring.initializr.generator;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import io.spring.initializr.metadata.BillOfMaterials;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.test.generator.ProjectAssert;
|
||||
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
* Project generator tests for supported build systems.
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -16,15 +16,15 @@
|
||||
|
||||
package io.spring.initializr.generator;
|
||||
|
||||
import static io.spring.initializr.test.generator.ProjectAssert.DEFAULT_APPLICATION_NAME;
|
||||
import static io.spring.initializr.test.generator.ProjectAssert.DEFAULT_PACKAGE_NAME;
|
||||
|
||||
import io.spring.initializr.test.generator.ProjectAssert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import io.spring.initializr.test.generator.ProjectAssert;
|
||||
import static io.spring.initializr.test.generator.ProjectAssert.DEFAULT_APPLICATION_NAME;
|
||||
import static io.spring.initializr.test.generator.ProjectAssert.DEFAULT_PACKAGE_NAME;
|
||||
|
||||
/**
|
||||
* Project generator tests for supported languages.
|
||||
@@ -121,7 +121,7 @@ public class ProjectGeneratorLanguageTests extends AbstractProjectGeneratorTests
|
||||
ProjectRequest request = createProjectRequest();
|
||||
request.setLanguage(language);
|
||||
request.setPackaging("war");
|
||||
if (bootVersion!=null) {
|
||||
if (bootVersion != null) {
|
||||
request.setBootVersion(bootVersion);
|
||||
}
|
||||
ProjectAssert project = generateProject(request);
|
||||
|
@@ -16,26 +16,26 @@
|
||||
|
||||
package io.spring.initializr.generator;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import io.spring.initializr.metadata.BillOfMaterials;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.test.generator.ProjectAssert;
|
||||
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Tests for {@link ProjectGenerator}
|
||||
@@ -186,10 +186,8 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
||||
generateGradleBuild(request)
|
||||
.contains(
|
||||
"compile('org.springframework.boot:spring-boot-starter-data-jpa')")
|
||||
.contains("compile('org.springframework.boot:spring-boot-starter-web')") // Added
|
||||
// by
|
||||
// war
|
||||
// packaging
|
||||
// Added by warpackaging
|
||||
.contains("compile('org.springframework.boot:spring-boot-starter-web')")
|
||||
.contains(
|
||||
"testCompile('org.springframework.boot:spring-boot-starter-test')")
|
||||
.contains("configurations {") // declare providedRuntime config
|
||||
@@ -464,9 +462,8 @@ public class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
||||
.contains("compile('org.springframework.boot:spring-boot-starter-web')")
|
||||
.contains(
|
||||
"compile('org.springframework.boot:spring-boot-starter-data-jpa')")
|
||||
.contains("runtime('org.h2:h2')").contains("configurations {") // declare
|
||||
// providedRuntime
|
||||
// config
|
||||
// declare providedRuntime config
|
||||
.contains("runtime('org.h2:h2')").contains("configurations {")
|
||||
.contains("providedRuntime")
|
||||
.contains("providedRuntime('javax.servlet:servlet-api')")
|
||||
.contains("testCompile('org.hamcrest:hamcrest')");
|
||||
|
@@ -1,6 +1,20 @@
|
||||
package io.spring.initializr.generator;
|
||||
/*
|
||||
* Copyright 2012-2017 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.
|
||||
*/
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
package io.spring.initializr.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -8,12 +22,14 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests for {@link ProjectRequestResolver}.
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -16,20 +16,19 @@
|
||||
|
||||
package io.spring.initializr.generator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import io.spring.initializr.metadata.BillOfMaterials;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.metadata.InitializrMetadataBuilder;
|
||||
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -16,20 +16,19 @@
|
||||
|
||||
package io.spring.initializr.metadata;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.hamcrest.CoreMatchers.sameInstance;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import io.spring.initializr.metadata.BillOfMaterials.Mapping;
|
||||
import io.spring.initializr.util.Version;
|
||||
import io.spring.initializr.util.VersionParser;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.hamcrest.CoreMatchers.sameInstance;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
|
@@ -16,18 +16,17 @@
|
||||
|
||||
package io.spring.initializr.metadata;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.spring.initializr.util.Version;
|
||||
import io.spring.initializr.util.VersionParser;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import io.spring.initializr.util.Version;
|
||||
import io.spring.initializr.util.VersionParser;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
|
@@ -16,14 +16,12 @@
|
||||
|
||||
package io.spring.initializr.metadata;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
||||
import org.springframework.boot.bind.PropertiesConfigurationFactory;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
@@ -31,6 +29,9 @@ import org.springframework.core.env.PropertiesPropertySource;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -16,18 +16,17 @@
|
||||
|
||||
package io.spring.initializr.metadata;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import io.spring.initializr.metadata.BillOfMaterials.Mapping;
|
||||
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
|
||||
import io.spring.initializr.util.Version;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
|
@@ -16,10 +16,6 @@
|
||||
|
||||
package io.spring.initializr.metadata;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -29,6 +25,10 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests for {@link Link}.
|
||||
*
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -36,7 +36,7 @@ public class SingleSelectCapabilityTests {
|
||||
public void defaultNoDefault() {
|
||||
SingleSelectCapability capability = new SingleSelectCapability("test");
|
||||
capability.getContent().add(DefaultMetadataElement.create("foo", false));
|
||||
capability.getContent().add(DefaultMetadataElement.create("bar",false));
|
||||
capability.getContent().add(DefaultMetadataElement.create("bar", false));
|
||||
assertNull(capability.getDefault());
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class SingleSelectCapabilityTests {
|
||||
public void defaultType() {
|
||||
SingleSelectCapability capability = new SingleSelectCapability("test");
|
||||
capability.getContent().add(DefaultMetadataElement.create("foo", false));
|
||||
DefaultMetadataElement second = DefaultMetadataElement.create("bar",true);
|
||||
DefaultMetadataElement second = DefaultMetadataElement.create("bar", true);
|
||||
capability.getContent().add(second);
|
||||
assertEquals(second, capability.getDefault());
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class SingleSelectCapabilityTests {
|
||||
capability.getContent().add(foo);
|
||||
|
||||
SingleSelectCapability anotherCapability = new SingleSelectCapability("test");
|
||||
DefaultMetadataElement bar =DefaultMetadataElement.create("bar", false);
|
||||
DefaultMetadataElement bar = DefaultMetadataElement.create("bar", false);
|
||||
anotherCapability.getContent().add(bar);
|
||||
|
||||
capability.merge(anotherCapability);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package io.spring.initializr.metadata;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package io.spring.initializr.metadata;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@@ -63,20 +63,20 @@ public class TypeCapabilityTests {
|
||||
@Test
|
||||
public void mergeAddEntry() {
|
||||
TypeCapability capability = new TypeCapability();
|
||||
Type first = new Type();
|
||||
first.setId("foo");
|
||||
first.setDefault(false);
|
||||
capability.getContent().add(first);
|
||||
Type first = new Type();
|
||||
first.setId("foo");
|
||||
first.setDefault(false);
|
||||
capability.getContent().add(first);
|
||||
|
||||
TypeCapability anotherCapability = new TypeCapability();
|
||||
Type another = new Type();
|
||||
another.setId("foo");
|
||||
another.setDefault(false);
|
||||
Type second = new Type();
|
||||
second.setId("bar");
|
||||
second.setDefault(true);
|
||||
anotherCapability.getContent().add(another);
|
||||
anotherCapability.getContent().add(second);
|
||||
Type another = new Type();
|
||||
another.setId("foo");
|
||||
another.setDefault(false);
|
||||
Type second = new Type();
|
||||
second.setId("bar");
|
||||
second.setDefault(true);
|
||||
anotherCapability.getContent().add(another);
|
||||
anotherCapability.getContent().add(second);
|
||||
|
||||
capability.merge(anotherCapability);
|
||||
assertEquals(2, capability.getContent().size());
|
||||
|
@@ -44,7 +44,7 @@ public class GradleBuildAssert {
|
||||
}
|
||||
|
||||
public GradleBuildAssert hasArtifactId(String artifactId) {
|
||||
return contains("baseName = '"+ artifactId+"'");
|
||||
return contains("baseName = '" + artifactId + "'");
|
||||
}
|
||||
|
||||
public GradleBuildAssert hasVersion(String version) {
|
||||
|
@@ -16,16 +16,16 @@
|
||||
|
||||
package io.spring.initializr.test.generator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.metadata.BillOfMaterials;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrConfiguration.Env.Maven.ParentPom;
|
||||
import io.spring.initializr.metadata.Repository;
|
||||
import org.custommonkey.xmlunit.SimpleNamespaceContext;
|
||||
import org.custommonkey.xmlunit.XMLUnit;
|
||||
import org.custommonkey.xmlunit.XpathEngine;
|
||||
@@ -37,11 +37,10 @@ import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import io.spring.initializr.generator.ProjectRequest;
|
||||
import io.spring.initializr.metadata.BillOfMaterials;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrConfiguration.Env.Maven.ParentPom;
|
||||
import io.spring.initializr.metadata.Repository;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* XPath assertions that are specific to a standard Maven POM.
|
||||
@@ -231,7 +230,7 @@ public class PomAssert {
|
||||
dependency.getScope());
|
||||
}
|
||||
if (expected.getType() != null) {
|
||||
assertEquals("Wrong type for "+ dependency, expected.getType(),
|
||||
assertEquals("Wrong type for " + dependency, expected.getType(),
|
||||
dependency.getType());
|
||||
}
|
||||
return this;
|
||||
|
@@ -16,9 +16,6 @@
|
||||
|
||||
package io.spring.initializr.test.generator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -30,6 +27,9 @@ import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Various project based assertions.
|
||||
*
|
||||
@@ -74,8 +74,8 @@ public class ProjectAssert {
|
||||
assertTrue("No directory " + name + " found in " + dir.getAbsolutePath(),
|
||||
projectDir.exists());
|
||||
assertTrue(name + " is not a directory", projectDir.isDirectory());
|
||||
return new ProjectAssert(projectDir); // Replacing the root dir so that other
|
||||
// assertions match the root
|
||||
// Replacing the root dir so that other assertions match the root
|
||||
return new ProjectAssert(projectDir);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,8 +201,8 @@ public class ProjectAssert {
|
||||
String packageName = expectedPackageName.replace(".", "/");
|
||||
return isGenericProject(expectedPackageName, expectedApplicationName,
|
||||
codeLocation, extension).hasStaticAndTemplatesResources(true)
|
||||
.hasFile("src/main/" + codeLocation + "/" + packageName
|
||||
+ "/ServletInitializer." + extension);
|
||||
.hasFile("src/main/" + codeLocation + "/" + packageName
|
||||
+ "/ServletInitializer." + extension);
|
||||
}
|
||||
|
||||
public ProjectAssert hasStaticAndTemplatesResources(boolean web) {
|
||||
|
@@ -20,8 +20,6 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import io.spring.initializr.metadata.BillOfMaterials;
|
||||
import io.spring.initializr.metadata.DefaultMetadataElement;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
@@ -32,6 +30,8 @@ import io.spring.initializr.metadata.InitializrMetadataBuilder;
|
||||
import io.spring.initializr.metadata.Repository;
|
||||
import io.spring.initializr.metadata.Type;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Easily create a {@link InitializrMetadata} instance for testing purposes.
|
||||
*
|
||||
@@ -111,7 +111,7 @@ public class InitializrMetadataTestBuilder {
|
||||
}
|
||||
|
||||
public InitializrMetadataTestBuilder addPackaging(String id, boolean defaultValue) {
|
||||
builder.withCustomizer(it -> {
|
||||
builder.withCustomizer(it -> {
|
||||
DefaultMetadataElement packaging = new DefaultMetadataElement();
|
||||
packaging.setId(id);
|
||||
packaging.setName(id);
|
||||
@@ -126,7 +126,7 @@ public class InitializrMetadataTestBuilder {
|
||||
}
|
||||
|
||||
public InitializrMetadataTestBuilder addJavaVersion(String version, boolean defaultValue) {
|
||||
builder.withCustomizer(it -> {
|
||||
builder.withCustomizer(it -> {
|
||||
DefaultMetadataElement element = new DefaultMetadataElement();
|
||||
element.setId(version);
|
||||
element.setName(version);
|
||||
@@ -141,7 +141,7 @@ public class InitializrMetadataTestBuilder {
|
||||
}
|
||||
|
||||
public InitializrMetadataTestBuilder addLanguage(String id, boolean defaultValue) {
|
||||
builder.withCustomizer(it -> {
|
||||
builder.withCustomizer(it -> {
|
||||
DefaultMetadataElement element = new DefaultMetadataElement();
|
||||
element.setId(id);
|
||||
element.setName(id);
|
||||
@@ -157,7 +157,7 @@ public class InitializrMetadataTestBuilder {
|
||||
}
|
||||
|
||||
public InitializrMetadataTestBuilder addBootVersion(String id, boolean defaultValue) {
|
||||
builder.withCustomizer(it -> {
|
||||
builder.withCustomizer(it -> {
|
||||
DefaultMetadataElement element = new DefaultMetadataElement();
|
||||
element.setId(id);
|
||||
element.setName(id);
|
||||
@@ -173,29 +173,29 @@ public class InitializrMetadataTestBuilder {
|
||||
}
|
||||
|
||||
public InitializrMetadataTestBuilder addBom(String id, BillOfMaterials bom) {
|
||||
builder.withCustomizer( it -> {
|
||||
builder.withCustomizer(it -> {
|
||||
it.getConfiguration().getEnv().getBoms().put(id, bom);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
public InitializrMetadataTestBuilder setGradleEnv(String dependencyManagementPluginVersion) {
|
||||
builder.withCustomizer( it-> {
|
||||
builder.withCustomizer(it -> {
|
||||
it.getConfiguration().getEnv().getGradle().setDependencyManagementPluginVersion(dependencyManagementPluginVersion);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
public InitializrMetadataTestBuilder setKotlinEnv(String kotlinVersion) {
|
||||
builder.withCustomizer( it-> {
|
||||
builder.withCustomizer(it -> {
|
||||
it.getConfiguration().getEnv().getKotlin().setVersion(kotlinVersion);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
public InitializrMetadataTestBuilder setMavenParent(String groupId, String artifactId,
|
||||
String version, boolean includeSpringBootBom) {
|
||||
builder.withCustomizer( it-> {
|
||||
String version, boolean includeSpringBootBom) {
|
||||
builder.withCustomizer(it -> {
|
||||
ParentPom parent = it.getConfiguration().getEnv().getMaven().getParent();
|
||||
parent.setGroupId(groupId);
|
||||
parent.setArtifactId(artifactId);
|
||||
@@ -206,7 +206,7 @@ public class InitializrMetadataTestBuilder {
|
||||
}
|
||||
|
||||
public InitializrMetadataTestBuilder addRepository(String id, String name, String url, boolean snapshotsEnabled) {
|
||||
builder.withCustomizer( it-> {
|
||||
builder.withCustomizer(it -> {
|
||||
Repository repo = new Repository();
|
||||
repo.setName(name);
|
||||
try {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package io.spring.initializr.util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link Agent}.
|
||||
*
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -16,11 +16,6 @@
|
||||
|
||||
package io.spring.initializr.util;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -29,6 +24,11 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* Tests for {@link VersionParser}.
|
||||
*
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package io.spring.initializr.util;
|
||||
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -28,6 +25,9 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 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.
|
||||
@@ -16,16 +16,16 @@
|
||||
|
||||
package io.spring.initializr.util;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.comparesEqualTo;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
Reference in New Issue
Block a user