From dfd89ecb8ffe4d959ff31b97fa9313fe801479d9 Mon Sep 17 00:00:00 2001 From: RicardoDiNu Date: Fri, 26 Apr 2024 20:54:45 +0200 Subject: [PATCH] MultiplayerSession Unit Tests - PlayerService(users) --- src/test/java/com/uniovi/Wiq_UnitTests.java | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/test/java/com/uniovi/Wiq_UnitTests.java b/src/test/java/com/uniovi/Wiq_UnitTests.java index ef05ca87..02952ca2 100644 --- a/src/test/java/com/uniovi/Wiq_UnitTests.java +++ b/src/test/java/com/uniovi/Wiq_UnitTests.java @@ -1743,6 +1743,30 @@ public void testRandomMultiplayerQuestions() throws InterruptedException, IOExce Assertions.assertEquals(5,questions.size()); } + @Test + @Order(108) + public void PlayerServiceImpl_getUsersByMultiplayerCode_ReturnsPlayer() { + Long playerId = 1L; + Player player = createPlayer(); + player.setId(playerId); + + player.setMultiplayerCode(123); + playerRepository.save(player); + + List result = playerService.getUsersByMultiplayerCode(123); + + Assertions.assertEquals(1, result.size()); + Assertions.assertEquals(123, result.get(0).getMultiplayerCode()); + } + + @Test + @Order(109) + public void PlayerServiceImpl_getUsersByMultiplayerCode_ReturnsEmpty() { + List result = playerService.getUsersByMultiplayerCode(123); + + Assertions.assertTrue(result.isEmpty()); + } + /** * Sends an HTTP request to the API