Fix formatting and checkstyle violations on initializr-service

See gh-676
This commit is contained in:
Stephane Nicoll
2018-06-01 07:51:14 +02:00
parent 4a336c6044
commit 5136274146
8 changed files with 74 additions and 49 deletions
@@ -51,6 +51,9 @@ public class InitializrService {
return new LegacyStsController(metadataProvider, resourceUrlProvider); return new LegacyStsController(metadataProvider, resourceUrlProvider);
} }
/**
* {@link Executor} configuration for event processing.
*/
@Configuration @Configuration
@EnableAsync @EnableAsync
static class AsyncConfiguration extends AsyncConfigurerSupport { static class AsyncConfiguration extends AsyncConfigurerSupport {
@@ -65,7 +65,7 @@ public class AbstractProjectRequestPostProcessor implements ProjectRequestPostPr
*/ */
protected Dependency getDependency(ProjectRequest request, String id) { protected Dependency getDependency(ProjectRequest request, String id) {
return request.getResolvedDependencies().stream() return request.getResolvedDependencies().stream()
.filter(d -> id.equals(d.getId())).findFirst().orElse(null); .filter((d) -> id.equals(d.getId())).findFirst().orElse(null);
} }
/** /**
@@ -67,9 +67,9 @@ class JavaVersionRequestPostProcessor implements ProjectRequestPostProcessor {
private Integer determineJavaGeneration(String javaVersion) { private Integer determineJavaGeneration(String javaVersion) {
try { try {
int generation = Integer.valueOf(javaVersion); int generation = Integer.valueOf(javaVersion);
return ((generation > 8 && generation <=10) ? generation : null); return ((generation > 8 && generation <= 10) ? generation : null);
} }
catch (NumberFormatException e) { catch (NumberFormatException ex) {
return null; return null;
} }
} }
@@ -19,9 +19,6 @@ package io.spring.initializr.service.extension;
import io.spring.initializr.generator.ProjectRequest; import io.spring.initializr.generator.ProjectRequest;
import org.junit.Test; import org.junit.Test;
import static io.spring.initializr.service.extension.JacksonKotlinRequestPostProcessor.JACKSON_KOTLIN;
import static io.spring.initializr.service.extension.ReactorTestRequestPostProcessor.REACTOR_TEST;
/** /**
* Tests for {@link JacksonKotlinRequestPostProcessor}. * Tests for {@link JacksonKotlinRequestPostProcessor}.
* *
@@ -37,8 +34,9 @@ public class JacksonKotlinRequestPostProcessorTests
request.setBootVersion("2.0.0.M2"); request.setBootVersion("2.0.0.M2");
request.setLanguage("kotlin"); request.setLanguage("kotlin");
generateMavenPom(request).hasSpringBootStarterDependency("webflux") generateMavenPom(request).hasSpringBootStarterDependency("webflux")
.hasDependency(JACKSON_KOTLIN).hasSpringBootStarterTest() .hasDependency(JacksonKotlinRequestPostProcessor.JACKSON_KOTLIN)
.hasDependency(REACTOR_TEST) .hasSpringBootStarterTest()
.hasDependency(ReactorTestRequestPostProcessor.REACTOR_TEST)
.hasDependency("org.jetbrains.kotlin", "kotlin-reflect") .hasDependency("org.jetbrains.kotlin", "kotlin-reflect")
.hasDependency("org.jetbrains.kotlin", "kotlin-stdlib-jdk8") .hasDependency("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
.hasDependenciesCount(6); .hasDependenciesCount(6);
@@ -49,7 +47,8 @@ public class JacksonKotlinRequestPostProcessorTests
ProjectRequest request = createProjectRequest("webflux"); ProjectRequest request = createProjectRequest("webflux");
request.setBootVersion("2.0.0.M2"); request.setBootVersion("2.0.0.M2");
generateMavenPom(request).hasSpringBootStarterDependency("webflux") generateMavenPom(request).hasSpringBootStarterDependency("webflux")
.hasSpringBootStarterTest().hasDependency(REACTOR_TEST) .hasSpringBootStarterTest()
.hasDependency(ReactorTestRequestPostProcessor.REACTOR_TEST)
.hasDependenciesCount(3); .hasDependenciesCount(3);
} }
@@ -24,7 +24,8 @@ import org.junit.Test;
* *
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public class JavaVersionRequestPostProcessorTests extends AbstractRequestPostProcessorTests { public class JavaVersionRequestPostProcessorTests
extends AbstractRequestPostProcessorTests {
@Test @Test
public void java9CannotBeUsedWithSpringBoot1Maven() { public void java9CannotBeUsedWithSpringBoot1Maven() {
@@ -126,7 +127,6 @@ public class JavaVersionRequestPostProcessorTests extends AbstractRequestPostPro
generateGradleBuild(request).hasJavaVersion("1.8"); generateGradleBuild(request).hasJavaVersion("1.8");
} }
@Test @Test
public void java10CanBeUsedWithSpringBoot2Maven() { public void java10CanBeUsedWithSpringBoot2Maven() {
ProjectRequest request = createProjectRequest("web"); ProjectRequest request = createProjectRequest("web");
@@ -19,11 +19,6 @@ package io.spring.initializr.service.extension;
import io.spring.initializr.generator.ProjectRequest; import io.spring.initializr.generator.ProjectRequest;
import org.junit.Test; import org.junit.Test;
import static io.spring.initializr.service.extension.SpringCloudStreamRequestPostProcessor.KAFKA_BINDER;
import static io.spring.initializr.service.extension.SpringCloudStreamRequestPostProcessor.KAFKA_STREAMS_BINDER;
import static io.spring.initializr.service.extension.SpringCloudStreamRequestPostProcessor.RABBIT_BINDER;
import static io.spring.initializr.service.extension.SpringCloudStreamRequestPostProcessor.SCS_TEST;
/** /**
* Tests for {@link SpringCloudStreamRequestPostProcessor}. * Tests for {@link SpringCloudStreamRequestPostProcessor}.
* *
@@ -36,8 +31,10 @@ public class SpringCloudStreamRequestPostProcessorTests
public void springCloudStreamWithRabbit() { public void springCloudStreamWithRabbit() {
ProjectRequest request = createProjectRequest("cloud-stream", "amqp"); ProjectRequest request = createProjectRequest("cloud-stream", "amqp");
generateMavenPom(request).hasDependency(getDependency("cloud-stream")) generateMavenPom(request).hasDependency(getDependency("cloud-stream"))
.hasDependency(getDependency("amqp")).hasDependency(RABBIT_BINDER) .hasDependency(getDependency("amqp"))
.hasSpringBootStarterTest().hasDependency(SCS_TEST) .hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
.hasSpringBootStarterTest()
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
.hasDependenciesCount(5); .hasDependenciesCount(5);
} }
@@ -45,8 +42,10 @@ public class SpringCloudStreamRequestPostProcessorTests
public void springCloudStreamWithKafka() { public void springCloudStreamWithKafka() {
ProjectRequest request = createProjectRequest("cloud-stream", "kafka"); ProjectRequest request = createProjectRequest("cloud-stream", "kafka");
generateMavenPom(request).hasDependency(getDependency("cloud-stream")) generateMavenPom(request).hasDependency(getDependency("cloud-stream"))
.hasDependency(getDependency("kafka")).hasDependency(KAFKA_BINDER) .hasDependency(getDependency("kafka"))
.hasSpringBootStarterTest().hasDependency(SCS_TEST) .hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
.hasSpringBootStarterTest()
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
.hasDependenciesCount(5); .hasDependenciesCount(5);
} }
@@ -56,8 +55,10 @@ public class SpringCloudStreamRequestPostProcessorTests
request.setBootVersion("2.0.0.RELEASE"); request.setBootVersion("2.0.0.RELEASE");
generateMavenPom(request).hasDependency(getDependency("cloud-stream")) generateMavenPom(request).hasDependency(getDependency("cloud-stream"))
.hasDependency(getDependency("kafka-streams")) .hasDependency(getDependency("kafka-streams"))
.hasDependency(KAFKA_STREAMS_BINDER).hasSpringBootStarterTest() .hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_STREAMS_BINDER)
.hasDependency(SCS_TEST).hasDependenciesCount(5); .hasSpringBootStarterTest()
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
.hasDependenciesCount(5);
} }
@Test @Test
@@ -68,9 +69,12 @@ public class SpringCloudStreamRequestPostProcessorTests
.hasDependency(getDependency("amqp")) .hasDependency(getDependency("amqp"))
.hasDependency(getDependency("kafka")) .hasDependency(getDependency("kafka"))
.hasDependency(getDependency("kafka-streams")) .hasDependency(getDependency("kafka-streams"))
.hasDependency(RABBIT_BINDER).hasDependency(KAFKA_BINDER) .hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
.hasDependency(KAFKA_STREAMS_BINDER).hasSpringBootStarterTest() .hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
.hasDependency(SCS_TEST).hasDependenciesCount(9); .hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_STREAMS_BINDER)
.hasSpringBootStarterTest()
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
.hasDependenciesCount(9);
} }
@Test @Test
@@ -78,8 +82,10 @@ public class SpringCloudStreamRequestPostProcessorTests
ProjectRequest request = createProjectRequest("reactive-cloud-stream", "amqp"); ProjectRequest request = createProjectRequest("reactive-cloud-stream", "amqp");
request.setBootVersion("2.0.0.RELEASE"); request.setBootVersion("2.0.0.RELEASE");
generateMavenPom(request).hasDependency(getDependency("reactive-cloud-stream")) generateMavenPom(request).hasDependency(getDependency("reactive-cloud-stream"))
.hasDependency(getDependency("amqp")).hasDependency(RABBIT_BINDER) .hasDependency(getDependency("amqp"))
.hasSpringBootStarterTest().hasDependency(SCS_TEST) .hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
.hasSpringBootStarterTest()
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
.hasDependenciesCount(5); .hasDependenciesCount(5);
} }
@@ -88,8 +94,10 @@ public class SpringCloudStreamRequestPostProcessorTests
ProjectRequest request = createProjectRequest("reactive-cloud-stream", "kafka"); ProjectRequest request = createProjectRequest("reactive-cloud-stream", "kafka");
request.setBootVersion("2.0.0.RELEASE"); request.setBootVersion("2.0.0.RELEASE");
generateMavenPom(request).hasDependency(getDependency("reactive-cloud-stream")) generateMavenPom(request).hasDependency(getDependency("reactive-cloud-stream"))
.hasDependency(getDependency("kafka")).hasDependency(KAFKA_BINDER) .hasDependency(getDependency("kafka"))
.hasSpringBootStarterTest().hasDependency(SCS_TEST) .hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
.hasSpringBootStarterTest()
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
.hasDependenciesCount(5); .hasDependenciesCount(5);
} }
@@ -100,8 +108,10 @@ public class SpringCloudStreamRequestPostProcessorTests
request.setBootVersion("2.0.0.RELEASE"); request.setBootVersion("2.0.0.RELEASE");
generateMavenPom(request).hasDependency(getDependency("reactive-cloud-stream")) generateMavenPom(request).hasDependency(getDependency("reactive-cloud-stream"))
.hasDependency(getDependency("kafka-streams")) .hasDependency(getDependency("kafka-streams"))
.hasDependency(KAFKA_STREAMS_BINDER).hasSpringBootStarterTest() .hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_STREAMS_BINDER)
.hasDependency(SCS_TEST).hasDependenciesCount(5); .hasSpringBootStarterTest()
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
.hasDependenciesCount(5);
} }
@Test @Test
@@ -113,16 +123,20 @@ public class SpringCloudStreamRequestPostProcessorTests
.hasDependency(getDependency("amqp")) .hasDependency(getDependency("amqp"))
.hasDependency(getDependency("kafka")) .hasDependency(getDependency("kafka"))
.hasDependency(getDependency("kafka-streams")) .hasDependency(getDependency("kafka-streams"))
.hasDependency(RABBIT_BINDER).hasDependency(KAFKA_BINDER) .hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
.hasDependency(KAFKA_STREAMS_BINDER).hasSpringBootStarterTest() .hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
.hasDependency(SCS_TEST).hasDependenciesCount(9); .hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_STREAMS_BINDER)
.hasSpringBootStarterTest()
.hasDependency(SpringCloudStreamRequestPostProcessor.SCS_TEST)
.hasDependenciesCount(9);
} }
@Test @Test
public void springCloudBusWithRabbit() { public void springCloudBusWithRabbit() {
ProjectRequest request = createProjectRequest("cloud-bus", "amqp"); ProjectRequest request = createProjectRequest("cloud-bus", "amqp");
generateMavenPom(request).hasDependency(getDependency("cloud-bus")) generateMavenPom(request).hasDependency(getDependency("cloud-bus"))
.hasDependency(getDependency("amqp")).hasDependency(RABBIT_BINDER) .hasDependency(getDependency("amqp"))
.hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
.hasSpringBootStarterTest().hasDependenciesCount(4); .hasSpringBootStarterTest().hasDependenciesCount(4);
} }
@@ -130,7 +144,8 @@ public class SpringCloudStreamRequestPostProcessorTests
public void springCloudBusWithKafka() { public void springCloudBusWithKafka() {
ProjectRequest request = createProjectRequest("cloud-bus", "amqp"); ProjectRequest request = createProjectRequest("cloud-bus", "amqp");
generateMavenPom(request).hasDependency(getDependency("cloud-bus")) generateMavenPom(request).hasDependency(getDependency("cloud-bus"))
.hasDependency(getDependency("amqp")).hasDependency(RABBIT_BINDER) .hasDependency(getDependency("amqp"))
.hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
.hasSpringBootStarterTest().hasDependenciesCount(4); .hasSpringBootStarterTest().hasDependenciesCount(4);
} }
@@ -142,7 +157,8 @@ public class SpringCloudStreamRequestPostProcessorTests
.hasDependency(getDependency("amqp")) .hasDependency(getDependency("amqp"))
.hasDependency(getDependency("kafka")) .hasDependency(getDependency("kafka"))
.hasDependency(getDependency("kafka-streams")) .hasDependency(getDependency("kafka-streams"))
.hasDependency(RABBIT_BINDER).hasDependency(KAFKA_BINDER) .hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
.hasSpringBootStarterTest().hasDependenciesCount(7); .hasSpringBootStarterTest().hasDependenciesCount(7);
} }
@@ -151,7 +167,8 @@ public class SpringCloudStreamRequestPostProcessorTests
ProjectRequest request = createProjectRequest("cloud-turbine-stream", "amqp"); ProjectRequest request = createProjectRequest("cloud-turbine-stream", "amqp");
request.setBootVersion("2.0.0.RELEASE"); request.setBootVersion("2.0.0.RELEASE");
generateMavenPom(request).hasDependency(getDependency("cloud-turbine-stream")) generateMavenPom(request).hasDependency(getDependency("cloud-turbine-stream"))
.hasDependency(getDependency("amqp")).hasDependency(RABBIT_BINDER) .hasDependency(getDependency("amqp"))
.hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
.hasSpringBootStarterTest().hasDependenciesCount(4); .hasSpringBootStarterTest().hasDependenciesCount(4);
} }
@@ -160,7 +177,8 @@ public class SpringCloudStreamRequestPostProcessorTests
ProjectRequest request = createProjectRequest("cloud-turbine-stream", "kafka"); ProjectRequest request = createProjectRequest("cloud-turbine-stream", "kafka");
request.setBootVersion("2.0.0.RELEASE"); request.setBootVersion("2.0.0.RELEASE");
generateMavenPom(request).hasDependency(getDependency("cloud-turbine-stream")) generateMavenPom(request).hasDependency(getDependency("cloud-turbine-stream"))
.hasDependency(getDependency("kafka")).hasDependency(KAFKA_BINDER) .hasDependency(getDependency("kafka"))
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
.hasSpringBootStarterTest().hasDependenciesCount(4); .hasSpringBootStarterTest().hasDependenciesCount(4);
} }
@@ -173,7 +191,8 @@ public class SpringCloudStreamRequestPostProcessorTests
.hasDependency(getDependency("amqp")) .hasDependency(getDependency("amqp"))
.hasDependency(getDependency("kafka")) .hasDependency(getDependency("kafka"))
.hasDependency(getDependency("kafka-streams")) .hasDependency(getDependency("kafka-streams"))
.hasDependency(RABBIT_BINDER).hasDependency(KAFKA_BINDER) .hasDependency(SpringCloudStreamRequestPostProcessor.RABBIT_BINDER)
.hasDependency(SpringCloudStreamRequestPostProcessor.KAFKA_BINDER)
.hasSpringBootStarterTest().hasDependenciesCount(7); .hasSpringBootStarterTest().hasDependenciesCount(7);
} }
@@ -19,9 +19,6 @@ package io.spring.initializr.service.extension;
import io.spring.initializr.generator.ProjectRequest; import io.spring.initializr.generator.ProjectRequest;
import org.junit.Test; import org.junit.Test;
import static io.spring.initializr.service.extension.SpringSessionRequestPostProcessor.JDBC;
import static io.spring.initializr.service.extension.SpringSessionRequestPostProcessor.REDIS;
/** /**
* Tests for {@link SpringSessionRequestPostProcessor}. * Tests for {@link SpringSessionRequestPostProcessor}.
* *
@@ -93,7 +90,9 @@ public class SpringSessionRequestPostProcessorTests
ProjectRequest request = createProjectRequest("session", "data-redis"); ProjectRequest request = createProjectRequest("session", "data-redis");
request.setBootVersion("2.0.0.M3"); request.setBootVersion("2.0.0.M3");
generateMavenPom(request).hasSpringBootStarterDependency("data-redis") generateMavenPom(request).hasSpringBootStarterDependency("data-redis")
.hasSpringBootStarterTest().hasDependency(REDIS).hasDependenciesCount(3); .hasSpringBootStarterTest()
.hasDependency(SpringSessionRequestPostProcessor.REDIS)
.hasDependenciesCount(3);
} }
@Test @Test
@@ -101,7 +100,9 @@ public class SpringSessionRequestPostProcessorTests
ProjectRequest request = createProjectRequest("session", "data-redis-reactive"); ProjectRequest request = createProjectRequest("session", "data-redis-reactive");
request.setBootVersion("2.0.0.M7"); request.setBootVersion("2.0.0.M7");
generateMavenPom(request).hasSpringBootStarterDependency("data-redis-reactive") generateMavenPom(request).hasSpringBootStarterDependency("data-redis-reactive")
.hasSpringBootStarterTest().hasDependency(REDIS).hasDependenciesCount(3); .hasSpringBootStarterTest()
.hasDependency(SpringSessionRequestPostProcessor.REDIS)
.hasDependenciesCount(3);
} }
@Test @Test
@@ -109,7 +110,9 @@ public class SpringSessionRequestPostProcessorTests
ProjectRequest request = createProjectRequest("session", "jdbc"); ProjectRequest request = createProjectRequest("session", "jdbc");
request.setBootVersion("2.0.0.M3"); request.setBootVersion("2.0.0.M3");
generateMavenPom(request).hasSpringBootStarterDependency("jdbc") generateMavenPom(request).hasSpringBootStarterDependency("jdbc")
.hasSpringBootStarterTest().hasDependency(JDBC).hasDependenciesCount(3); .hasSpringBootStarterTest()
.hasDependency(SpringSessionRequestPostProcessor.JDBC)
.hasDependenciesCount(3);
} }
@Test @Test
@@ -118,7 +121,9 @@ public class SpringSessionRequestPostProcessorTests
request.setBootVersion("2.0.0.M3"); request.setBootVersion("2.0.0.M3");
generateMavenPom(request).hasSpringBootStarterDependency("data-redis") generateMavenPom(request).hasSpringBootStarterDependency("data-redis")
.hasSpringBootStarterDependency("jdbc").hasSpringBootStarterTest() .hasSpringBootStarterDependency("jdbc").hasSpringBootStarterTest()
.hasDependency(REDIS).hasDependency(JDBC).hasDependenciesCount(5); .hasDependency(SpringSessionRequestPostProcessor.REDIS)
.hasDependency(SpringSessionRequestPostProcessor.JDBC)
.hasDependenciesCount(5);
} }
} }
@@ -25,10 +25,9 @@ import org.springframework.core.env.Environment;
import org.springframework.mock.env.MockEnvironment; import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Java6Assertions.entry; import static org.assertj.core.api.Assertions.entry;
/** /**
*
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public class CloudFoundryInfoContributorTests { public class CloudFoundryInfoContributorTests {