Turned on checkstyle

This commit is contained in:
Marcin Grzejszczak
2019-02-01 15:48:32 +01:00
parent 94e9b8f2f8
commit e4b08a083c
268 changed files with 5114 additions and 3993 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 the original author or authors.
* Copyright 2012-2019 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.
@@ -18,11 +18,11 @@ package com.example;
import java.util.function.Function;
import reactor.core.publisher.Flux;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Flux;
/**
* @author Dave Syer
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2016 the original author or authors.
* Copyright 2012-2019 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.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example;
import java.util.HashMap;
@@ -20,25 +21,26 @@ import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
import reactor.core.publisher.Flux;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.util.MultiValueMap;
import reactor.core.publisher.Flux;
// @checkstyle:off
@SpringBootApplication
public class SampleApplication {
public static void main(String[] args) {
SpringApplication.run(SampleApplication.class, args);
}
@Bean
public Function<Foo, Bar> uppercase() {
return value -> new Bar(value.uppercase());
}
public static void main(String[] args) {
SpringApplication.run(SampleApplication.class, args);
}
@Bean
public Function<MultiValueMap<String, String>, Map<String, Integer>> sum() {
return multiValueMap -> {
@@ -55,6 +57,7 @@ public class SampleApplication {
}
}
// @checkstyle:on
class Foo {
@@ -63,25 +66,26 @@ class Foo {
Foo() {
}
public String lowercase() {
return value.toLowerCase();
}
public Foo(String value) {
Foo(String value) {
this.value = value;
}
public String lowercase() {
return this.value.toLowerCase();
}
public String uppercase() {
return value.toUpperCase();
return this.value.toUpperCase();
}
public String getValue() {
return value;
return this.value;
}
public void setValue(String value) {
this.value = value;
}
}
class Bar {
@@ -91,12 +95,12 @@ class Bar {
Bar() {
}
public Bar(String value) {
Bar(String value) {
this.value = value;
}
public String getValue() {
return value;
return this.value;
}
public void setValue(String value) {

View File

@@ -1,4 +1,4 @@
spring.cloud.stream.bindings.input.destination: foos
spring.cloud.stream.bindings.output.destination: bars
spring.cloud.function.stream.processor.name: uppercase
management.security.enabled: false
spring.cloud.stream.bindings.input.destination:foos
spring.cloud.stream.bindings.output.destination:bars
spring.cloud.function.stream.processor.name:uppercase
management.security.enabled:false

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 the original author or authors.
* Copyright 2012-2019 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.
@@ -15,12 +15,11 @@
*/
package com.example;
import static org.assertj.core.api.Assertions.assertThat;
import java.net.URI;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -30,6 +29,8 @@ import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Dave Syer
*/
@@ -38,13 +39,14 @@ import org.springframework.test.context.junit4.SpringRunner;
public class SampleApplicationMvcTests {
@Autowired
private TestRestTemplate rest;
private TestRestTemplate rest;
@Test
public void words() throws Exception {
ResponseEntity<String> result = rest.exchange(RequestEntity.get(new URI("/words"))
.accept(MediaType.APPLICATION_JSON).build(), String.class);
assertThat(result.getBody()).isEqualTo("[{\"value\":\"foo\"},{\"value\":\"bar\"}]");
ResponseEntity<String> result = this.rest.exchange(RequestEntity.get(new URI("/words"))
.accept(MediaType.APPLICATION_JSON).build(), String.class);
assertThat(result.getBody())
.isEqualTo("[{\"value\":\"foo\"},{\"value\":\"bar\"}]");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2018 the original author or authors.
* Copyright 2012-2019 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.
@@ -19,7 +19,6 @@ import java.net.URI;
import java.util.Arrays;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,43 +47,45 @@ public class SampleApplicationTests {
@LocalServerPort
private int port;
private TestRestTemplate rest = new TestRestTemplate();
@Before
public void before() {
headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
this.headers = new HttpHeaders();
this.headers.setContentType(MediaType.APPLICATION_JSON);
}
@Test
public void words() {
assertThat(rest.getForObject("http://localhost:" + port + "/words", String.class))
assertThat(this.rest.getForObject("http://localhost:" + this.port + "/words", String.class))
.isEqualTo("[{\"value\":\"foo\"},{\"value\":\"bar\"}]");
}
@Test
public void uppercase() {
assertThat(rest.postForObject("http://localhost:" + port + "/uppercase",
new HttpEntity<>("[{\"value\":\"foo\"}]", headers), String.class))
assertThat(this.rest.postForObject("http://localhost:" + this.port + "/uppercase",
new HttpEntity<>("[{\"value\":\"foo\"}]", this.headers), String.class))
.isEqualTo("[{\"value\":\"FOO\"}]");
}
@Test
public void composite() {
assertThat(rest.getForObject("http://localhost:" + port + "/words,uppercase",
assertThat(this.rest.getForObject("http://localhost:" + this.port + "/words,uppercase",
String.class)).isEqualTo("[{\"value\":\"FOO\"},{\"value\":\"BAR\"}]");
}
@Test
public void single() {
assertThat(rest.postForObject("http://localhost:" + port + "/uppercase",
new HttpEntity<>("{\"value\":\"foo\"}", headers), String.class)).isEqualTo("{\"value\":\"FOO\"}");
assertThat(this.rest.postForObject("http://localhost:" + this.port + "/uppercase",
new HttpEntity<>("{\"value\":\"foo\"}", this.headers), String.class))
.isEqualTo("{\"value\":\"FOO\"}");
}
@Test
public void lowercase() {
assertThat(rest.postForObject("http://localhost:" + port + "/lowercase",
new HttpEntity<>("[{\"value\":\"Foo\"}]", headers), String.class))
assertThat(this.rest.postForObject("http://localhost:" + this.port + "/lowercase",
new HttpEntity<>("[{\"value\":\"Foo\"}]", this.headers), String.class))
.isEqualTo("[{\"value\":\"foo\"}]");
}
@@ -96,8 +97,8 @@ public class SampleApplicationTests {
map.put("A", Arrays.asList("1", "2", "3"));
map.put("B", Arrays.asList("5", "6"));
assertThat(rest.exchange(
RequestEntity.post(new URI("http://localhost:" + port + "/sum"))
assertThat(this.rest.exchange(
RequestEntity.post(new URI("http://localhost:" + this.port + "/sum"))
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_FORM_URLENCODED).body(map),
String.class).getBody()).isEqualTo("[{\"A\":6,\"B\":11}]");
@@ -112,9 +113,11 @@ public class SampleApplicationTests {
map.put("A", Arrays.asList("1", "2", "3"));
map.put("B", Arrays.asList("5", "6"));
assertThat(rest.exchange(
RequestEntity.post(new URI("http://localhost:" + port + "/sum")).accept(MediaType.APPLICATION_JSON)
assertThat(this.rest.exchange(
RequestEntity.post(new URI("http://localhost:" + this.port + "/sum"))
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.MULTIPART_FORM_DATA).body(map),
String.class).getBody()).isEqualTo("[{\"A\":6,\"B\":11}]");
}
}