From 4e3fb07d2ff1de05f54061984ba8b69ac0ed46ed Mon Sep 17 00:00:00 2001 From: Kaiser-Yang Date: Mon, 21 Oct 2024 09:56:27 +0000 Subject: [PATCH] Apply Google Java Style Format --- .../gcs/controller/RepositoryController.java | 36 ++++++++++++------- .../cmipt/gcs/controller/UserController.java | 21 ++++++----- .../gcs/pojo/repository/RepositoryDTO.java | 3 +- .../controller/RepositoryControllerTest.java | 4 ++- 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/main/java/edu/cmipt/gcs/controller/RepositoryController.java b/src/main/java/edu/cmipt/gcs/controller/RepositoryController.java index fd2a8f7..2a88097 100644 --- a/src/main/java/edu/cmipt/gcs/controller/RepositoryController.java +++ b/src/main/java/edu/cmipt/gcs/controller/RepositoryController.java @@ -23,6 +23,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; + import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.Size; @@ -183,12 +184,11 @@ public ResponseEntity updateRepository( tags = {"Repository", "Get Method"}) @Parameters({ @Parameter( - name = "userId", - description = "User id", - required = true, - in = ParameterIn.QUERY, - schema = @Schema(implementation = Long.class) - ), + name = "userId", + description = "User id", + required = true, + in = ParameterIn.QUERY, + schema = @Schema(implementation = Long.class)), @Parameter( name = "repositoryName", description = "Repository name", @@ -201,12 +201,24 @@ public ResponseEntity updateRepository( @ApiResponse(responseCode = "400", description = "Repository name is invalid") }) public void checkRepositoryNameValidity( - @RequestParam("repositoryName") - @Size(min = ValidationConstant.MIN_REPOSITORY_NAME_LENGTH, max = ValidationConstant.MAX_REPOSITORY_NAME_LENGTH, message ="REPOSITORYDTO_REPOSITORYNAME_SIZE {RepositoryDTO.repositoryName.Size}") - @NotBlank(message = "REPOSITORYDTO_REPOSITORYNAME_NOTBLANK {RepositoryDTO.repositoryName.NotBlank}") - @Pattern(regexp = ValidationConstant.REPOSITORY_NAME_PATTERN, message = "REPOSITORYNAME_PATTERN_MISMATCH {REPOSITORYNAME_PATTERN_MISMATCH}") - String repositoryName, - @RequestParam("userId") Long userId) { + @RequestParam("repositoryName") + @Size( + min = ValidationConstant.MIN_REPOSITORY_NAME_LENGTH, + max = ValidationConstant.MAX_REPOSITORY_NAME_LENGTH, + message = + "REPOSITORYDTO_REPOSITORYNAME_SIZE" + + " {RepositoryDTO.repositoryName.Size}") + @NotBlank( + message = + "REPOSITORYDTO_REPOSITORYNAME_NOTBLANK" + + " {RepositoryDTO.repositoryName.NotBlank}") + @Pattern( + regexp = ValidationConstant.REPOSITORY_NAME_PATTERN, + message = + "REPOSITORYNAME_PATTERN_MISMATCH" + + " {REPOSITORYNAME_PATTERN_MISMATCH}") + String repositoryName, + @RequestParam("userId") Long userId) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("user_id", userId); queryWrapper.eq("repository_name", repositoryName); diff --git a/src/main/java/edu/cmipt/gcs/controller/UserController.java b/src/main/java/edu/cmipt/gcs/controller/UserController.java index ad07ef4..d658f8f 100644 --- a/src/main/java/edu/cmipt/gcs/controller/UserController.java +++ b/src/main/java/edu/cmipt/gcs/controller/UserController.java @@ -329,15 +329,14 @@ public void checkUsernameValidity( content = @Content(schema = @Schema(implementation = ErrorVO.class))) }) public void checkPasswordValidity( - @RequestParam("userPassword") - @Size( - min = ValidationConstant.MIN_PASSWORD_LENGTH, - max = ValidationConstant.MAX_PASSWORD_LENGTH, - message = "USERDTO_PASSWORD_SIZE {UserDTO.password.Size}") - @NotBlank(message = "USERDTO_PASSWORD_NOTBLANK {UserDTO.password.NotBlank}") - @Pattern( - regexp = ValidationConstant.PASSWORD_PATTERN, - message = "PASSWORD_PATTERN_MISMATCH {PASSWORD_PATTERN_MISMATCH}") - String password) { - } + @RequestParam("userPassword") + @Size( + min = ValidationConstant.MIN_PASSWORD_LENGTH, + max = ValidationConstant.MAX_PASSWORD_LENGTH, + message = "USERDTO_PASSWORD_SIZE {UserDTO.password.Size}") + @NotBlank(message = "USERDTO_PASSWORD_NOTBLANK {UserDTO.password.NotBlank}") + @Pattern( + regexp = ValidationConstant.PASSWORD_PATTERN, + message = "PASSWORD_PATTERN_MISMATCH {PASSWORD_PATTERN_MISMATCH}") + String password) {} } diff --git a/src/main/java/edu/cmipt/gcs/pojo/repository/RepositoryDTO.java b/src/main/java/edu/cmipt/gcs/pojo/repository/RepositoryDTO.java index 0f1d6bf..1f96085 100644 --- a/src/main/java/edu/cmipt/gcs/pojo/repository/RepositoryDTO.java +++ b/src/main/java/edu/cmipt/gcs/pojo/repository/RepositoryDTO.java @@ -53,4 +53,5 @@ public record RepositoryDTO( "REPOSITORYDTO_REPOSITORYDESCRIPTION_SIZE" + " {RepositoryDTO.repositoryDescription.Size}") String repositoryDescription, - @Schema(description = "Whether or Not Private Repo", example = "false") Boolean isPrivate) {} + @Schema(description = "Whether or Not Private Repo", example = "false") + Boolean isPrivate) {} diff --git a/src/test/java/edu/cmipt/gcs/controller/RepositoryControllerTest.java b/src/test/java/edu/cmipt/gcs/controller/RepositoryControllerTest.java index 4ac8076..3043d91 100644 --- a/src/test/java/edu/cmipt/gcs/controller/RepositoryControllerTest.java +++ b/src/test/java/edu/cmipt/gcs/controller/RepositoryControllerTest.java @@ -53,7 +53,9 @@ public void testCreateRepositoryValid() throws Exception { "isPrivate": %s } """ - .formatted(repositoryName, i % 2 == 0 ? "false" : "true"))) + .formatted( + repositoryName, + i % 2 == 0 ? "false" : "true"))) .andExpect(status().isOk()); } var content =