diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2017-01-17 00:05:23 +0100 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2017-01-17 00:05:23 +0100 |
commit | 8aeb13f44fbeec2d836d1a71e5cc2d4cdb8486b9 (patch) | |
tree | 4096598b6d0b97bd2583ff53a488a97c6455aa31 /src/main/java/org/luxons | |
parent | Add test for PlayerRepository (diff) | |
download | seven-wonders-8aeb13f44fbeec2d836d1a71e5cc2d4cdb8486b9.tar.gz seven-wonders-8aeb13f44fbeec2d836d1a71e5cc2d4cdb8486b9.tar.bz2 seven-wonders-8aeb13f44fbeec2d836d1a71e5cc2d4cdb8486b9.zip |
Add test for LobbyRepository
Diffstat (limited to 'src/main/java/org/luxons')
-rw-r--r-- | src/main/java/org/luxons/sevenwonders/repositories/LobbyRepository.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/org/luxons/sevenwonders/repositories/LobbyRepository.java b/src/main/java/org/luxons/sevenwonders/repositories/LobbyRepository.java index dce824ad..8f305791 100644 --- a/src/main/java/org/luxons/sevenwonders/repositories/LobbyRepository.java +++ b/src/main/java/org/luxons/sevenwonders/repositories/LobbyRepository.java @@ -35,17 +35,25 @@ public class LobbyRepository { return lobby; } - public Lobby find(long lobbyId) { + public Lobby find(long lobbyId) throws LobbyNotFoundException { Lobby lobby = lobbies.get(lobbyId); if (lobby == null) { - throw new LobbyNotFoundException(String.valueOf(lobbyId)); + throw new LobbyNotFoundException(lobbyId); + } + return lobby; + } + + public Lobby remove(long lobbyId) throws LobbyNotFoundException { + Lobby lobby = lobbies.remove(lobbyId); + if (lobby == null) { + throw new LobbyNotFoundException(lobbyId); } return lobby; } public static class LobbyNotFoundException extends RuntimeException { - LobbyNotFoundException(String name) { - super("Lobby not found for game '" + name + "'"); + LobbyNotFoundException(long id) { + super("Lobby not found for id '" + id + "'"); } } } |