66import com .github .tomakehurst .wiremock .junit5 .WireMockRuntimeInfo ;
77import com .github .tomakehurst .wiremock .junit5 .WireMockTest ;
88import java .util .Collections ;
9+ import java .util .Set ;
10+ import java .util .stream .Collectors ;
911import me .itzg .helpers .cache .ApiCachingDisabled ;
12+ import me .itzg .helpers .curseforge .model .CurseForgeMod ;
1013import me .itzg .helpers .http .SharedFetch .Options ;
1114import org .intellij .lang .annotations .Language ;
1215import org .junit .jupiter .api .Test ;
16+ import reactor .core .publisher .Flux ;
1317
1418@ WireMockTest
1519class CurseForgeApiClientTest {
@@ -38,4 +42,30 @@ void apiKeyHeaderIsTrimmed(WireMockRuntimeInfo wmInfo) {
3842 .withHeader ("x-api-key" , equalTo ("key" ))
3943 );
4044 }
45+
46+ @ Test
47+ void unknownModDoesNotPreventResolvingOthers (WireMockRuntimeInfo wmInfo ) {
48+ stubFor (get (urlPathEqualTo ("/v1/mods/search" ))
49+ .withQueryParam ("slug" , equalTo ("unknown-mod" ))
50+ .willReturn (jsonResponse ("{\" data\" : []}" , 200 ))
51+ );
52+ stubFor (get (urlPathEqualTo ("/v1/mods/search" ))
53+ .withQueryParam ("slug" , equalTo ("known-mod" ))
54+ .willReturn (jsonResponse ("{\" data\" : [{\" id\" : 100, \" classId\" : 6, \" gameId\" : 432}]}" , 200 ))
55+ );
56+
57+ try (CurseForgeApiClient client = new CurseForgeApiClient (wmInfo .getHttpBaseUrl (),
58+ "key" , Options .builder ().build (), "432" , new ApiCachingDisabled ()
59+ )) {
60+ final Set <Integer > ids = Flux .just ("unknown-mod" , "known-mod" )
61+ .flatMap (slug -> client .searchMod (slug , 6 )
62+ .map (CurseForgeMod ::getId )
63+ .onErrorComplete (UnknownModException .class )
64+ )
65+ .collect (Collectors .toSet ())
66+ .block ();
67+
68+ assertThat (ids ).containsExactly (100 );
69+ }
70+ }
4171}
0 commit comments