FIX:: checkstyle 'common'
This commit is contained in:
committed by
Merel Steenbergen
parent
064e8e04c2
commit
61e31df157
@@ -1,6 +1,10 @@
|
|||||||
package greenify.common;
|
package greenify.common;
|
||||||
|
|
||||||
public class ApplicationException extends RuntimeException {
|
public class ApplicationException extends RuntimeException {
|
||||||
|
/**
|
||||||
|
* This method returns an application exception message.
|
||||||
|
* @param message the exception message
|
||||||
|
*/
|
||||||
public ApplicationException(String message) {
|
public ApplicationException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,34 @@
|
|||||||
package greenify.common;
|
package greenify.common;
|
||||||
|
|
||||||
public class ErrorResponse {
|
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) {
|
public ErrorResponse(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method creates an error response without a message.
|
||||||
|
*/
|
||||||
public ErrorResponse() { }
|
public ErrorResponse() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the message.
|
||||||
|
* @return the message
|
||||||
|
*/
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method sets a message.
|
||||||
|
* @param message the message you want set
|
||||||
|
*/
|
||||||
public void setMessage(String message) {
|
public void setMessage(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
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 {
|
public class UserDto {
|
||||||
private Long id;
|
private Long id;
|
||||||
private String name;
|
private String name;
|
||||||
@@ -21,19 +25,35 @@ public class UserDto {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method that returns the name of a user.
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method that sets the name of a user.
|
||||||
|
* @param name name of a user
|
||||||
|
*/
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method that returns the ID of a user.
|
||||||
|
* @return id
|
||||||
|
*/
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method that sets the ID of a user.
|
||||||
|
* @param id id of a user
|
||||||
|
*/
|
||||||
public void setId(Long id) {
|
public void setId(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import greenify.common.ErrorResponse;
|
import greenify.common.ErrorResponse;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ErrorResponseTest {
|
public class ErrorResponseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setAndGetTest() {
|
public void setAndGetTest() {
|
||||||
ErrorResponse response = new ErrorResponse("New error");
|
ErrorResponse response = new ErrorResponse("New error");
|
||||||
ErrorResponse testResponse = new ErrorResponse();
|
ErrorResponse testResponse = new ErrorResponse();
|
||||||
testResponse.setMessage("New error");
|
testResponse.setMessage("New error");
|
||||||
assertTrue(response.getMessage().equals("New error"));
|
assertEquals("New error", response.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -19,6 +17,6 @@ public class ErrorResponseTest {
|
|||||||
ErrorResponse first = new ErrorResponse("New error");
|
ErrorResponse first = new ErrorResponse("New error");
|
||||||
ErrorResponse second = new ErrorResponse("New error");
|
ErrorResponse second = new ErrorResponse("New error");
|
||||||
assertEquals(first.getMessage(), second.getMessage());
|
assertEquals(first.getMessage(), second.getMessage());
|
||||||
assertTrue(first.getMessage().equals(second.getMessage()));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import greenify.common.UserDto;
|
import greenify.common.UserDto;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class UserDtoTest {
|
public class UserDtoTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setAndGetTest() {
|
public void setAndGetTest() {
|
||||||
UserDto testUser = new UserDto();
|
UserDto testUser = new UserDto();
|
||||||
testUser.setId(1L);
|
testUser.setId(1L);
|
||||||
testUser.setName("greenify");
|
testUser.setName("greenify");
|
||||||
UserDto user = new UserDto(1L, "greenify");
|
UserDto user = new UserDto(1L, "greenify");
|
||||||
assertTrue(user.getId() == 1L);
|
assertEquals(1L, (long) user.getId());
|
||||||
assertEquals(user.getName(), "greenify");
|
assertEquals(user.getName(), "greenify");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,4 +21,5 @@ public class UserDtoTest {
|
|||||||
assertEquals(first.getId(), second.getId());
|
assertEquals(first.getId(), second.getId());
|
||||||
assertEquals(first.getName(), second.getName());
|
assertEquals(first.getName(), second.getName());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user