GameMenuController { void playBackgroundMusic(GameContext gameContext, GameSpec selectedGameSpec, BackgroundMusicManager musicManager) { MediaPlayer currentMusic = musicManager.getCurrentMusic(); boolean defaultMusicPlaying = true; if (currentMusic != null) { Media currentMedia = currentMusic.getMedia(); if (currentMedia != null) { defaultMusicPlaying = currentMedia.getSource().contains(Configuration.DEFAULT_VALUE_BACKGROUND_MUSIC); } } log.info("is default music set : {}", defaultMusicPlaying); if (defaultMusicPlaying || musicManager.getPlaylist().isEmpty()) { musicManager.backupPlaylist(); musicManager.emptyPlaylist(); musicManager.playMusicAlone(selectedGameSpec.getGameSummary().getBackgroundMusicUrl()); gameContext.getMusicControl().updateMusicController(); } }  void onGameSelection(
        @NonNull GazePlay gazePlay,
        @NonNull Parent root,
        @NonNull GameSpec gameSpec,
        String gameName
    ); void chooseGame(
        GazePlay gazePlay,
        GameSpec selectedGameSpec,
        IGameVariant gameVariant
    );  }
@Test void shouldSetBackgroundMusic() { when(mockMusicManager.getCurrentMusic().getMedia().getSource()).thenReturn("songidea(copycat)_0.mp3"); when(mockMusicManager.getPlaylist().isEmpty()).thenReturn(false); when(mockGameSpec.getGameSummary()).thenReturn(mockGameSummary); when(mockGameSummary.getBackgroundMusicUrl()).thenReturn("https: when(mockGameContext.getMusicControl()).thenReturn(mockMusicControl); gameMenuController.playBackgroundMusic(mockGameContext, mockGameSpec, mockMusicManager); verify(mockMusicManager).backupPlaylist(); }
@Test void shouldNotSetBackgroundMusic() { when(mockMusicManager.getCurrentMusic().getMedia().getSource()).thenReturn("another-song.mp3"); when(mockMusicManager.getPlaylist().isEmpty()).thenReturn(false); gameMenuController.playBackgroundMusic(mockGameContext, mockGameSpec, mockMusicManager); assertTrue(BackgroundMusicManager.getInstance().getBackupPlaylist().isEmpty()); }