Fix the branch and add a test
This commit is contained in:
@@ -9,26 +9,49 @@ public class ActivityDto {
|
||||
public ActivityDto() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for ActivityDto.
|
||||
* @param id of the activity
|
||||
* @param name of the activity
|
||||
* @param description of the activity
|
||||
* @param score of the activity
|
||||
*/
|
||||
public ActivityDto(Long id, String name, String description, int score) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.score= score;
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(int score) {
|
||||
this.score = score;
|
||||
}
|
||||
}
|
||||
|
||||
31
src/Common/src/test/java/ActivityDtoTest.java
Normal file
31
src/Common/src/test/java/ActivityDtoTest.java
Normal file
@@ -0,0 +1,31 @@
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import greenify.common.ActivityDto;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ActivityDtoTest {
|
||||
@Test
|
||||
public void setAndGetTest() {
|
||||
ActivityDto testActivity = new ActivityDto();
|
||||
testActivity.setId(1L);
|
||||
testActivity.setName("eatVeganMeal");
|
||||
testActivity.setDescription("User adds a vegan meal");
|
||||
testActivity.setScore(10);
|
||||
ActivityDto activity = new ActivityDto(1L, "eatVeganMeal", "User adds a vegan meal", 10);
|
||||
assertTrue(activity.getId() == 1L);
|
||||
assertEquals(activity.getName(), "eatVeganMeal");
|
||||
assertEquals(activity.getDescription(), "User adds a vegan meal");
|
||||
assertEquals(activity.getScore(), 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsTest() {
|
||||
ActivityDto first = new ActivityDto(1L, "eatVeganMeal", "User adds a vegan meal", 10);
|
||||
ActivityDto second = new ActivityDto(1L, "eatVeganMeal", "User adds a vegan meal", 10);
|
||||
assertEquals(first.getId(), second.getId());
|
||||
assertEquals(first.getName(), second.getName());
|
||||
assertEquals(first.getDescription(), second.getDescription());
|
||||
assertEquals(first.getScore(), second.getScore());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user