From 61e31df1578abe97a06118b6b382bcff87087136 Mon Sep 17 00:00:00 2001 From: mlwauben Date: Tue, 26 Mar 2019 08:46:54 +0100 Subject: [PATCH] FIX:: checkstyle 'common' --- .../greenify/common/ApplicationException.java | 4 +++ .../java/greenify/common/ErrorResponse.java | 19 ++++++++++-- .../main/java/greenify/common/UserDto.java | 30 +++++++++++++++---- .../src/test/java/ErrorResponseTest.java | 10 +++---- src/Common/src/test/java/UserDtoTest.java | 8 ++--- 5 files changed, 54 insertions(+), 17 deletions(-) diff --git a/src/Common/src/main/java/greenify/common/ApplicationException.java b/src/Common/src/main/java/greenify/common/ApplicationException.java index b9321ed..f64b9fd 100644 --- a/src/Common/src/main/java/greenify/common/ApplicationException.java +++ b/src/Common/src/main/java/greenify/common/ApplicationException.java @@ -1,6 +1,10 @@ package greenify.common; public class ApplicationException extends RuntimeException { + /** + * This method returns an application exception message. + * @param message the exception message + */ public ApplicationException(String message) { super(message); } diff --git a/src/Common/src/main/java/greenify/common/ErrorResponse.java b/src/Common/src/main/java/greenify/common/ErrorResponse.java index 4acb747..df449c6 100644 --- a/src/Common/src/main/java/greenify/common/ErrorResponse.java +++ b/src/Common/src/main/java/greenify/common/ErrorResponse.java @@ -1,19 +1,34 @@ package greenify.common; public class ErrorResponse { - String message; + private String message; + /** + * The method creates a new error response with a message. + * @param message the message you want to response with + */ public ErrorResponse(String message) { this.message = message; } + /** + * This method creates an error response without a message. + */ public ErrorResponse() { } + /** + * This method returns the message. + * @return the message + */ public String getMessage() { return message; } + /** + * This method sets a message. + * @param message the message you want set + */ public void setMessage(String message) { this.message = message; } -} \ No newline at end of file +} diff --git a/src/Common/src/main/java/greenify/common/UserDto.java b/src/Common/src/main/java/greenify/common/UserDto.java index f3bdf29..2b83014 100644 --- a/src/Common/src/main/java/greenify/common/UserDto.java +++ b/src/Common/src/main/java/greenify/common/UserDto.java @@ -1,9 +1,13 @@ +/* + DTO stands for Data Transfer Object. + is an object that carries data between processes. + The motivation for its use is that communication between processes + is usually done + resorting to remote interfaces (e.g., web services), + where each call is an expensive operation. + */ package greenify.common; -// DTO stands for Data Transfer Object. -// is an object that carries data between processes. -// The motivation for its use is that communication between processes is usually done -// resorting to remote interfaces (e.g., web services), where each call is an expensive operation. public class UserDto { private Long id; private String name; @@ -21,19 +25,35 @@ public class UserDto { this.name = name; } + /** + * Method that returns the name of a user. + * @return name + */ public String getName() { return name; } + /** + * Method that sets the name of a user. + * @param name name of a user + */ public void setName(String name) { this.name = name; } + /** + * Method that returns the ID of a user. + * @return id + */ public Long getId() { return id; } + /** + * Method that sets the ID of a user. + * @param id id of a user + */ public void setId(Long id) { this.id = id; } -} \ No newline at end of file +} diff --git a/src/Common/src/test/java/ErrorResponseTest.java b/src/Common/src/test/java/ErrorResponseTest.java index 350e71f..05892e1 100644 --- a/src/Common/src/test/java/ErrorResponseTest.java +++ b/src/Common/src/test/java/ErrorResponseTest.java @@ -1,17 +1,15 @@ import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import greenify.common.ErrorResponse; - import org.junit.Test; public class ErrorResponseTest { + @Test public void setAndGetTest() { ErrorResponse response = new ErrorResponse("New error"); ErrorResponse testResponse = new ErrorResponse(); testResponse.setMessage("New error"); - assertTrue(response.getMessage().equals("New error")); + assertEquals("New error", response.getMessage()); } @Test @@ -19,6 +17,6 @@ public class ErrorResponseTest { ErrorResponse first = new ErrorResponse("New error"); ErrorResponse second = new ErrorResponse("New error"); assertEquals(first.getMessage(), second.getMessage()); - assertTrue(first.getMessage().equals(second.getMessage())); } -} \ No newline at end of file + +} diff --git a/src/Common/src/test/java/UserDtoTest.java b/src/Common/src/test/java/UserDtoTest.java index a1892bd..565ca0f 100644 --- a/src/Common/src/test/java/UserDtoTest.java +++ b/src/Common/src/test/java/UserDtoTest.java @@ -1,17 +1,16 @@ import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import greenify.common.UserDto; import org.junit.Test; public class UserDtoTest { + @Test public void setAndGetTest() { UserDto testUser = new UserDto(); testUser.setId(1L); testUser.setName("greenify"); UserDto user = new UserDto(1L, "greenify"); - assertTrue(user.getId() == 1L); + assertEquals(1L, (long) user.getId()); assertEquals(user.getName(), "greenify"); } @@ -22,4 +21,5 @@ public class UserDtoTest { assertEquals(first.getId(), second.getId()); assertEquals(first.getName(), second.getName()); } -} \ No newline at end of file + +}