1
1
package me .itzg .helpers .modrinth ;
2
2
3
- import org .junit .jupiter .api .Test ;
4
- import org .junit .jupiter .api .io .TempDir ;
5
-
6
- import static org .assertj .core .api .Assertions .*;
7
- import static me .itzg .helpers .modrinth .ModrinthTestHelpers .*;
8
3
import static com .github .tomakehurst .wiremock .client .WireMock .*;
9
-
10
- import java .io .IOException ;
11
- import java .net .URISyntaxException ;
12
- import java .nio .file .*;
13
-
14
- import com .fasterxml .jackson .core .JsonProcessingException ;
4
+ import static me .itzg .helpers .modrinth .ModrinthTestHelpers .*;
5
+ import static org .assertj .core .api .Assertions .assertThat ;
15
6
16
7
import com .github .tomakehurst .wiremock .junit5 .WireMockRuntimeInfo ;
17
8
import com .github .tomakehurst .wiremock .junit5 .WireMockTest ;
18
-
9
+ import java .io .IOException ;
10
+ import java .net .URISyntaxException ;
11
+ import java .nio .file .Path ;
19
12
import me .itzg .helpers .files .Manifests ;
20
- import me .itzg .helpers .modrinth .model .* ;
13
+ import me .itzg .helpers .modrinth .model .ModpackIndex ;
21
14
import me .itzg .helpers .modrinth .model .ModpackIndex .ModpackFile ;
15
+ import me .itzg .helpers .modrinth .model .Version ;
16
+ import org .junit .jupiter .api .Test ;
17
+ import org .junit .jupiter .api .io .TempDir ;
22
18
23
19
@ WireMockTest
24
20
public class InstallModrinthModpackCommandTest {
25
- private String projectName = "test_project1" ;
26
- private String projectId = "efgh5678" ;
27
- private String projectVersionId = "abcd1234" ;
28
- private Version projectVersion =
21
+ private final String projectName = "test_project1" ;
22
+ private final String projectId = "efgh5678" ;
23
+ private final String projectVersionId = "abcd1234" ;
24
+ private final Version projectVersion =
29
25
createModrinthProjectVersion (projectVersionId );
30
26
31
27
static InstallModrinthModpackCommand createInstallModrinthModpackCommand (
@@ -46,7 +42,7 @@ static InstallModrinthModpackCommand createInstallModrinthModpackCommand(
46
42
@ Test
47
43
void downloadsAndInstallsModrinthModpack (
48
44
WireMockRuntimeInfo wm , @ TempDir Path tempDir
49
- ) throws JsonProcessingException , IOException , URISyntaxException
45
+ ) throws IOException , URISyntaxException
50
46
{
51
47
String expectedFileData = "some test data" ;
52
48
String relativeFilePath = "test_file" ;
@@ -71,11 +67,41 @@ void downloadsAndInstallsModrinthModpack(
71
67
.isEqualTo (expectedFileData );
72
68
}
73
69
70
+ @ Test
71
+ void downloadsAndInstallsModrinthModpack_versionNumberAndAnyLoader (
72
+ WireMockRuntimeInfo wm , @ TempDir Path tempDir
73
+ ) throws IOException , URISyntaxException
74
+ {
75
+ String expectedFileData = "some test data" ;
76
+ String relativeFilePath = "test_file" ;
77
+ ModpackFile testFile = createHostedModpackFile (
78
+ relativeFilePath , expectedFileData , wm .getHttpBaseUrl ());
79
+
80
+ ModpackIndex index = createBasicModpackIndex ();
81
+ index .getFiles ().add (testFile );
82
+
83
+ String projectVersionNumber = "1.6.1" ;
84
+ stubModrinthModpackApi (
85
+ wm , projectName , this .projectId ,
86
+ createModrinthProjectVersion (projectVersionId ).setVersionNumber (projectVersionNumber ),
87
+ createModrinthPack (index )
88
+ );
89
+
90
+ InstallModrinthModpackCommand commandUT =
91
+ createInstallModrinthModpackCommand (wm .getHttpBaseUrl (), tempDir ,
92
+ projectName , projectVersionNumber , null );
93
+
94
+ int commandStatus = commandUT .call ();
95
+
96
+ assertThat (commandStatus ).isEqualTo (0 );
97
+ assertThat (tempDir .resolve (relativeFilePath )).content ()
98
+ .isEqualTo (expectedFileData );
99
+ }
100
+
74
101
@ Test
75
102
void createsModrinthModpackManifestForModpackInstallation (
76
103
WireMockRuntimeInfo wm , @ TempDir Path tempDir
77
- ) throws JsonProcessingException , IOException , URISyntaxException
78
- {
104
+ ) throws IOException {
79
105
ModpackIndex index = createBasicModpackIndex ();
80
106
81
107
stubModrinthModpackApi (
@@ -107,7 +133,7 @@ void createsModrinthModpackManifestForModpackInstallation(
107
133
@ Test
108
134
void removesFilesNoLongerNeedeByUpdatedModpack (
109
135
WireMockRuntimeInfo wm , @ TempDir Path tempDir
110
- ) throws JsonProcessingException , IOException , URISyntaxException
136
+ ) throws IOException , URISyntaxException
111
137
{
112
138
String expectedFileData = "some test data" ;
113
139
String relativeFilePath = "test_file" ;
@@ -146,7 +172,7 @@ void removesFilesNoLongerNeedeByUpdatedModpack(
146
172
@ Test
147
173
void downloadsAndInstallsGenericModpacksOverHttp (
148
174
WireMockRuntimeInfo wm , @ TempDir Path tempDir
149
- ) throws JsonProcessingException , IOException , URISyntaxException
175
+ ) throws IOException , URISyntaxException
150
176
{
151
177
String expectedFileData = "some test data" ;
152
178
String relativeFilePath = "test_file" ;
0 commit comments