@@ -45,33 +45,75 @@ void getBulkProjectsWithUnknownServerSide(WireMockRuntimeInfo wmInfo) {
4545 }
4646 }
4747
48- @ Test
49- void getVersionsForProject (WireMockRuntimeInfo wmInfo ) {
50-
51- stubFor (get (urlPathMatching ("/v2/project/(BITzwT7B|clickvillagers)/version" ))
52- .withQueryParam ("loaders" , equalTo ("[\" purpur\" ,\" paper\" ,\" spigot\" ]" ))
53- .withQueryParam ("game_versions" , equalTo ("[\" 1.20.1\" ]" ))
54- .willReturn (aResponse ()
55- .withHeader ("Content-Type" , "application/json" )
56- .withBodyFile ("modrinth/project-BITzwT7B-version-resp.json" )
57- )
58- );
48+ @ Nested
49+ class getVersionsForProject {
50+ @ Test
51+ void exactLoader (WireMockRuntimeInfo wmInfo ) {
5952
60- try (ModrinthApiClient client = new ModrinthApiClient (wmInfo .getHttpBaseUrl (), "modrinth" , Options .builder ().build ())) {
61- final List <Version > result = client .getVersionsForProject ("BITzwT7B" , Loader .purpur , "1.20.1" )
62- .block ();
53+ stubFor (get (urlPathMatching ("/v2/project/(BITzwT7B|clickvillagers)/version" ))
54+ .withQueryParam ("loaders" , equalTo ("[\" purpur\" ]" ))
55+ .withQueryParam ("game_versions" , equalTo ("[\" 1.20.1\" ]" ))
56+ .willReturn (aResponse ()
57+ .withHeader ("Content-Type" , "application/json" )
58+ .withBodyFile ("modrinth/project-BITzwT7B-version-resp.json" )
59+ )
60+ );
61+
62+ try (ModrinthApiClient client = new ModrinthApiClient (wmInfo .getHttpBaseUrl (), "modrinth" , Options .builder ().build ())) {
63+ final List <Version > result = client .getVersionsForProject ("BITzwT7B" , Loader .purpur , "1.20.1" )
64+ .block ();
65+
66+ assertThat (result )
67+ .hasSize (3 )
68+ .extracting (Version ::getId )
69+ .containsExactly (
70+ "O9nndrTu" ,
71+ "DfUyEmsH" ,
72+ "oUJMLDhz"
73+ );
74+ }
75+ }
76+
77+ @ Test
78+ void fallbackToCompatibleLoader (WireMockRuntimeInfo wmInfo ) {
79+ stubFor (get (urlPathMatching ("/v2/project/entityculling/version" ))
80+ .withQueryParam ("loaders" , equalTo ("[\" neoforge\" ]" ))
81+ .withQueryParam ("game_versions" , equalTo ("[\" 1.12.2\" ]" ))
82+ .willReturn (aResponse ()
83+ .withHeader ("Content-Type" , "application/json" )
84+ .withBodyFile ("modrinth/versions-entityculling-neoforge-not-forge.json" )
85+ )
86+ );
87+ stubFor (get (urlPathMatching ("/v2/project/entityculling/version" ))
88+ .withQueryParam ("loaders" , equalTo ("[\" forge\" ]" ))
89+ .withQueryParam ("game_versions" , equalTo ("[\" 1.12.2\" ]" ))
90+ .willReturn (aResponse ()
91+ .withHeader ("Content-Type" , "application/json" )
92+ .withBodyFile ("modrinth/versions-entityculling-forge.json" )
93+ )
94+ );
6395
64- assertThat (result )
65- .hasSize (3 )
66- .extracting (Version ::getId )
67- .containsExactly (
68- "O9nndrTu" ,
69- "DfUyEmsH" ,
70- "oUJMLDhz"
71- );
96+ try (ModrinthApiClient client = new ModrinthApiClient (wmInfo .getHttpBaseUrl (), "modrinth" ,
97+ Options .builder ().build ()
98+ )) {
99+ final List <Version > result = client .getVersionsForProject (
100+ "entityculling" ,
101+ Loader .neoforge ,
102+ "1.12.2"
103+ )
104+ .block ();
105+
106+ assertThat (result )
107+ .extracting (Version ::getId )
108+ .containsExactly (
109+ "knltv3Vh"
110+ );
111+ }
72112 }
73113 }
74114
115+
116+
75117 @ Nested
76118 class resolveProjectVersion {
77119
@@ -142,7 +184,7 @@ void noFiles(WireMockRuntimeInfo wmInfo) {
142184 @ Test
143185 void noApplicableVersionsOfType (WireMockRuntimeInfo wmInfo ) {
144186 stubFor (get (urlPathMatching ("/v2/project/(3wmN97b8|multiverse-core)/version" ))
145- .withQueryParam ("loaders" , equalTo ("[\" purpur\" , \" paper \" , \" spigot \" ]" ))
187+ .withQueryParam ("loaders" , equalTo ("[\" purpur\" ]" ))
146188 .withQueryParam ("game_versions" , equalTo ("[\" 1.21.1\" ]" ))
147189 .willReturn (aResponse ()
148190 .withHeader ("Content-Type" , "application/json" )
0 commit comments