public static List<MusicProtocol.MusicTrack> convertToAppleMusicPlaylistTracks(Collection<MusicPlaylistItem> musicPlaylistItems) {
        List<MusicProtocol.MusicTrack> convertedTracks = new ArrayList<>();
        for (MusicPlaylistItem item : musicPlaylistItems) {
            if (item == null) {
                throw new IllegalStateException("MusicPlaylistItem cannot be null");
            }

            if (StringUtils.isBlank(item.getPlaylistId())) {
                throw new IllegalStateException("MusicPlaylistIte::getPlaylistId cannot be blank");
            }

            MusicProtocol.MusicTrack.Builder trackBuilder = convertMusicRecordingToTrackBuilder(item.getTrack());

            trackBuilder.setPlaylistId(item.getPlaylistId())
                    .setPlaylistPosition(item.getOrder());

            convertedTracks.add(trackBuilder.build());
        }

        return convertedTracks;
    }
@Test
    public void testConvertToAppleMusicPlaylistTracks() {
        String expectedISRC = "1234567890ab";
        String expectedTitle = "Expected Track Title";
        long expectedDurationMillis = RandomUtils.nextLong();
        String expectedArtistName = "Expected Artist Name";
        MusicGroup musicGroup = new MusicGroup(expectedArtistName);
        String expectedICPN = "1234567890abcdefg";
        String expectedAlbumTitle = "Expected Album Title";
        MusicRelease musicRelease = new MusicRelease(expectedICPN, expectedAlbumTitle, List.of(musicGroup));
        boolean expectedIsExplicit = true;
        MusicRecording musicRecording = new MusicRecording(expectedISRC, expectedTitle, expectedDurationMillis, musicRelease, List.of(musicGroup), expectedIsExplicit);
        String expectedPlaylistId = "ExpectedPlaylist.ID";
        int expectedOrder = 1;
        String invalidPlaylistId = " ";

        MusicPlaylistItem musicPlaylistItem = new MusicPlaylistItem(musicRecording, expectedPlaylistId, expectedOrder);

        List<MusicPlaylistItem> playlistItems = new ArrayList<>();
        playlistItems.add(musicPlaylistItem);

        // Null playlist
        List<MusicPlaylistItem> nullPlaylistItems = new ArrayList<>();
        nullPlaylistItems.add(null);
        Assertions.assertThrows(IllegalStateException.class, () -> AppleMusicPlaylistConverter.convertToAppleMusicPlaylistTracks(nullPlaylistItems));

        // One playlist item
        List<MusicProtocol.MusicTrack> musicTracks = AppleMusicPlaylistConverter.convertToAppleMusicPlaylistTracks(playlistItems);
        Assertions.assertNotNull(musicTracks);
        Assertions.assertFalse(musicTracks.isEmpty());
        Assertions.assertEquals(musicTracks.size(), 1);
        MusicProtocol.MusicTrack validMusicTrack = musicTracks.get(0);
        Assertions.assertNotNull(validMusicTrack);
        Assertions.assertTrue(validMusicTrack.hasPlaylistId());
        Assertions.assertEquals(validMusicTrack.getPlaylistId(), expectedPlaylistId);
        Assertions.assertTrue(validMusicTrack.hasPlaylistPosition());
        Assertions.assertEquals(validMusicTrack.getPlaylistPosition(), expectedOrder);
        // Tested in testConvertMusicRecordingToTrackBuilder
        Assertions.assertTrue(validMusicTrack.hasMusicAlbum());
        Assertions.assertTrue(validMusicTrack.hasIsrcCode());
        Assertions.assertTrue(validMusicTrack.hasTitle());
        Assertions.assertTrue(validMusicTrack.hasDurationMillis());
        Assertions.assertTrue(validMusicTrack.hasIsExplicit());
        Assertions.assertEquals(validMusicTrack.getIsExplicit(), expectedIsExplicit);

        // One playlist item with invalid playlist id
        MusicPlaylistItem invalidPlaylistIdItem = new MusicPlaylistItem(musicRecording, invalidPlaylistId, expectedOrder);
        Assertions.assertThrows(IllegalStateException.class, () -> AppleMusicPlaylistConverter.convertToAppleMusicPlaylistTracks(List.of(musicPlaylistItem, invalidPlaylistIdItem)));
    }