Skip to content

Commit

Permalink
#254 Remove deprecated image URLs in ArtistBio class
Browse files Browse the repository at this point in the history
  • Loading branch information
kagemomiji committed Jun 12, 2024
1 parent 3f99a63 commit 991bcea
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ public String getLastFmUrl() {
return lastFmUrl;
}

@Deprecated
public String getSmallImageUrl() {
return smallImageUrl;
}

@Deprecated
public String getMediumImageUrl() {
return mediumImageUrl;
}

@Deprecated
public String getLargeImageUrl() {
return largeImageUrl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,14 @@ private ArtistBio getArtistBio(String artistName, Locale locale) {
if (info == null) {
return null;
}

// image urls are deprecated
return new ArtistBio(processWikiText(info.getWikiSummary()),
info.getMbid(),
info.getUrl(),
info.getImageURL(ImageSize.MEDIUM),
info.getImageURL(ImageSize.LARGE),
info.getImageURL(ImageSize.MEGA));
"",
"",
"");
} catch (Throwable x) {
LOG.warn("Failed to find artist bio for " + artistName, x);
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
This file is part of Airsonic.
Airsonic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Airsonic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Airsonic. If not, see <http://www.gnu.org/licenses/>.
Copyright 2024 (C) Y.Tory
*/

package org.airsonic.player.service;

import de.umass.lastfm.Album;
Expand Down Expand Up @@ -40,6 +59,7 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.startsWith;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;


Expand Down Expand Up @@ -323,12 +343,6 @@ public void testGetArtistBioByMediaFileShouldReturnArtistBio() {
when(mockedInfoArtist.getWikiSummary()).thenReturn("testSummary");
when(mockedInfoArtist.getMbid()).thenReturn("testMbid");
when(mockedInfoArtist.getUrl()).thenReturn("testUrl");
when(mockedInfoArtist.getImageURL(eq(ImageSize.MEGA))).
thenReturn("testMegaImageURL");
when(mockedInfoArtist.getImageURL(eq(ImageSize.LARGE))).
thenReturn("testLargeImageURL");
when(mockedInfoArtist.getImageURL(eq(ImageSize.MEDIUM))).
thenReturn("testMediumImageURL");

try (MockedStatic<Artist> mockedStaticArtist = org.mockito.Mockito.mockStatic(Artist.class)) {
mockedStaticArtist.when(() -> Artist.getInfo(eq("testArtist"), eq(Locale.ENGLISH), isNull(), anyString())).thenReturn(mockedInfoArtist);
Expand All @@ -338,9 +352,7 @@ public void testGetArtistBioByMediaFileShouldReturnArtistBio() {
assertEquals("testSummary", artistBio.getBiography());
assertEquals("testMbid", artistBio.getMusicBrainzId());
assertEquals("testUrl", artistBio.getLastFmUrl());
assertEquals("testMegaImageURL", artistBio.getLargeImageUrl());
assertEquals("testLargeImageURL", artistBio.getMediumImageUrl());
assertEquals("testMediumImageURL", artistBio.getSmallImageUrl());
verifyNoMoreInteractions(mockedInfoArtist);
}
}

Expand All @@ -354,12 +366,6 @@ public void testGetArtistBioShouldRuturn() {
when(mockedInfoArtist.getWikiSummary()).thenReturn("testSummary");
when(mockedInfoArtist.getMbid()).thenReturn("testMbid");
when(mockedInfoArtist.getUrl()).thenReturn("testUrl");
when(mockedInfoArtist.getImageURL(eq(ImageSize.MEGA))).
thenReturn("testMegaImageURL");
when(mockedInfoArtist.getImageURL(eq(ImageSize.LARGE))).
thenReturn("testLargeImageURL");
when(mockedInfoArtist.getImageURL(eq(ImageSize.MEDIUM))).
thenReturn("testMediumImageURL");

try (MockedStatic<Artist> mockedStaticArtist = org.mockito.Mockito.mockStatic(Artist.class)) {
mockedStaticArtist.when(() -> Artist.getInfo(eq("testArtist"), eq(Locale.ENGLISH), isNull(), anyString())).thenReturn(mockedInfoArtist);
Expand All @@ -369,9 +375,7 @@ public void testGetArtistBioShouldRuturn() {
assertEquals("testSummary", artistBio.getBiography());
assertEquals("testMbid", artistBio.getMusicBrainzId());
assertEquals("testUrl", artistBio.getLastFmUrl());
assertEquals("testMegaImageURL", artistBio.getLargeImageUrl());
assertEquals("testLargeImageURL", artistBio.getMediumImageUrl());
assertEquals("testMediumImageURL", artistBio.getSmallImageUrl());
verifyNoMoreInteractions(mockedInfoArtist);
}
}

Expand Down Expand Up @@ -559,8 +563,4 @@ public void testSearchCoverArtWithShouldReturnList(String artist, String album,
}
}





}

0 comments on commit 991bcea

Please sign in to comment.