minor formatting cleanup

This commit is contained in:
Eugen Paraschiv 2019-01-27 14:25:36 +02:00
parent 8ccec9a413
commit 2e733c3867
18 changed files with 122 additions and 132 deletions

View File

@ -65,21 +65,23 @@ public class DbConfig {
@Configuration
@Profile("h2")
@PropertySource("classpath:persistence-h2.properties")
class H2Config {}
class H2Config {
}
@Configuration
@Profile("hsqldb")
@PropertySource("classpath:persistence-hsqldb.properties")
class HsqldbConfig {}
class HsqldbConfig {
}
@Configuration
@Profile("derby")
@PropertySource("classpath:persistence-derby.properties")
class DerbyConfig {}
class DerbyConfig {
}
@Configuration
@Profile("sqlite")
@PropertySource("classpath:persistence-sqlite.properties")
class SqliteConfig {}
class SqliteConfig {
}

View File

@ -15,7 +15,6 @@ public class RestConfig implements RepositoryRestConfigurer {
public void configureRepositoryRestConfiguration(RepositoryRestConfiguration repositoryRestConfiguration) {
repositoryRestConfiguration.getProjectionConfiguration().addProjection(CustomBook.class);
ExposureConfiguration config = repositoryRestConfiguration.getExposureConfiguration();
config.forDomainType(WebsiteUser.class).withItemExposure((metadata, httpMethods) ->
httpMethods.disable(HttpMethod.PATCH));
config.forDomainType(WebsiteUser.class).withItemExposure((metadata, httpMethods) -> httpMethods.disable(HttpMethod.PATCH));
}
}

View File

@ -24,13 +24,7 @@ public class ValidatorEventRegister implements InitializingBean {
List<String> events = Arrays.asList("beforeCreate", "afterCreate", "beforeSave", "afterSave", "beforeLinkSave", "afterLinkSave", "beforeDelete", "afterDelete");
for (Map.Entry<String, Validator> entry : validators.entrySet()) {
events
.stream()
.filter(p -> entry
.getKey()
.startsWith(p))
.findFirst()
.ifPresent(p -> validatingRepositoryEventListener.addValidator(p, entry.getValue()));
events.stream().filter(p -> entry.getKey().startsWith(p)).findFirst().ifPresent(p -> validatingRepositoryEventListener.addValidator(p, entry.getValue()));
}
}
}

View File

@ -9,6 +9,7 @@ import java.util.logging.Logger;
@RepositoryEventHandler
public class AuthorEventHandler {
Logger logger = Logger.getLogger("Class AuthorEventHandler");
public AuthorEventHandler() {
super();
}

View File

@ -11,6 +11,7 @@ import org.springframework.data.rest.core.annotation.RepositoryEventHandler;
@RepositoryEventHandler
public class BookEventHandler {
Logger logger = Logger.getLogger("Class BookEventHandler");
@HandleBeforeCreate
public void handleBookBeforeCreate(Book book) {

View File

@ -19,12 +19,7 @@ public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionH
public ResponseEntity<Object> handleAccessDeniedException(Exception ex, WebRequest request) {
RepositoryConstraintViolationException nevEx = (RepositoryConstraintViolationException) ex;
String errors = nevEx
.getErrors()
.getAllErrors()
.stream()
.map(ObjectError::toString)
.collect(Collectors.joining("\n"));
String errors = nevEx.getErrors().getAllErrors().stream().map(ObjectError::toString).collect(Collectors.joining("\n"));
return new ResponseEntity<>(errors, new HttpHeaders(), HttpStatus.NOT_ACCEPTABLE);
}

View File

@ -63,7 +63,6 @@ public class Book {
this.isbn = isbn;
}
public Library getLibrary() {
return library;
}

View File

@ -7,4 +7,5 @@ import com.baeldung.models.Book;
import com.baeldung.projections.CustomBook;
@RepositoryRestResource(excerptProjection = CustomBook.class)
public interface BookRepository extends CrudRepository<Book, Long> {}
public interface BookRepository extends CrudRepository<Book, Long> {
}

View File

@ -29,7 +29,6 @@ public class SpringDataProjectionLiveTest {
private static final String BOOK_ENDPOINT = "http://localhost:8080/books";
private static final String AUTHOR_ENDPOINT = "http://localhost:8080/authors";
@Autowired
private BookRepository bookRepo;
@ -59,7 +58,6 @@ public class SpringDataProjectionLiveTest {
// System.out.println(response.asString());
}
@Test
public void whenGetBookProjection_thenOK() {
final Response response = RestAssured.get(BOOK_ENDPOINT + "/1?projection=customBook");