Fix the branch and add a test

This commit is contained in:
cugurlu
2019-03-17 18:58:56 +01:00
parent 0c042daa1c
commit 1da7f62c95
9 changed files with 104 additions and 213 deletions

View File

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

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