Polishing.

Reformat code.

See #606.
This commit is contained in:
Mark Paluch
2021-04-29 12:14:16 +02:00
parent 546eda53bd
commit 41b4b03469
24 changed files with 54 additions and 72 deletions

View File

@@ -15,6 +15,8 @@
*/ */
package example.springdata.cassandra.streamoptional; package example.springdata.cassandra.streamoptional;
import static org.assertj.core.api.Assertions.*;
import example.springdata.cassandra.util.CassandraKeyspace; import example.springdata.cassandra.util.CassandraKeyspace;
import java.time.LocalDate; import java.time.LocalDate;

View File

@@ -35,13 +35,6 @@
<artifactId>spring-boot-starter-data-cassandra</artifactId> <artifactId>spring-boot-starter-data-cassandra</artifactId>
</dependency> </dependency>
<!-- Required for Embedded Cassandra -->
<dependency>
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>3.0.2</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -18,10 +18,10 @@
<modules> <modules>
<module>bom</module> <module>bom</module>
<!-- <module>couchbase</module> --> <!-- <module>couchbase</module> Bug in Couchbase SDK -->
<module>cassandra</module> <module>cassandra</module>
<module>elasticsearch</module> <module>elasticsearch</module>
<!-- <module>geode</module> --> <!-- <module>geode</module> Geode isn't Java 16-ready -->
<module>jdbc</module> <module>jdbc</module>
<module>jpa</module> <module>jpa</module>
<module>ldap</module> <module>ldap</module>

View File

@@ -15,13 +15,13 @@
*/ */
package example.springdata.rest.headers; package example.springdata.rest.headers;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import lombok.Data;
import lombok.RequiredArgsConstructor;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
@@ -30,7 +30,7 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor @RequiredArgsConstructor
public class Address { public class Address {
@GeneratedValue @Id// @GeneratedValue @Id //
private Long id; private Long id;
private final String street, zipCode, city, state; private final String street, zipCode, city, state;

View File

@@ -15,6 +15,9 @@
*/ */
package example.springdata.rest.headers; package example.springdata.rest.headers;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
@@ -25,9 +28,6 @@ import javax.persistence.Id;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Version; import javax.persistence.Version;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener; import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@@ -52,7 +52,7 @@ public class Customer {
private final String firstname, lastname; private final String firstname, lastname;
private final Gender gender; private final Gender gender;
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true)// @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) //
private final Address address; private final Address address;
Customer() { Customer() {

View File

@@ -15,13 +15,13 @@
*/ */
package example.springdata.rest.headers; package example.springdata.rest.headers;
import static org.assertj.core.api.Assertions.*;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Integration tests to bootstrap the application. * Integration tests to bootstrap the application.
* *

View File

@@ -21,13 +21,11 @@ import static org.springframework.restdocs.RestDocumentation.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import java.net.URI;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.restdocs.config.RestDocumentationConfigurer; import org.springframework.restdocs.config.RestDocumentationConfigurer;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders;

View File

@@ -15,13 +15,13 @@
*/ */
package example.springdata.multistore.person; package example.springdata.multistore.person;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import lombok.Data;
import lombok.RequiredArgsConstructor;
/** /**
* A person. * A person.
* *

View File

@@ -15,13 +15,13 @@
*/ */
package example.springdata.rest.projections; package example.springdata.rest.projections;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import lombok.Data;
import lombok.RequiredArgsConstructor;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
@@ -30,7 +30,7 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor @RequiredArgsConstructor
public class Address { public class Address {
@GeneratedValue @Id// @GeneratedValue @Id //
private Long id; private Long id;
private final String street, zipCode, city, state; private final String street, zipCode, city, state;

View File

@@ -15,15 +15,15 @@
*/ */
package example.springdata.rest.projections; package example.springdata.rest.projections;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import lombok.Data;
import lombok.RequiredArgsConstructor;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
@@ -36,7 +36,7 @@ public class Customer {
private final String firstname, lastname; private final String firstname, lastname;
private final Gender gender; private final Gender gender;
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true)// @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) //
private final Address address; private final Address address;
Customer() { Customer() {

View File

@@ -15,17 +15,17 @@
*/ */
package example.springdata.rest.projections; package example.springdata.rest.projections;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import java.math.BigDecimal; import java.math.BigDecimal;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */

View File

@@ -15,6 +15,8 @@
*/ */
package example.springdata.rest.projections; package example.springdata.rest.projections;
import lombok.Data;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -25,8 +27,6 @@ import javax.persistence.Id;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import lombok.Data;
/** /**
* @author Oliver Gierke * @author Oliver Gierke
*/ */
@@ -34,13 +34,13 @@ import lombok.Data;
@Data @Data
public class Order { public class Order {
@Id @GeneratedValue// @Id @GeneratedValue //
private Long id; private Long id;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) //
private List<LineItem> items = new ArrayList<>(); private List<LineItem> items = new ArrayList<>();
@ManyToOne// @ManyToOne //
private Customer customer; private Customer customer;
public Order add(LineItem item) { public Order add(LineItem item) {

View File

@@ -15,12 +15,13 @@
*/ */
package example.springdata.rest.projections; package example.springdata.rest.projections;
import static org.assertj.core.api.Assertions.*;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Integration tests to bootstrap the application. * Integration tests to bootstrap the application.
* *

View File

@@ -15,6 +15,8 @@
*/ */
package example.springdata.rest.projections; package example.springdata.rest.projections;
import static org.assertj.core.api.Assertions.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -24,8 +26,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.projection.ProjectionFactory; import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.projection.SpelAwareProxyProjectionFactory; import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Test cases showing the programatic use of a {@link ProjectionFactory}. * Test cases showing the programatic use of a {@link ProjectionFactory}.
* *

View File

@@ -29,8 +29,6 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.User.UserBuilder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.factory.PasswordEncoderFactories; import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.provisioning.InMemoryUserDetailsManager; import org.springframework.security.provisioning.InMemoryUserDetailsManager;

View File

@@ -15,13 +15,13 @@
*/ */
package example.springdata.rest.security; package example.springdata.rest.security;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
/** /**

View File

@@ -15,13 +15,13 @@
*/ */
package example.springdata.rest.security; package example.springdata.rest.security;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import lombok.Data;
import lombok.RequiredArgsConstructor;
/** /**
* Domain object for an item managed by the company. * Domain object for an item managed by the company.
* *

View File

@@ -15,7 +15,7 @@
*/ */
package example.springdata.rest.security; package example.springdata.rest.security;
import static org.junit.jupiter.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@@ -26,9 +26,6 @@ import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException; import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
/** /**
* Collection of test cases used to verify method-level security. * Collection of test cases used to verify method-level security.
* *

View File

@@ -15,7 +15,7 @@
*/ */
package example.springdata.rest.security; package example.springdata.rest.security;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*; import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;

View File

@@ -32,7 +32,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.data.geo.Point; import org.springframework.data.geo.Point;
import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.index.IndexDefinition;
import org.springframework.data.mongodb.core.index.IndexResolver; import org.springframework.data.mongodb.core.index.IndexResolver;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -53,8 +52,7 @@ public class StoreInitializer {
return; return;
} }
var indexDefinitions = IndexResolver var indexDefinitions = IndexResolver.create(operations.getConverter().getMappingContext())
.create(operations.getConverter().getMappingContext())
.resolveIndexFor(Store.class); .resolveIndexFor(Store.class);
indexDefinitions.forEach(operations.indexOps(Store.class)::ensureIndex); indexDefinitions.forEach(operations.indexOps(Store.class)::ensureIndex);

View File

@@ -22,13 +22,10 @@ import example.springdata.rest.stores.StoreRepository;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.geo.Distance; import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Metrics; import org.springframework.data.geo.Metrics;

View File

@@ -1,5 +1,4 @@
# Random port for embedded MongoDB # Random port for embedded MongoDB
spring.data.mongodb.port=0 spring.data.mongodb.port=0
# Spring Data REST # Spring Data REST
spring.data.rest.base-path=/api spring.data.rest.base-path=/api

View File

@@ -97,7 +97,6 @@ class StarbucksClient {
forEach(store -> log.info("{} - {}", store.name, store.address)); forEach(store -> log.info("{} - {}", store.name, store.address));
} }
@Test @Test
void accessServiceUsingRestTemplate() { void accessServiceUsingRestTemplate() {

View File

@@ -15,6 +15,8 @@
*/ */
package example.springdata.rest.stores; package example.springdata.rest.stores;
import static org.assertj.core.api.Assertions.*;
import example.springdata.rest.stores.Store.Address; import example.springdata.rest.stores.Store.Address;
import java.util.UUID; import java.util.UUID;
@@ -22,16 +24,14 @@ import java.util.UUID;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.geo.Distance; import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Metrics; import org.springframework.data.geo.Metrics;
import org.springframework.data.geo.Point; import org.springframework.data.geo.Point;
import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Integration tests for {@link StoreRepository}. * Integration tests for {@link StoreRepository}.
* *