Code formatting

This commit is contained in:
Stephane Nicoll
2017-02-10 12:14:55 +01:00
parent 53679aa860
commit 5296d6a05f
99 changed files with 722 additions and 660 deletions

View File

@@ -1,6 +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>
@@ -120,7 +121,8 @@
<configuration>
<attach>true</attach>
<descriptors>
<descriptor>${basedir}/src/assembly/snippets.xml</descriptor>
<descriptor>${basedir}/src/assembly/snippets.xml
</descriptor>
<descriptor>${basedir}/src/assembly/stub.xml</descriptor>
</descriptors>
</configuration>

View File

@@ -46,9 +46,9 @@ public class CloudfoundryEnvironmentPostProcessor
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment,
SpringApplication springApplication) {
SpringApplication springApplication) {
Map<String,Object> map = new LinkedHashMap<>();
Map<String, Object> map = new LinkedHashMap<>();
String uri = environment.getProperty("vcap.services.stats-index.credentials.uri");
if (StringUtils.hasText(uri)) {
UriComponents uriComponents = UriComponentsBuilder.fromUriString(uri).build();
@@ -71,7 +71,7 @@ public class CloudfoundryEnvironmentPostProcessor
}
private static void addOrReplace(MutablePropertySources propertySources,
Map<String, Object> map) {
Map<String, Object> map) {
MapPropertySource target = null;
if (propertySources.contains(PROPERTY_SOURCE_NAME)) {
PropertySource<?> source = propertySources.get(PROPERTY_SOURCE_NAME);

View File

@@ -21,6 +21,22 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.github.benmanes.caffeine.cache.Caffeine;
import io.spring.initializr.generator.ProjectGenerator;
import io.spring.initializr.generator.ProjectRequestPostProcessor;
import io.spring.initializr.generator.ProjectRequestResolver;
import io.spring.initializr.generator.ProjectResourceLocator;
import io.spring.initializr.metadata.DependencyMetadataProvider;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.metadata.InitializrMetadataBuilder;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import io.spring.initializr.metadata.InitializrProperties;
import io.spring.initializr.util.TemplateRenderer;
import io.spring.initializr.web.project.MainController;
import io.spring.initializr.web.support.DefaultDependencyMetadataProvider;
import io.spring.initializr.web.support.DefaultInitializrMetadataProvider;
import io.spring.initializr.web.ui.UiController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.bind.RelaxedPropertyResolver;
@@ -37,23 +53,6 @@ import org.springframework.core.env.Environment;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.resource.ResourceUrlProvider;
import com.github.benmanes.caffeine.cache.Caffeine;
import io.spring.initializr.generator.ProjectGenerator;
import io.spring.initializr.generator.ProjectRequestPostProcessor;
import io.spring.initializr.generator.ProjectRequestResolver;
import io.spring.initializr.generator.ProjectResourceLocator;
import io.spring.initializr.metadata.DependencyMetadataProvider;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.metadata.InitializrMetadataBuilder;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import io.spring.initializr.metadata.InitializrProperties;
import io.spring.initializr.util.TemplateRenderer;
import io.spring.initializr.web.project.MainController;
import io.spring.initializr.web.support.DefaultDependencyMetadataProvider;
import io.spring.initializr.web.support.DefaultInitializrMetadataProvider;
import io.spring.initializr.web.ui.UiController;
/**
* {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
* Auto-configuration} to configure Spring initializr. In a web environment,
@@ -81,10 +80,10 @@ public class InitializrAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public MainController initializrMainController(InitializrMetadataProvider metadataProvider,
TemplateRenderer templateRenderer,
ResourceUrlProvider resourceUrlProvider,
ProjectGenerator projectGenerator,
DependencyMetadataProvider dependencyMetadataProvider) {
TemplateRenderer templateRenderer,
ResourceUrlProvider resourceUrlProvider,
ProjectGenerator projectGenerator,
DependencyMetadataProvider dependencyMetadataProvider) {
return new MainController(metadataProvider, templateRenderer, resourceUrlProvider
, projectGenerator, dependencyMetadataProvider);
}

View File

@@ -21,6 +21,9 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest;
import io.spring.initializr.util.Agent;
import io.spring.initializr.util.Agent.AgentId;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
@@ -31,9 +34,6 @@ import org.springframework.web.servlet.config.annotation.ContentNegotiationConfi
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.util.UrlPathHelper;
import io.spring.initializr.util.Agent;
import io.spring.initializr.util.Agent.AgentId;
/**
* Spring Initializr web configuration.
*
@@ -62,12 +62,12 @@ public class WebConfig extends WebMvcConfigurerAdapter {
return Collections.emptyList();
}
String userAgent = request.getHeader(HttpHeaders.USER_AGENT);
if (userAgent!=null) {
if (userAgent != null) {
Agent agent = Agent.fromUserAgent(userAgent);
if (agent!=null) {
if (AgentId.CURL.equals(agent.getId()) || AgentId.HTTPIE.equals(agent.getId())) {
return Collections.singletonList(MediaType.TEXT_PLAIN);
}
if (agent != null) {
if (AgentId.CURL.equals(agent.getId()) || AgentId.HTTPIE.equals(agent.getId())) {
return Collections.singletonList(MediaType.TEXT_PLAIN);
}
}
}
return Collections.singletonList(MediaType.APPLICATION_JSON);

View File

@@ -20,12 +20,11 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
import org.json.JSONObject;
import io.spring.initializr.metadata.BillOfMaterials;
import io.spring.initializr.metadata.Dependency;
import io.spring.initializr.metadata.DependencyMetadata;
import io.spring.initializr.metadata.Repository;
import org.json.JSONObject;
/**
* A {@link DependencyMetadataJsonMapper} handling the metadata format for v2.1.

View File

@@ -20,14 +20,14 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import io.spring.initializr.metadata.Dependency;
import io.spring.initializr.metadata.Type;
import org.json.JSONObject;
import org.springframework.hateoas.TemplateVariable;
import org.springframework.hateoas.TemplateVariables;
import org.springframework.hateoas.UriTemplate;
import io.spring.initializr.metadata.Dependency;
import io.spring.initializr.metadata.Type;
/**
* A {@link InitializrMetadataJsonMapper} handling the metadata format for v2.1
* <p>
@@ -50,7 +50,7 @@ public class InitializrMetadataV21JsonMapper extends InitializrMetadataV2JsonMap
@Override
protected Map<String, Object> links(JSONObject parent, List<Type> types, String appUrl) {
Map<String, Object> links = super.links(parent, types, appUrl);
links.put("dependencies", dependenciesLink(appUrl));
links.put("dependencies", dependenciesLink(appUrl));
parent.put("_links", links);
return links;
}
@@ -58,10 +58,10 @@ public class InitializrMetadataV21JsonMapper extends InitializrMetadataV2JsonMap
@Override
protected Map<String, Object> mapDependency(Dependency dependency) {
Map<String, Object> content = mapValue(dependency);
if (dependency.getVersionRange()!=null) {
if (dependency.getVersionRange() != null) {
content.put("versionRange", dependency.getVersionRange());
}
if (dependency.getLinks()!=null && !dependency.getLinks().isEmpty()) {
if (dependency.getLinks() != null && !dependency.getLinks().isEmpty()) {
content.put("_links", LinkMapper.mapLinks(dependency.getLinks()));
}
return content;

View File

@@ -22,12 +22,6 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.json.JSONObject;
import org.springframework.hateoas.TemplateVariable;
import org.springframework.hateoas.TemplateVariables;
import org.springframework.hateoas.UriTemplate;
import org.springframework.util.StringUtils;
import io.spring.initializr.metadata.DefaultMetadataElement;
import io.spring.initializr.metadata.DependenciesCapability;
import io.spring.initializr.metadata.Dependency;
@@ -39,6 +33,12 @@ import io.spring.initializr.metadata.SingleSelectCapability;
import io.spring.initializr.metadata.TextCapability;
import io.spring.initializr.metadata.Type;
import io.spring.initializr.metadata.TypeCapability;
import org.json.JSONObject;
import org.springframework.hateoas.TemplateVariable;
import org.springframework.hateoas.TemplateVariables;
import org.springframework.hateoas.UriTemplate;
import org.springframework.util.StringUtils;
/**
* A {@link InitializrMetadataJsonMapper} handling the metadata format for v2.
@@ -176,7 +176,7 @@ public class InitializrMetadataV2JsonMapper implements InitializrMetadataJsonMap
}
protected Map<String, Object> mapDependency(Dependency dependency) {
if (dependency.getVersionRange() == null) {
if (dependency.getVersionRange() == null) {
// only map the dependency if no versionRange is set
return mapValue(dependency);
}

View File

@@ -23,17 +23,17 @@ import java.util.function.Function;
import javax.servlet.http.HttpServletResponse;
import io.spring.initializr.generator.InvalidProjectRequestException;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import io.spring.initializr.metadata.TypeCapability;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.resource.ResourceUrlProvider;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import io.spring.initializr.generator.InvalidProjectRequestException;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import io.spring.initializr.metadata.TypeCapability;
/**
* A base controller that uses a {@link InitializrMetadataProvider}
*
@@ -72,7 +72,7 @@ public abstract class AbstractInitializrController {
/**
* Render the home page with the specified template.
*/
protected void renderHome(Map<String,Object> model) throws Exception {
protected void renderHome(Map<String, Object> model) throws Exception {
InitializrMetadata metadata = metadataProvider.get();
model.put("serviceUrl", generateAppUrl());
@@ -80,7 +80,8 @@ public abstract class AbstractInitializrController {
for (PropertyDescriptor descriptor : wrapper.getPropertyDescriptors()) {
if ("types".equals(descriptor.getName())) {
model.put("types", removeTypes(metadata.getTypes()));
} else {
}
else {
model.put(descriptor.getName(), wrapper.getPropertyValue(descriptor.getName()));
}
}
@@ -101,7 +102,7 @@ public abstract class AbstractInitializrController {
result.setTitle(types.getTitle());
result.getContent().addAll(types.getContent());
// Only keep project type
result.getContent().removeIf(t -> !"project".equals(t.getTags().get("format")) );
result.getContent().removeIf(t -> !"project".equals(t.getTags().get("format")));
return result;
}

View File

@@ -18,12 +18,12 @@ package io.spring.initializr.web.project;
import java.util.Map;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.resource.ResourceUrlProvider;
import io.spring.initializr.metadata.InitializrMetadataProvider;
/**
* A controller used to serve the legacy home page used by STS.
*
@@ -35,7 +35,7 @@ public class LegacyStsController extends AbstractInitializrController {
public LegacyStsController(InitializrMetadataProvider metadataProvider, ResourceUrlProvider resourceUrlProvider) {
super(metadataProvider, resourceUrlProvider);
}
@RequestMapping(value = "/sts", produces = "text/html")
public String stsHome(Map<String, Object> model) throws Exception {
renderHome(model);

View File

@@ -16,10 +16,6 @@
package io.spring.initializr.web.project;
import static io.spring.initializr.util.Agent.AgentId.CURL;
import static io.spring.initializr.util.Agent.AgentId.HTTPIE;
import static io.spring.initializr.util.Agent.AgentId.SPRING_BOOT_CLI;
import java.io.File;
import java.io.FileInputStream;
import java.io.UnsupportedEncodingException;
@@ -28,26 +24,7 @@ import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.rauschig.jarchivelib.ArchiverFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.CacheControl;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.ResponseEntity.BodyBuilder;
import org.springframework.stereotype.Controller;
import org.springframework.util.DigestUtils;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.resource.ResourceUrlProvider;
import com.samskivert.mustache.Mustache;
import io.spring.initializr.generator.BasicProjectRequest;
import io.spring.initializr.generator.CommandLineHelpGenerator;
import io.spring.initializr.generator.ProjectGenerator;
@@ -64,6 +41,28 @@ import io.spring.initializr.web.mapper.InitializrMetadataJsonMapper;
import io.spring.initializr.web.mapper.InitializrMetadataV21JsonMapper;
import io.spring.initializr.web.mapper.InitializrMetadataV2JsonMapper;
import io.spring.initializr.web.mapper.InitializrMetadataVersion;
import org.rauschig.jarchivelib.ArchiverFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.CacheControl;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.ResponseEntity.BodyBuilder;
import org.springframework.stereotype.Controller;
import org.springframework.util.DigestUtils;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.resource.ResourceUrlProvider;
import static io.spring.initializr.util.Agent.AgentId.CURL;
import static io.spring.initializr.util.Agent.AgentId.HTTPIE;
import static io.spring.initializr.util.Agent.AgentId.SPRING_BOOT_CLI;
/**
* The main initializr controller provides access to the configured metadata and serves as
@@ -179,10 +178,10 @@ public class MainController extends AbstractInitializrController {
private static InitializrMetadataJsonMapper getJsonMapper(
InitializrMetadataVersion version) {
switch (version) {
case V2:
return new InitializrMetadataV2JsonMapper();
default:
return new InitializrMetadataV21JsonMapper();
case V2:
return new InitializrMetadataV2JsonMapper();
default:
return new InitializrMetadataV21JsonMapper();
}
}

View File

@@ -19,8 +19,6 @@ package io.spring.initializr.web.support;
import java.util.LinkedHashMap;
import java.util.Map;
import org.springframework.cache.annotation.Cacheable;
import io.spring.initializr.metadata.BillOfMaterials;
import io.spring.initializr.metadata.Dependency;
import io.spring.initializr.metadata.DependencyMetadata;
@@ -29,6 +27,8 @@ import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.metadata.Repository;
import io.spring.initializr.util.Version;
import org.springframework.cache.annotation.Cacheable;
/**
* A default {@link DependencyMetadataProvider} implementation.
*
@@ -48,14 +48,14 @@ public class DefaultDependencyMetadataProvider implements DependencyMetadataProv
Map<String, Repository> repositories = new LinkedHashMap<>();
for (Dependency d : dependencies.values()) {
if (d.getRepository()!=null) {
if (d.getRepository() != null) {
repositories.put(d.getRepository(), metadata.getConfiguration().getEnv().getRepositories().get(d.getRepository()));
}
}
Map<String, BillOfMaterials> boms = new LinkedHashMap<>();
for (Dependency d : dependencies.values()) {
if (d.getBom()!=null) {
if (d.getBom() != null) {
boms.put(d.getBom(), metadata.getConfiguration().getEnv().getBoms().get(d.getBom()).resolve(bootVersion));
}
}

View File

@@ -18,15 +18,15 @@ package io.spring.initializr.web.support;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import io.spring.initializr.metadata.DefaultMetadataElement;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
/**
* A default {@link InitializrMetadataProvider} that is able to refresh
@@ -35,7 +35,7 @@ import io.spring.initializr.metadata.InitializrMetadataProvider;
* @author Stephane Nicoll
*/
public class DefaultInitializrMetadataProvider implements InitializrMetadataProvider {
private static final Logger log = LoggerFactory
.getLogger(DefaultInitializrMetadataProvider.class);
@@ -56,7 +56,7 @@ public class DefaultInitializrMetadataProvider implements InitializrMetadataProv
protected void updateInitializrMetadata(InitializrMetadata metadata) {
List<DefaultMetadataElement> bootVersions = fetchBootVersions();
if (bootVersions!=null && !bootVersions.isEmpty()) {
if (bootVersions != null && !bootVersions.isEmpty()) {
if (bootVersions.stream().noneMatch(it -> it.isDefault())) { // No default specified
bootVersions.get(0).setDefault(true);
}
@@ -70,7 +70,8 @@ public class DefaultInitializrMetadataProvider implements InitializrMetadataProv
try {
log.info("Fetching boot metadata from {}", url);
return new SpringBootMetadataReader(restTemplate, url).getBootVersions();
} catch (Exception e) {
}
catch (Exception e) {
log.warn("Failed to fetch spring boot metadata", e);
}
}

View File

@@ -19,12 +19,11 @@ package io.spring.initializr.web.support;
import java.util.ArrayList;
import java.util.List;
import io.spring.initializr.metadata.DefaultMetadataElement;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
import io.spring.initializr.metadata.DefaultMetadataElement;
import org.springframework.web.client.RestTemplate;
/**
* Reads metadata from the main spring.io website. This is a stateful
@@ -50,7 +49,7 @@ public class SpringBootMetadataReader {
public List<DefaultMetadataElement> getBootVersions() {
JSONArray array = content.getJSONArray("projectReleases");
List<DefaultMetadataElement> list = new ArrayList<>();
for (int i=0; i<array.length(); i++) {
for (int i = 0; i < array.length(); i++) {
JSONObject it = array.getJSONObject(i);
DefaultMetadataElement version = new DefaultMetadataElement();
version.setId(it.getString("version"));

View File

@@ -22,7 +22,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.spring.initializr.metadata.Dependency;
import io.spring.initializr.metadata.DependencyGroup;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import io.spring.initializr.util.Version;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@@ -33,11 +38,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.spring.initializr.metadata.Dependency;
import io.spring.initializr.metadata.DependencyGroup;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import io.spring.initializr.util.Version;
/**
* UI specific controller providing dedicated endpoints for the Web UI.
*
@@ -56,11 +56,12 @@ public class UiController {
Version v = StringUtils.isEmpty(version) ? null : Version.parse(version);
dependencyGroups.forEach(g -> {
g.getContent().forEach(d -> {
if (v!=null && d.getVersionRange()!=null) {
if (v != null && d.getVersionRange() != null) {
if (d.match(v)) {
content.add(new DependencyItem(g.getName(), d));
}
} else {
}
else {
content.add(new DependencyItem(g.getName(), d));
}
});
@@ -84,10 +85,10 @@ public class UiController {
result.put("id", d.getId());
result.put("name", d.getName());
result.put("group", item.group);
if (d.getDescription()!=null) {
if (d.getDescription() != null) {
result.put("description", d.getDescription());
}
if (d.getWeight()>0) {
if (d.getWeight() > 0) {
result.put("weight", d.getWeight());
}
if (!CollectionUtils.isEmpty(d.getKeywords()) || !CollectionUtils.isEmpty(d.getAliases())) {

View File

@@ -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,14 +16,15 @@
package io.spring.initializr.web;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
import io.spring.initializr.web.AbstractInitializrIntegrationTests.Config;
import org.junit.runner.RunWith;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
/**
* @author Stephane Nicoll
* @author Dave Syer

View File

@@ -16,6 +16,10 @@
package io.spring.initializr.web;
import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests.RestTemplateConfig;
import io.spring.initializr.web.test.MockMvcClientHttpRequestFactory;
import io.spring.initializr.web.test.MockMvcClientHttpRequestFactoryTestExecutionListener;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs;
@@ -27,10 +31,6 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.TestExecutionListeners.MergeMode;
import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests.RestTemplateConfig;
import io.spring.initializr.web.test.MockMvcClientHttpRequestFactory;
import io.spring.initializr.web.test.MockMvcClientHttpRequestFactoryTestExecutionListener;
/**
* @author Stephane Nicoll
*/

View File

@@ -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,8 +16,6 @@
package io.spring.initializr.web;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -28,6 +26,14 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.metadata.InitializrMetadataBuilder;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import io.spring.initializr.metadata.InitializrProperties;
import io.spring.initializr.test.generator.ProjectAssert;
import io.spring.initializr.web.AbstractInitializrIntegrationTests.Config;
import io.spring.initializr.web.mapper.InitializrMetadataVersion;
import io.spring.initializr.web.support.DefaultInitializrMetadataProvider;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Rule;
@@ -36,6 +42,7 @@ import org.junit.runner.RunWith;
import org.rauschig.jarchivelib.ArchiverFactory;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
@@ -51,14 +58,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.StreamUtils;
import org.springframework.web.client.RestTemplate;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.metadata.InitializrMetadataBuilder;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import io.spring.initializr.metadata.InitializrProperties;
import io.spring.initializr.test.generator.ProjectAssert;
import io.spring.initializr.web.AbstractInitializrIntegrationTests.Config;
import io.spring.initializr.web.mapper.InitializrMetadataVersion;
import io.spring.initializr.web.support.DefaultInitializrMetadataProvider;
import static org.junit.Assert.assertTrue;
/**
* @author Stephane Nicoll
@@ -183,12 +183,12 @@ public abstract class AbstractInitializrIntegrationTests {
File project = folder.newFolder();
switch (archiveType) {
case ZIP:
ArchiverFactory.createArchiver("zip").extract(archiveFile, project);
break;
case TGZ:
ArchiverFactory.createArchiver("tar", "gz").extract(archiveFile, project);
break;
case ZIP:
ArchiverFactory.createArchiver("zip").extract(archiveFile, project);
break;
case TGZ:
ArchiverFactory.createArchiver("tar", "gz").extract(archiveFile, project);
break;
}
return new ProjectAssert(project);
}

View File

@@ -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,14 +16,15 @@
package io.spring.initializr.web.autoconfigure;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.mock.env.MockEnvironment;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.mock.env.MockEnvironment;
/**
* @author Stephane Nicoll
*/

View File

@@ -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,19 +16,18 @@
package io.spring.initializr.web.mapper;
import static org.junit.Assert.assertEquals;
import java.net.URL;
import java.util.Collections;
import org.json.JSONObject;
import org.junit.Test;
import io.spring.initializr.metadata.BillOfMaterials;
import io.spring.initializr.metadata.Dependency;
import io.spring.initializr.metadata.DependencyMetadata;
import io.spring.initializr.metadata.Repository;
import io.spring.initializr.util.Version;
import org.json.JSONObject;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author Stephane Nicoll

View File

@@ -16,16 +16,15 @@
package io.spring.initializr.web.mapper;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.json.JSONObject;
import org.junit.Test;
import io.spring.initializr.metadata.Dependency;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.metadata.Link;
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
import org.json.JSONObject;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Stephane Nicoll
@@ -51,12 +50,12 @@ public class InitializrMetadataJsonMapperTests {
String json = jsonMapper.write(metadata, "http://server:8080/my-app");
JSONObject result = new JSONObject(json);
assertEquals("http://server:8080/my-app/foo.zip?type=foo{&dependencies,packaging,javaVersion," +
"language,bootVersion,groupId,artifactId,version,name,description,packageName}",
"language,bootVersion,groupId,artifactId,version,name,description,packageName}",
get(result, "_links.foo.href"));
}
@Test
public void linksRendered() {
public void linksRendered() {
Dependency dependency = Dependency.withId("foo", "com.example", "foo");
dependency.getLinks().add(Link.create("guide", "https://example.com/how-to"));
dependency.getLinks().add(Link.create("reference", "https://example.com/doc"));
@@ -66,17 +65,17 @@ public class InitializrMetadataJsonMapperTests {
int first = json.indexOf("https://example.com/how-to");
int second = json.indexOf("https://example.com/doc");
// JSON objects are not ordered
assertTrue(first>0);
assertTrue(second>0);
assertTrue(first > 0);
assertTrue(second > 0);
}
private Object get(JSONObject result, String path) {
String[] nodes = path.split("\\.");
for (int i = 0; i < nodes.length-1; i++) {
for (int i = 0; i < nodes.length - 1; i++) {
String node = nodes[i];
result = result.getJSONObject(node);
}
return result.getString(nodes[nodes.length-1]);
return result.getString(nodes[nodes.length - 1]);
}
}

View File

@@ -16,16 +16,15 @@
package io.spring.initializr.web.mapper;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import io.spring.initializr.metadata.Link;
import org.junit.Test;
import io.spring.initializr.metadata.Link;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* Tests for {@link LinkMapper}.

View File

@@ -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,12 +16,12 @@
package io.spring.initializr.web.project;
import org.junit.Test;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import io.spring.initializr.test.generator.PomAssert;
import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests;
import org.junit.Test;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
/**
* Validate that the "raw" HTTP commands that are described in the

View File

@@ -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,13 @@
package io.spring.initializr.web.project;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests;
import io.spring.initializr.web.project.LegacyStsControllerIntegrationTests.LegacyConfig;
import org.junit.Test;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpEntity;
@@ -31,9 +33,7 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.web.servlet.resource.ResourceUrlProvider;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests;
import io.spring.initializr.web.project.LegacyStsControllerIntegrationTests.LegacyConfig;
import static org.junit.Assert.assertTrue;
/**
* @author Stephane Nicoll
@@ -49,8 +49,8 @@ public class LegacyStsControllerIntegrationTests
assertTrue("groupId not found", body.contains("com.example"));
assertTrue("artifactId not found", body.contains("demo"));
assertTrue("custom description not found", body.contains("Demo project for Spring Boot"));
assertTrue ("Wrong body:\n" + body, body.contains("<input type=\"radio\" name=\"language\" value=\"groovy\"/>"));
assertTrue ("Wrong body:\n" + body, body.contains("<input type=\"radio\" name=\"language\" value=\"java\" checked=\"true\"/>"));
assertTrue("Wrong body:\n" + body, body.contains("<input type=\"radio\" name=\"language\" value=\"groovy\"/>"));
assertTrue("Wrong body:\n" + body, body.contains("<input type=\"radio\" name=\"language\" value=\"java\" checked=\"true\"/>"));
}
protected String htmlHome() {

View File

@@ -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,18 @@
package io.spring.initializr.web.project;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.springframework.test.context.ActiveProfiles;
import io.spring.initializr.test.generator.PomAssert;
import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests;
import org.junit.Test;
import org.springframework.test.context.ActiveProfiles;
import static org.junit.Assert.assertTrue;
/**
* @author Stephane Nicoll
*/
@ActiveProfiles({"test-default", "test-custom-defaults"})
@ActiveProfiles({ "test-default", "test-custom-defaults" })
public class MainControllerDefaultsIntegrationTests extends AbstractInitializrControllerIntegrationTests {
// see defaults customization

View File

@@ -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,24 +16,24 @@
package io.spring.initializr.web.project;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.net.URI;
import io.spring.initializr.test.generator.ProjectAssert;
import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests;
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import io.spring.initializr.test.generator.ProjectAssert;
import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* @author Stephane Nicoll
*/
@ActiveProfiles({"test-default", "test-custom-env"})
@ActiveProfiles({ "test-default", "test-custom-env" })
public class MainControllerEnvIntegrationTests extends AbstractInitializrControllerIntegrationTests {
@Test

View File

@@ -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,6 +16,24 @@
package io.spring.initializr.web.project;
import java.net.URI;
import java.net.URISyntaxException;
import io.spring.initializr.metadata.Dependency;
import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests;
import io.spring.initializr.web.mapper.InitializrMetadataVersion;
import org.json.JSONObject;
import org.junit.Ignore;
import org.junit.Test;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.web.client.HttpClientErrorException;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.nullValue;
@@ -27,24 +45,6 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.net.URI;
import java.net.URISyntaxException;
import org.json.JSONObject;
import org.junit.Ignore;
import org.junit.Test;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.web.client.HttpClientErrorException;
import io.spring.initializr.metadata.Dependency;
import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests;
import io.spring.initializr.web.mapper.InitializrMetadataVersion;
/**
* @author Stephane Nicoll
*/
@@ -81,7 +81,7 @@ public class MainControllerIntegrationTests
@Test
public void dependencyNotInRange() {
try {
execute("/starter.tgz?style=org.acme:bur", byte[].class, null, (String[])null);
execute("/starter.tgz?style=org.acme:bur", byte[].class, null, (String[]) null);
}
catch (HttpClientErrorException ex) {
assertEquals(HttpStatus.NOT_ACCEPTABLE, ex.getStatusCode());
@@ -92,8 +92,8 @@ public class MainControllerIntegrationTests
public void noDependencyProject() {
downloadZip("/starter.zip").isJavaProject().isMavenProject()
.hasStaticAndTemplatesResources(false).pomAssert().hasDependenciesCount(2)
.hasSpringBootStarterRootDependency() // the root dep is added if none is
// specified
// the root dep is added if none is specified
.hasSpringBootStarterRootDependency()
.hasSpringBootStarterTest();
}
@@ -349,7 +349,8 @@ public class MainControllerIntegrationTests
try {
downloadArchive("/starter.zip?style=foo:bar");
fail("Should have failed");
} catch (HttpClientErrorException ex) {
}
catch (HttpClientErrorException ex) {
assertEquals(HttpStatus.BAD_REQUEST, ex.getStatusCode());
assertStandardErrorBody(ex.getResponseBodyAsString(),
"Unknown dependency 'foo:bar' check project metadata");
@@ -361,7 +362,8 @@ public class MainControllerIntegrationTests
try {
downloadArchive("/starter.zip?style=foo");
fail("Should have failed");
} catch (HttpClientErrorException ex) {
}
catch (HttpClientErrorException ex) {
assertEquals(HttpStatus.BAD_REQUEST, ex.getStatusCode());
assertStandardErrorBody(ex.getResponseBodyAsString(),
"Unknown dependency 'foo' check project metadata");
@@ -371,18 +373,18 @@ public class MainControllerIntegrationTests
@Test
public void homeIsForm() {
String body = htmlHome();
assertTrue ("Wrong body:\n" + body, body.contains("action=\"/starter.zip\""));
assertTrue ("Wrong body:\n" + body, body.contains("Web dependency description"));
assertFalse ("Wrong body:\n" + body, body.contains("${"));
assertFalse ("Wrong body:\n" + body, body.contains("{{"));
assertFalse ("Wrong body:\n" + body, body.contains("}}"));
assertTrue ("Wrong body:\n" + body, body.contains("<option value=\"groovy\">"));
assertTrue ("Wrong body:\n" + body, body.contains("<option value=\"java\" selected>"));
assertTrue("Wrong body:\n" + body, body.contains("action=\"/starter.zip\""));
assertTrue("Wrong body:\n" + body, body.contains("Web dependency description"));
assertFalse("Wrong body:\n" + body, body.contains("${"));
assertFalse("Wrong body:\n" + body, body.contains("{{"));
assertFalse("Wrong body:\n" + body, body.contains("}}"));
assertTrue("Wrong body:\n" + body, body.contains("<option value=\"groovy\">"));
assertTrue("Wrong body:\n" + body, body.contains("<option value=\"java\" selected>"));
}
@Test
public void homeIsJson() {
String body = invokeHome(null, (String[])null).getBody();
String body = invokeHome(null, (String[]) null).getBody();
assertTrue("Wrong body:\n$body", body.contains("\"dependencies\""));
}

View File

@@ -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,15 @@
package io.spring.initializr.web.project;
import static org.junit.Assert.assertEquals;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.metadata.InitializrMetadataBuilder;
import io.spring.initializr.metadata.InitializrMetadataProvider;
import io.spring.initializr.web.AbstractFullStackInitializrIntegrationTests;
import org.json.JSONObject;
import org.junit.Test;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.UrlResource;
import org.springframework.http.HttpStatus;
@@ -34,6 +33,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.web.client.HttpClientErrorException;
import static org.junit.Assert.assertEquals;
/**
* @author Stephane Nicoll
*/

View File

@@ -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,14 @@
package io.spring.initializr.web.project;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.stream.Collectors;
import io.spring.initializr.test.generator.ProjectAssert;
import io.spring.initializr.web.AbstractFullStackInitializrIntegrationTests;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
@@ -41,11 +39,13 @@ import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.Select;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.util.StreamUtils;
import io.spring.initializr.test.generator.ProjectAssert;
import io.spring.initializr.web.AbstractFullStackInitializrIntegrationTests;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Dave Syer

View File

@@ -1,11 +1,20 @@
package io.spring.initializr.web.project;
/*
* 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 org.junit.Test;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.Order;
import org.springframework.test.context.ActiveProfiles;
package io.spring.initializr.web.project;
import io.spring.initializr.generator.ProjectRequest;
import io.spring.initializr.generator.ProjectRequestPostProcessor;
@@ -13,6 +22,13 @@ import io.spring.initializr.generator.ProjectRequestPostProcessorAdapter;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests;
import io.spring.initializr.web.project.ProjectGenerationPostProcessorTests.ProjectRequestPostProcessorConfiguration;
import org.junit.Test;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.Order;
import org.springframework.test.context.ActiveProfiles;
@ActiveProfiles("test-default")
@Import(ProjectRequestPostProcessorConfiguration.class)

View File

@@ -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.
@@ -26,7 +26,7 @@ import io.spring.initializr.util.Version;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;;
import static org.junit.Assert.assertSame;
/**
* @author Stephane Nicoll

View File

@@ -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,14 @@
package io.spring.initializr.web.support;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import java.util.List;
import io.spring.initializr.metadata.DefaultMetadataElement;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -34,9 +32,11 @@ import org.springframework.http.MediaType;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
import io.spring.initializr.metadata.DefaultMetadataElement;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
/**
* @author Stephane Nicoll
@@ -102,8 +102,8 @@ public class DefaultInitializrMetadataProviderTests {
this.mockServer.expect(requestTo(url))
.andExpect(method(HttpMethod.GET))
.andRespond(withStatus(HttpStatus.OK)
.body(new ClassPathResource(bodyPath))
.headers(httpHeaders));
.body(new ClassPathResource(bodyPath))
.headers(httpHeaders));
}
}

View File

@@ -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,10 +16,14 @@
package io.spring.initializr.web.support;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import io.spring.initializr.metadata.DefaultMetadataElement;
import io.spring.initializr.metadata.InitializrMetadata;
import io.spring.initializr.metadata.InitializrMetadataBuilder;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.MediaType;
import org.springframework.test.web.client.MockRestServiceServer;
@@ -30,9 +34,6 @@ import static org.junit.Assert.fail;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* @author Stephane Nicoll
* @author Dave Syer
@@ -48,7 +49,7 @@ public class SpringBootMetadataReaderTests {
@Test
public void readAvailableVersions() {
server.expect(requestTo("https://spring.io/project_metadata/spring-boot")).andRespond(
withSuccess(new ClassPathResource("metadata/sagan/spring-boot.json"), MediaType.APPLICATION_JSON));
withSuccess(new ClassPathResource("metadata/sagan/spring-boot.json"), MediaType.APPLICATION_JSON));
List<DefaultMetadataElement> versions = new SpringBootMetadataReader(restTemplate,
metadata.getConfiguration().getEnv().getSpringBootMetadataUrl()).getBootVersions();
assertNotNull("spring boot versions should not be null", versions);

View File

@@ -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.
@@ -22,6 +22,7 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.servlet.RequestDispatcher;
import org.springframework.http.HttpHeaders;
@@ -39,9 +40,10 @@ import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.util.Assert;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.*;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.request;
/**
* @author Dave Syer

View File

@@ -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.
@@ -17,11 +17,11 @@
package io.spring.initializr.web.ui;
import io.spring.initializr.web.AbstractInitializrControllerIntegrationTests;
import org.json.JSONObject;
import org.junit.Test;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ActiveProfiles;