From cb5a679cff1929ed184139a230dfade5a32c5605 Mon Sep 17 00:00:00 2001 From: Lars Johansson <lars.johansson@ess.eu> Date: Wed, 4 May 2022 15:30:50 +0200 Subject: [PATCH] Update http status codes in REST API and global exception handler Update REST API with response codes for endpoints. Set http status codes corresponding to exceptions. --- .../openepics/names/rest/api/v1/INames.java | 102 +++++++++ .../names/rest/api/v1/IStructures.java | 198 ++++++++++++++++++ .../GlobalControllerExceptionHandler.java | 23 +- .../openepics/names/service/NamesService.java | 29 ++- .../openepics/names/util/ValidateUtil.java | 65 +++--- .../org/openepics/names/docker/ITUtil.java | 2 + .../org/openepics/names/docker/NamesIT.java | 18 +- .../names/docker/StructuresDeviceGroupIT.java | 10 +- .../names/docker/StructuresDeviceTypeIT.java | 12 +- .../names/docker/StructuresDisciplineIT.java | 10 +- .../names/docker/StructuresSubsystemIT.java | 12 +- .../names/docker/StructuresSystemGroupIT.java | 10 +- .../names/docker/StructuresSystemIT.java | 12 +- 13 files changed, 406 insertions(+), 97 deletions(-) diff --git a/src/main/java/org/openepics/names/rest/api/v1/INames.java b/src/main/java/org/openepics/names/rest/api/v1/INames.java index 3f7cd29a..45f9112c 100644 --- a/src/main/java/org/openepics/names/rest/api/v1/INames.java +++ b/src/main/java/org/openepics/names/rest/api/v1/INames.java @@ -147,6 +147,12 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -206,6 +212,12 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -255,6 +267,12 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -303,6 +321,12 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -351,6 +375,12 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -399,6 +429,12 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -441,6 +477,12 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -483,6 +525,18 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -529,6 +583,18 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "404", + description = "Not Found. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -575,6 +641,12 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -629,6 +701,12 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -693,6 +771,12 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -755,6 +839,12 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -816,6 +906,12 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -874,6 +970,12 @@ public interface INames { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", diff --git a/src/main/java/org/openepics/names/rest/api/v1/IStructures.java b/src/main/java/org/openepics/names/rest/api/v1/IStructures.java index d49c2216..17cba1bb 100644 --- a/src/main/java/org/openepics/names/rest/api/v1/IStructures.java +++ b/src/main/java/org/openepics/names/rest/api/v1/IStructures.java @@ -171,6 +171,18 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -232,6 +244,12 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -285,6 +303,12 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -334,6 +358,12 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -382,6 +412,12 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -431,6 +467,12 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -474,6 +516,12 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -524,6 +572,12 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -578,6 +632,18 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -641,6 +707,18 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -713,6 +791,18 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -781,6 +871,18 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -853,6 +955,18 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -925,6 +1039,18 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -997,6 +1123,18 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -1059,6 +1197,18 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -1118,6 +1268,18 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -1180,6 +1342,18 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -1240,6 +1414,18 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", @@ -1300,6 +1486,18 @@ public interface IStructures { content = @Content( mediaType = "application/json", schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "409", + description = "Conflict. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), + @ApiResponse( + responseCode = "422", + description = "Unprocessable entity. Reason and information such as message, details, field are available.", + content = @Content( + mediaType = "application/json", + schema = @Schema(implementation = Response.class))), @ApiResponse( responseCode = "500", description = "Internal server error. Reason and information such as message, details, field are available.", diff --git a/src/main/java/org/openepics/names/rest/controller/GlobalControllerExceptionHandler.java b/src/main/java/org/openepics/names/rest/controller/GlobalControllerExceptionHandler.java index f6790331..f4e570e2 100644 --- a/src/main/java/org/openepics/names/rest/controller/GlobalControllerExceptionHandler.java +++ b/src/main/java/org/openepics/names/rest/controller/GlobalControllerExceptionHandler.java @@ -48,13 +48,10 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExcep * Note * <ul> * <li>400 {@link HttpStatus#BAD_REQUEST}</li> - * <li>401 {@link HttpStatus#UNAUTHORIZED}</li> - * <li>403 {@link HttpStatus#FORBIDDEN}</li> * <li>404 {@link HttpStatus#NOT_FOUND}</li> * <li>409 {@link HttpStatus#CONFLICT}</li> * <li>422 {@link HttpStatus#UNPROCESSABLE_ENTITY}</li> * <li>500 {@link HttpStatus#INTERNAL_SERVER_ERROR}</li> - * <li>501 {@link HttpStatus#NOT_IMPLEMENTED}</li> * </ul> * * @author Lars Johansson @@ -81,30 +78,26 @@ public class GlobalControllerExceptionHandler extends ResponseEntityExceptionHan response.setMessage(StringUtils.trimToEmpty(ex.getMessage())); response.setDetails(StringUtils.trimToEmpty(se.getDetails())); response.setField(StringUtils.trimToEmpty(se.getField())); + resultStatus = HttpStatus.BAD_REQUEST; if (ex instanceof InputNotAvailableException || ex instanceof InputNotCorrectException || ex instanceof InputNotValidException) { - // resultStatus = HttpStatus.UNPROCESSABLE_ENTITY; - resultStatus = HttpStatus.BAD_REQUEST; + resultStatus = HttpStatus.UNPROCESSABLE_ENTITY; } - if (ex instanceof DataNotFoundException) { - // resultStatus = HttpStatus.NOT_FOUND; - resultStatus = HttpStatus.BAD_REQUEST; + if (ex instanceof DataNotAvailableException || ex instanceof DataNotFoundException) { + resultStatus = HttpStatus.NOT_FOUND; } - if (ex instanceof DataNotAvailableException || ex instanceof DataNotCorrectException || ex instanceof DataNotValidException) { - // resultStatus = HttpStatus.UNPROCESSABLE_ENTITY; - resultStatus = HttpStatus.BAD_REQUEST; + if (ex instanceof DataNotCorrectException || ex instanceof DataNotValidException) { + resultStatus = HttpStatus.UNPROCESSABLE_ENTITY; } if (ex instanceof DataDeletedException) { - // resultStatus = HttpStatus.UNPROCESSABLE_ENTITY; - resultStatus = HttpStatus.BAD_REQUEST; + resultStatus = HttpStatus.UNPROCESSABLE_ENTITY; } if (ex instanceof DataConflictException || ex instanceof DataExistException) { - // resultStatus = HttpStatus.CONFLICT; - resultStatus = HttpStatus.BAD_REQUEST; + resultStatus = HttpStatus.CONFLICT; } } diff --git a/src/main/java/org/openepics/names/service/NamesService.java b/src/main/java/org/openepics/names/service/NamesService.java index a2e8eea2..673ad520 100644 --- a/src/main/java/org/openepics/names/service/NamesService.java +++ b/src/main/java/org/openepics/names/service/NamesService.java @@ -372,49 +372,55 @@ public class NamesService { // do List<Name> names = nameRepository.readNames(false, FieldName.NAME, name); - ExceptionUtil.validateConditionDataNotAvailableException(names != null && names.size() == 1, "name not available", name, null); + ExceptionUtil.validateConditionDataNotFoundException(names != null && names.size() == 1, "name not found", name, null); Name toBeChecked = names.get(0); // system structure if (toBeChecked.getSystemgroupUuid() != null) { SystemGroup systemGroup = holderIRepositories.getSystemGroupRepository().findLatestNotDeletedByUuid(toBeChecked.getSystemgroupUuid().toString()); - ExceptionUtil.validateConditionDataNotAvailableException(systemGroup != null, "system group not available", name, null); + ExceptionUtil.validateConditionDataNotAvailableException(systemGroup != null, + "system group not available", name, null); if (systemGroup.isDeleted()) { return Boolean.TRUE; } } else if (toBeChecked.getSystemUuid() != null) { org.openepics.names.repository.model.System system = holderIRepositories.getSystemRepository().findLatestNotDeletedByUuid(toBeChecked.getSystemUuid().toString()); - ExceptionUtil.validateConditionDataNotAvailableException(system != null, "system not available", name, null); + ExceptionUtil.validateConditionDataNotAvailableException(system != null, + "system not available", name, null); if (system.isDeleted()) { return Boolean.TRUE; } SystemGroup systemGroup = holderIRepositories.getSystemGroupRepository().findLatestNotDeletedByUuid(system.getParentUuid().toString()); - ExceptionUtil.validateConditionDataNotAvailableException(systemGroup != null, "system group not available", name, null); + ExceptionUtil.validateConditionDataNotAvailableException(systemGroup != null, + "system group not available", name, null); if (systemGroup.isDeleted()) { return Boolean.TRUE; } } else if (toBeChecked.getSubsystemUuid() != null) { Subsystem subsystem = holderIRepositories.getSubsystemRepository().findLatestNotDeletedByUuid(toBeChecked.getSubsystemUuid().toString()); - ExceptionUtil.validateConditionDataNotAvailableException(subsystem != null, "subsystem not available", name, null); + ExceptionUtil.validateConditionDataNotAvailableException(subsystem != null, + "subsystem not available", name, null); if (subsystem.isDeleted()) { return Boolean.TRUE; } org.openepics.names.repository.model.System system = holderIRepositories.getSystemRepository().findLatestNotDeletedByUuid(subsystem.getParentUuid().toString()); - ExceptionUtil.validateConditionDataNotAvailableException(system != null, "system not available", name, null); + ExceptionUtil.validateConditionDataNotAvailableException(system != null, + "system not available", name, null); if (system.isDeleted()) { return Boolean.TRUE; } SystemGroup systemGroup = holderIRepositories.getSystemGroupRepository().findLatestNotDeletedByUuid(system.getParentUuid().toString()); - ExceptionUtil.validateConditionDataNotAvailableException(systemGroup != null, "system group not available", name, null); + ExceptionUtil.validateConditionDataNotAvailableException(systemGroup != null, + "system group not available", name, null); if (systemGroup.isDeleted()) { return Boolean.TRUE; @@ -423,21 +429,24 @@ public class NamesService { // device structure if (toBeChecked.getDevicetypeUuid() != null) { DeviceType deviceType = holderIRepositories.getDeviceTypeRepository().findLatestNotDeletedByUuid(toBeChecked.getDevicetypeUuid().toString()); - ExceptionUtil.validateConditionDataNotAvailableException(deviceType != null, "device type not available", name, null); + ExceptionUtil.validateConditionDataNotAvailableException(deviceType != null, + "device type not available", name, null); if (deviceType.isDeleted()) { return Boolean.TRUE; } DeviceGroup deviceGroup = holderIRepositories.getDeviceGroupRepository().findLatestNotDeletedByUuid(deviceType.getParentUuid().toString()); - ExceptionUtil.validateConditionDataNotAvailableException(deviceGroup != null, "device group not available", name, null); + ExceptionUtil.validateConditionDataNotAvailableException(deviceGroup != null, + "device group not available", name, null); if (deviceGroup.isDeleted()) { return Boolean.TRUE; } Discipline discipline = holderIRepositories.getDisciplineRepository().findLatestNotDeletedByUuid(deviceType.getParentUuid().toString()); - ExceptionUtil.validateConditionDataNotAvailableException(discipline != null, "device group not available", name, null); + ExceptionUtil.validateConditionDataNotAvailableException(discipline != null, + "device group not available", name, null); if (discipline.isDeleted()) { return Boolean.TRUE; diff --git a/src/main/java/org/openepics/names/util/ValidateUtil.java b/src/main/java/org/openepics/names/util/ValidateUtil.java index be8c91c3..8dc233ff 100644 --- a/src/main/java/org/openepics/names/util/ValidateUtil.java +++ b/src/main/java/org/openepics/names/util/ValidateUtil.java @@ -106,8 +106,8 @@ public class ValidateUtil { */ public static void validateInputComment(String comment) { // available - ExceptionUtil.validateConditionInputNotAvailableException( - !StringUtils.isEmpty(comment), "comment " + ValidateUtil.IS_NOT_AVAILABLE, comment, "comment"); + ExceptionUtil.validateConditionInputNotAvailableException(!StringUtils.isEmpty(comment), + "comment " + ValidateUtil.IS_NOT_AVAILABLE, comment, "comment"); } /** @@ -117,8 +117,8 @@ public class ValidateUtil { */ public static void validateInputDescription(String description) { // available - ExceptionUtil.validateConditionInputNotAvailableException( - !StringUtils.isEmpty(description), "description " + ValidateUtil.IS_NOT_AVAILABLE, description, "description"); + ExceptionUtil.validateConditionInputNotAvailableException(!StringUtils.isEmpty(description), + "description " + ValidateUtil.IS_NOT_AVAILABLE, description, "description"); } /** @@ -128,8 +128,8 @@ public class ValidateUtil { */ public static void validateInputIndex(String index) { // available - ExceptionUtil.validateConditionInputNotAvailableException( - !StringUtils.isEmpty(index), "index " + ValidateUtil.IS_NOT_AVAILABLE, index, "index"); + ExceptionUtil.validateConditionInputNotAvailableException(!StringUtils.isEmpty(index), + "index " + ValidateUtil.IS_NOT_AVAILABLE, index, "index"); } /** @@ -139,8 +139,8 @@ public class ValidateUtil { */ public static void validateInputMnemonic(String mnemonic) { // available - ExceptionUtil.validateConditionInputNotAvailableException( - !StringUtils.isEmpty(mnemonic), "mnemonic " + ValidateUtil.IS_NOT_AVAILABLE, mnemonic, "mnemonic"); + ExceptionUtil.validateConditionInputNotAvailableException(!StringUtils.isEmpty(mnemonic), + "mnemonic " + ValidateUtil.IS_NOT_AVAILABLE, mnemonic, "mnemonic"); } /** @@ -150,8 +150,8 @@ public class ValidateUtil { */ public static void validateInputMnemonicpath(String mnemonicpath) { // available - ExceptionUtil.validateConditionInputNotAvailableException( - !StringUtils.isEmpty(mnemonicpath), "mnemonicpath " + ValidateUtil.IS_NOT_AVAILABLE, mnemonicpath, "mnemonicpath"); + ExceptionUtil.validateConditionInputNotAvailableException(!StringUtils.isEmpty(mnemonicpath), + "mnemonicpath " + ValidateUtil.IS_NOT_AVAILABLE, mnemonicpath, "mnemonicpath"); } /** @@ -161,8 +161,8 @@ public class ValidateUtil { */ public static void validateInputName(String name) { // available - ExceptionUtil.validateConditionInputNotAvailableException( - !StringUtils.isEmpty(name), "name " + ValidateUtil.IS_NOT_AVAILABLE, name, "name"); + ExceptionUtil.validateConditionInputNotAvailableException(!StringUtils.isEmpty(name), + "name " + ValidateUtil.IS_NOT_AVAILABLE, name, "name"); } /** @@ -182,13 +182,13 @@ public class ValidateUtil { */ public static void validateInputStatus(Status status, Status expected) { // available - ExceptionUtil.validateConditionInputNotAvailableException( - status != null, "status " + ValidateUtil.IS_NOT_AVAILABLE, null, "status"); + ExceptionUtil.validateConditionInputNotAvailableException(status != null, + "status " + ValidateUtil.IS_NOT_AVAILABLE, null, "status"); // expected status if (expected != null) { - ExceptionUtil.validateConditionInputNotCorrectException( - expected.equals(status), "status " + ValidateUtil.IS_NOT_CORRECT, status.toString(), "status"); + ExceptionUtil.validateConditionInputNotCorrectException(expected.equals(status), + "status " + ValidateUtil.IS_NOT_CORRECT, status.toString(), "status"); } } @@ -209,13 +209,13 @@ public class ValidateUtil { */ public static void validateInputType(Type type, Type expected) { // available - ExceptionUtil.validateConditionInputNotAvailableException( - type != null, "type " + ValidateUtil.IS_NOT_AVAILABLE, null, "type"); + ExceptionUtil.validateConditionInputNotAvailableException(type != null, + "type " + ValidateUtil.IS_NOT_AVAILABLE, null, "type"); // expected type if (expected != null) { - ExceptionUtil.validateConditionInputNotCorrectException( - expected.equals(type), "type " + ValidateUtil.IS_NOT_CORRECT, type.toString(), "type"); + ExceptionUtil.validateConditionInputNotCorrectException(expected.equals(type), + "type " + ValidateUtil.IS_NOT_CORRECT, type.toString(), "type"); } } @@ -227,8 +227,8 @@ public class ValidateUtil { public static void validateInputUuid(String uuid) { // available // correct - ExceptionUtil.validateConditionInputNotAvailableException( - !StringUtils.isEmpty(uuid), "uuid " + ValidateUtil.IS_NOT_AVAILABLE, uuid, "uuid"); + ExceptionUtil.validateConditionInputNotAvailableException(!StringUtils.isEmpty(uuid), + "uuid " + ValidateUtil.IS_NOT_AVAILABLE, uuid, "uuid"); try { UUID.fromString(uuid); } catch (IllegalArgumentException e) { @@ -265,8 +265,9 @@ public class ValidateUtil { boolean condition = ((queryFields == null && queryValues == null) || (queryFields != null && queryValues != null && queryFields.length == queryValues.length && queryFields.length > 0)); - ExceptionUtil.validateConditionInputNotCorrectException( - condition, "url and parameters " + ValidateUtil.ARE_NOT_CORRECT, "queryFields, queryValues with different lengths or empty", null); + ExceptionUtil.validateConditionInputNotCorrectException(condition, + "url and parameters " + ValidateUtil.ARE_NOT_CORRECT, "queryFields, queryValues with different lengths or empty", null); + if (queryFields != null) { for (int i=0; i<queryFields.length; i++) { if (FieldName.UUID.equals(queryFields[i])) { @@ -328,15 +329,15 @@ public class ValidateUtil { if (!NameChoice.DELETE.equals(nameChoice)) { ExceptionUtil.validateConditionInputNotAvailableException(nameElement.getParentsystemstructure() != null, - "parent system structure uuid " + ValidateUtil.IS_NOT_CORRECT, nameElement.toString(), "parentsystemstructure"); + "parent system structure uuid " + ValidateUtil.IS_NOT_AVAILABLE, nameElement.toString(), "parentsystemstructure"); // optional (either none or both) // parentdevicestructure // index if (nameElement.getParentdevicestructure() != null && nameElement.getIndex() == null) { - throw ExceptionUtil.createInputNotValidException("index " + ValidateUtil.IS_NOT_VALID, nameElement.toString(), "index"); + throw ExceptionUtil.createInputNotCorrectException("index " + ValidateUtil.IS_NOT_CORRECT, nameElement.toString(), "index"); } else if (nameElement.getParentdevicestructure() == null && nameElement.getIndex() != null) { - throw ExceptionUtil.createInputNotValidException("parent device structure uuid " + ValidateUtil.IS_NOT_CORRECT, nameElement.toString(), "parentdevicestructure"); + throw ExceptionUtil.createInputNotCorrectException("parent device structure uuid " + ValidateUtil.IS_NOT_CORRECT, nameElement.toString(), "parentdevicestructure"); } validateInputDescription(nameElement.getDescription()); @@ -419,7 +420,8 @@ public class ValidateUtil { // retrieve for uuid and check if (NameChoice.UPDATE.equals(nameChoice) || NameChoice.DELETE.equals(nameChoice)) { List<Name> names = nameRepository.readNames(false, FieldName.UUID, nameElement.getUuid().toString()); - ExceptionUtil.validateConditionDataNotCorrectException(names != null && names.size() == 1, ValidateUtil.NAME + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, nameElement.toString(), "uuid"); + ExceptionUtil.validateConditionDataNotCorrectException(names != null && names.size() == 1, + ValidateUtil.NAME + ValidateUtil.SPACE + ValidateUtil.IS_NOT_CORRECT, nameElement.toString(), "uuid"); } SystemGroup systemGroup = null; @@ -674,6 +676,7 @@ public class ValidateUtil { || (queryFields != null && queryValues != null && queryFields.length == queryValues.length && queryFields.length > 0)); ExceptionUtil.validateConditionInputNotCorrectException(condition, "url and parameters " + ValidateUtil.ARE_NOT_CORRECT, "queryFields, queryValues with different lengths or empty", null); + if (queryFields != null) { for (int i=0; i<queryFields.length; i++) { if (FieldStructure.UUID.equals(queryFields[i])) { @@ -765,7 +768,8 @@ public class ValidateUtil { if (!StructureChoice.DELETE.equals(structureChoice)) { switch (structureElement.getType()) { case SYSTEM, SUBSYSTEM, DEVICEGROUP, DEVICETYPE: - ExceptionUtil.validateConditionInputNotAvailableException(structureElement.getParent() != null, "parent uuid " + ValidateUtil.IS_NOT_AVAILABLE, structureElement.toString(), "parent"); + ExceptionUtil.validateConditionInputNotAvailableException(structureElement.getParent() != null, + "parent uuid " + ValidateUtil.IS_NOT_AVAILABLE, structureElement.toString(), "parent"); ValidateUtil.validateInputUuid(structureElement.getParent().toString()); break; default: @@ -778,7 +782,8 @@ public class ValidateUtil { // validate mnemonic input (value itself, not in relation to other values) // validateMnemonic takes isMnemonicRequired into account MnemonicValidation mnemonicValidation = namingConvention.validateMnemonic(structureElement.getType(), structureElement.getMnemonic()); - ExceptionUtil.validateConditionInputNotValidException(MnemonicValidation.VALID.equals(mnemonicValidation), "mnemonic " + ValidateUtil.IS_NOT_VALID, structureElement.toString(), "mnemonic"); + ExceptionUtil.validateConditionInputNotValidException(MnemonicValidation.VALID.equals(mnemonicValidation), + "mnemonic " + ValidateUtil.IS_NOT_VALID, structureElement.toString(), "mnemonic"); validateInputDescription(structureElement.getDescription()); } diff --git a/src/test/java/org/openepics/names/docker/ITUtil.java b/src/test/java/org/openepics/names/docker/ITUtil.java index ddde23b4..4598c419 100644 --- a/src/test/java/org/openepics/names/docker/ITUtil.java +++ b/src/test/java/org/openepics/names/docker/ITUtil.java @@ -43,6 +43,8 @@ public class ITUtil { public static final String NAMING = "naming"; + static final int HTTP_UNPROCESSABLE_ENTITY = 422; + static final String AUTH_USER = "user:userPass"; static final String AUTH_ADMIN = "admin:adminPass"; static final String EMPTY_JSON = "[]"; diff --git a/src/test/java/org/openepics/names/docker/NamesIT.java b/src/test/java/org/openepics/names/docker/NamesIT.java index 30a041c3..dccd7cde 100644 --- a/src/test/java/org/openepics/names/docker/NamesIT.java +++ b/src/test/java/org/openepics/names/docker/NamesIT.java @@ -230,7 +230,7 @@ public class NamesIT { ITUtilNameElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilNameElement.assertCreate(nameElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); // ---------- // system structure @@ -240,11 +240,11 @@ public class NamesIT { nameElement.setDescription("description"); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilNameElement.assertCreate(nameElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); nameElement.setComment("comment"); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilNameElement.assertCreate(nameElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); nameElement.setParentsystemstructure(subsystem010PRL); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.TRUE); @@ -257,7 +257,7 @@ public class NamesIT { nameElement.setIndex("051"); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilNameElement.assertCreate(nameElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); nameElement.setParentdevicestructure(deviceTypeRFA); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.TRUE); @@ -269,7 +269,7 @@ public class NamesIT { nameElement.setParentdevicestructure(null); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilNameElement.assertCreate(nameElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); // ---------- // system structure @@ -288,7 +288,7 @@ public class NamesIT { nameElement.setIndex("051"); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilNameElement.assertCreate(nameElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); nameElement.setParentdevicestructure(deviceTypeRFA); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.TRUE); @@ -300,7 +300,7 @@ public class NamesIT { nameElement.setParentdevicestructure(null); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilNameElement.assertCreate(nameElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); // ---------- // system structure @@ -319,7 +319,7 @@ public class NamesIT { nameElement.setIndex("051"); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilNameElement.assertCreate(nameElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); nameElement.setParentdevicestructure(deviceTypeTT); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.TRUE); @@ -334,7 +334,7 @@ public class NamesIT { nameElement.setParentdevicestructure(null); ITUtilNameElement.assertValidate(nameElement, NameChoice.CREATE, Boolean.FALSE); - ITUtilNameElement.assertCreate(nameElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilNameElement.assertCreate(nameElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); // ---------- // system structure + device structure diff --git a/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java b/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java index 9b0ae663..d55e71dc 100644 --- a/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresDeviceGroupIT.java @@ -145,23 +145,23 @@ public class StructuresDeviceGroupIT { ITUtilStructureElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setType(Type.DEVICEGROUP); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setParent(disciplineUuid); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setName("name"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setDescription("description"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setComment("comment"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); diff --git a/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java b/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java index 7f6e2e48..2c43e23b 100644 --- a/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresDeviceTypeIT.java @@ -157,27 +157,27 @@ public class StructuresDeviceTypeIT { ITUtilStructureElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setType(Type.DEVICETYPE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setParent(deviceGroupUuid); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setName("name"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setMnemonic("Cc"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setDescription("description"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setComment("comment"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); diff --git a/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java b/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java index 1240e0be..00fbe9cd 100644 --- a/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresDisciplineIT.java @@ -118,23 +118,23 @@ public class StructuresDisciplineIT { ITUtilStructureElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setType(Type.DISCIPLINE); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setName("name"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setMnemonic("Cc"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setDescription("description"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setComment("comment"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); diff --git a/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java b/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java index 6b41067b..830a7af8 100644 --- a/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresSubsystemIT.java @@ -159,27 +159,27 @@ public class StructuresSubsystemIT { ITUtilStructureElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setType(Type.SUBSYSTEM); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setParent(systemUuid); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setName("name"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setMnemonic("Cc"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setDescription("description"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setComment("comment"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); diff --git a/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java b/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java index ee1f01fb..733ca51b 100644 --- a/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresSystemGroupIT.java @@ -124,23 +124,23 @@ public class StructuresSystemGroupIT { ITUtilStructureElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setType(Type.SYSTEMGROUP); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setName("name"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setMnemonic("Cc"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setDescription("description"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setComment("comment"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); diff --git a/src/test/java/org/openepics/names/docker/StructuresSystemIT.java b/src/test/java/org/openepics/names/docker/StructuresSystemIT.java index a9429c4e..66852a02 100644 --- a/src/test/java/org/openepics/names/docker/StructuresSystemIT.java +++ b/src/test/java/org/openepics/names/docker/StructuresSystemIT.java @@ -143,27 +143,27 @@ public class StructuresSystemIT { ITUtilStructureElement.assertCreate("[{asdf]", HttpURLConnection.HTTP_BAD_REQUEST); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setType(Type.SYSTEM); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setParent(systemGroupUuid); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setName("name"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setMnemonic("Cc"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setDescription("description"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.FALSE); - ITUtilStructureElement.assertCreate(structureElement, HttpURLConnection.HTTP_BAD_REQUEST); + ITUtilStructureElement.assertCreate(structureElement, ITUtil.HTTP_UNPROCESSABLE_ENTITY); structureElement.setComment("comment"); ITUtilStructureElement.assertValidate(structureElement, StructureChoice.CREATE, Boolean.TRUE); -- GitLab