From 981b561aa0741ba80e58f28a9e480ba762b548a1 Mon Sep 17 00:00:00 2001 From: Erik Moravec <xmoravec@fi.muni.cz> Date: Fri, 28 May 2021 19:43:35 +0200 Subject: [PATCH] refactor: fixed Optional related warnings in tests --- .../icehockeymanager/facades/TeamManagerFacadeImplTest.java | 2 +- .../fi/pa165/icehockeymanager/facades/UserFacadeImplTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/service/src/test/java/cz/muni/fi/pa165/icehockeymanager/facades/TeamManagerFacadeImplTest.java b/service/src/test/java/cz/muni/fi/pa165/icehockeymanager/facades/TeamManagerFacadeImplTest.java index 466e236..2f40f63 100644 --- a/service/src/test/java/cz/muni/fi/pa165/icehockeymanager/facades/TeamManagerFacadeImplTest.java +++ b/service/src/test/java/cz/muni/fi/pa165/icehockeymanager/facades/TeamManagerFacadeImplTest.java @@ -95,7 +95,7 @@ public class TeamManagerFacadeImplTest { Team team = buildTeamMock(1L, "Boston Bruins"); when(teamService.findTeam(1L)).thenReturn(Optional.ofNullable(team)); Player player = buildPlayerMock(1L, "David Pastrnak", team); - when(playerService.findPlayer(1L)).thenReturn(Optional.ofNullable(player)); + when(playerService.findPlayer(1L)).thenReturn(Optional.of(player)); teamManagerFacade.firePlayer(1L); verify(teamService).removePlayerFromTeam(team, player); verify(playerService).removeTeamFromPlayer(player, team); diff --git a/service/src/test/java/cz/muni/fi/pa165/icehockeymanager/facades/UserFacadeImplTest.java b/service/src/test/java/cz/muni/fi/pa165/icehockeymanager/facades/UserFacadeImplTest.java index 8aa9d12..01593a2 100644 --- a/service/src/test/java/cz/muni/fi/pa165/icehockeymanager/facades/UserFacadeImplTest.java +++ b/service/src/test/java/cz/muni/fi/pa165/icehockeymanager/facades/UserFacadeImplTest.java @@ -76,14 +76,14 @@ class UserFacadeImplTest { var player = mock(Player.class); when(player.getId()).thenReturn(1L); when(player.getName()).thenReturn("Satan"); - when(playerService.findPlayer(1)).thenReturn(Optional.ofNullable(player)); + when(playerService.findPlayer(1)).thenReturn(Optional.of(player)); var expected = new PlayerDto(); expected.setId(1L); expected.setName("Satan"); Optional<PlayerDto> result = userFacade.findPlayer(1); - Assertions.assertThat(result).isEqualTo(Optional.ofNullable(expected)); + Assertions.assertThat(result).isEqualTo(Optional.of(expected)); verify(playerService).findPlayer(1); } -- GitLab