FIX:: checkstyle 'common'

This commit is contained in:
mlwauben
2019-03-26 08:46:54 +01:00
parent 4200ae587d
commit 0ae5e7f4ee
5 changed files with 54 additions and 17 deletions

View File

@@ -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);
}

View File

@@ -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;
}
}
}

View File

@@ -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;
}
}
}

View File

@@ -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()));
}
}
}

View File

@@ -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());
}
}
}