Add test for leaderboard JSON

This commit is contained in:
Merel Steenbergen
2019-03-26 11:31:41 +01:00
parent f39aef31d0
commit f11cfc804b
2 changed files with 19 additions and 0 deletions

View File

@@ -74,6 +74,16 @@ public class UserService {
user.addFriend(add);
}
/**
* Returns the friendlist of the user in JSON.
* @param name the username of the user
* @return a userDTO of the logged in user
*/
public String getLeaderboard(String name) {
User user = userRepository.findByName(name);
return user.friendsToString();
}
/**
* The method sets input value.
* @param name of the user

View File

@@ -174,4 +174,13 @@ public class UserServiceTest {
assertEquals(alex.getFriends(), test);
}
@Test
public void leaderboardTest() {
User alex = userRepository.findByName("alex");
User lola = userRepository.findByName("lola");
userService.addFriend("alex", "lola");
assertEquals(userService.getLeaderboard("alex"), "friends=[{name=lola, footprint=0.0}]");
}
}