Skip to content

Commit

Permalink
Added support for the www.comicvine.com web address [#22]
Browse files Browse the repository at this point in the history
  • Loading branch information
mcpierce committed Jul 31, 2024
1 parent aba2297 commit 1d40541
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@
@Log4j2
public class ComicVineMetadataAdaptor extends AbstractMetadataAdaptor {
static final String REFERENCE_ID_PATTERN =
"^http[s]?\\:\\/\\/comicvine\\.gamespot\\.com\\/.*\\/4000-([\\d]{1,6}).*";
"^https?\\:\\/\\/(www\\.comicvine\\.com|comicvine\\.gamespot\\.com)\\/.*\\/4000-([\\d]{1,6}).*";
/** The base URL for ComicVine. */
public static final String BASE_URL = "https://comicvine.gamespot.com";

public static final long MINIMUM_DELAY_VALUE = 1L;
public static final int REFERENCE_ID_POSITION = 2;

/** The action to fetch the list of volumes. */
protected ComicVineGetVolumesAction comicVineGetVolumesAction = new ComicVineGetVolumesAction();
Expand Down Expand Up @@ -144,7 +145,7 @@ public String getReferenceId(final String webAddress) {
final Matcher matches = pattern.matcher(webAddress);
String referenceId = null;
if (matches.matches()) {
referenceId = matches.group(1);
referenceId = matches.group(REFERENCE_ID_POSITION);
}
return referenceId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

@RunWith(MockitoJUnitRunner.class)
public class ComicVineMetadataAdaptorProviderTest {
private static final String TEST_GOOD_ADDRESS =
private static final String TEST_GOOD_ADDRESS_1 =
"https://comicvine.gamespot.com/action-comics-futures-end-1-crossroads/4000-463937/";
private static final String TEST_GOOD_ADDRESS_2 =
"https://www.comicvine.com/action-comics-futures-end-1-crossroads/4000-463937/";
private static final String TEST_BAD_ADDRESS =
"https://notcomicvine.gamespot.com/action-comics-futures-end-1-crossroads/4000-463937";;
"https://notcomicvine.gamespot.com/action-comics-futures-end-1-crossroads/4000-463937";

@InjectMocks private ComicVineMetadataAdaptorProvider provider;

Expand All @@ -22,7 +24,22 @@ public void testSupportedReferenceWithBadReference() {
}

@Test
public void testSupportedReference() {
assertTrue(provider.supportedReference(TEST_GOOD_ADDRESS));
public void testSupportedReferenceOldHttpComicVineDomain() {
assertTrue(provider.supportedReference(TEST_GOOD_ADDRESS_2.replace("https", "http")));
}

@Test
public void testSupportedReferenceOldComicVineDomain() {
assertTrue(provider.supportedReference(TEST_GOOD_ADDRESS_2));
}

@Test
public void testSupportedReferenceCurrentHttpComicVineDomain() {
assertTrue(provider.supportedReference(TEST_GOOD_ADDRESS_1.replace("https", "http")));
}

@Test
public void testSupportedReferenceCurrentComicVineDomain() {
assertTrue(provider.supportedReference(TEST_GOOD_ADDRESS_1));
}
}

0 comments on commit 1d40541

Please sign in to comment.