Add test for leaderboard JSON
This commit is contained in:
@@ -74,6 +74,16 @@ public class UserService {
|
|||||||
user.addFriend(add);
|
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.
|
* The method sets input value.
|
||||||
* @param name of the user
|
* @param name of the user
|
||||||
|
|||||||
@@ -174,4 +174,13 @@ public class UserServiceTest {
|
|||||||
assertEquals(alex.getFriends(), test);
|
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}]");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user