forked from finos/vuu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VUU86: Add tests for layout server (#68)
- Loading branch information
1 parent
7965bb5
commit 5c86765
Showing
16 changed files
with
841 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 9 additions & 1 deletion
10
layout-server/src/main/java/org/finos/vuu/layoutserver/dto/request/LayoutRequestDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
package org.finos.vuu.layoutserver.dto.request; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
import lombok.Data; | ||
|
||
@Data | ||
public class LayoutRequestDTO { | ||
|
||
/** | ||
* The definition of the layout as a string (i.e. stringified JSON structure containing components) | ||
* The definition of the layout as a string (e.g. stringified JSON structure containing | ||
* components) | ||
*/ | ||
@JsonProperty(value = "definition", required = true) | ||
@NotBlank(message = "Definition must not be blank") | ||
private String definition; | ||
|
||
@JsonProperty(value = "metadata", required = true) | ||
@NotNull(message = "Metadata must not be null") | ||
private MetadataRequestDTO metadata; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ut-server/src/main/java/org/finos/vuu/layoutserver/exceptions/GlobalExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.finos.vuu.layoutserver.exceptions; | ||
|
||
import java.util.List; | ||
import java.util.NoSuchElementException; | ||
import java.util.stream.Collectors; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.http.converter.HttpMessageNotReadableException; | ||
import org.springframework.web.bind.MethodArgumentNotValidException; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; | ||
|
||
@ControllerAdvice | ||
public class GlobalExceptionHandler { | ||
|
||
@ExceptionHandler(NoSuchElementException.class) | ||
public ResponseEntity<String> handleNotFound(NoSuchElementException ex) { | ||
return new ResponseEntity<>(ex.getMessage(), | ||
org.springframework.http.HttpStatus.NOT_FOUND); | ||
} | ||
|
||
@ExceptionHandler({ | ||
HttpMessageNotReadableException.class, | ||
MethodArgumentTypeMismatchException.class}) | ||
public ResponseEntity<String> handleBadRequest(Exception ex) { | ||
return new ResponseEntity<>(ex.getMessage(), | ||
org.springframework.http.HttpStatus.BAD_REQUEST); | ||
} | ||
|
||
@ExceptionHandler(MethodArgumentNotValidException.class) | ||
public ResponseEntity<String> handleMethodArgumentNotValid(MethodArgumentNotValidException ex) { | ||
List<String> errors = ex.getFieldErrors() | ||
.stream() | ||
.map(fieldError -> fieldError.getField() + ": " + fieldError.getDefaultMessage()) | ||
.collect(Collectors.toList()); | ||
|
||
return new ResponseEntity<>(errors.toString(), | ||
org.springframework.http.HttpStatus.BAD_REQUEST); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
layout-server/src/main/java/org/finos/vuu/layoutserver/repository/MetadataRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
package org.finos.vuu.layoutserver.repository; | ||
|
||
import java.util.UUID; | ||
import org.finos.vuu.layoutserver.model.Metadata; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.UUID; | ||
|
||
@Repository | ||
public interface MetadataRepository extends CrudRepository<Metadata, UUID> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
layout-server/src/main/java/org/finos/vuu/layoutserver/service/MetadataService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.