1
+ package me .itzg .helpers .modrinth ;
2
+
3
+ import static org .assertj .core .api .Assertions .assertThat ;
4
+
5
+ import java .util .Collections ;
6
+ import java .util .HashMap ;
7
+ import java .util .Map ;
8
+ import me .itzg .helpers .curseforge .ExcludeIncludesContent .ExcludeIncludes ;
9
+ import me .itzg .helpers .modrinth .model .Env ;
10
+ import me .itzg .helpers .modrinth .model .EnvType ;
11
+ import me .itzg .helpers .modrinth .model .ModpackIndex .ModpackFile ;
12
+ import org .junit .jupiter .api .Test ;
13
+
14
+ class FileInclusionCalculatorTest {
15
+
16
+ @ Test
17
+ void forceIncludeWhenExcludedServerFile () {
18
+ final ExcludeIncludesContent globalContent = new ExcludeIncludesContent ();
19
+ globalContent .setGlobalExcludes (Collections .singleton ("cloth-config" ));
20
+
21
+ final FileInclusionCalculator calculator = new FileInclusionCalculator ("modpack" ,
22
+ null ,
23
+ Collections .singletonList ("cloth" ),
24
+ globalContent
25
+ );
26
+
27
+ final ModpackFile modFile = new ModpackFile ()
28
+ .setEnv (forServerAndClient ())
29
+ .setPath ("mods/cloth-config-15.0.140-fabric.jar" );
30
+
31
+ final boolean result = calculator .includeModFile (modFile );
32
+ assertThat (result ).isTrue ();
33
+ }
34
+
35
+ @ Test
36
+ void excludeForModpack () {
37
+ final ExcludeIncludesContent globalContent = new ExcludeIncludesContent ();
38
+ globalContent .setGlobalExcludes (Collections .singleton ("other" ));
39
+ final Map <String , ExcludeIncludes > modpacksGlobal = new HashMap <>();
40
+ modpacksGlobal .put ("modpackWithExcludes" , new ExcludeIncludes ().setExcludes (Collections .singleton ("cloth-config" )));
41
+ globalContent .setModpacks (modpacksGlobal );
42
+
43
+ final ModpackFile modFile = new ModpackFile ()
44
+ .setEnv (forServerAndClient ())
45
+ .setPath ("mods/cloth-config-15.0.140-fabric.jar" );
46
+
47
+ {
48
+ final FileInclusionCalculator calculator = new FileInclusionCalculator ("modpack" ,
49
+ null ,
50
+ null ,
51
+ globalContent
52
+ );
53
+
54
+ assertThat (calculator .includeModFile (modFile )).isTrue ();
55
+ }
56
+ {
57
+ final FileInclusionCalculator calculator = new FileInclusionCalculator ("modpackWithExcludes" ,
58
+ null ,
59
+ null ,
60
+ globalContent
61
+ );
62
+
63
+ assertThat (calculator .includeModFile (modFile )).isFalse ();
64
+ }
65
+ }
66
+
67
+ private Map <Env , EnvType > forServerAndClient () {
68
+ final Map <Env , EnvType > modEnvs = new HashMap <>();
69
+ modEnvs .put (Env .client , EnvType .required );
70
+ modEnvs .put (Env .server , EnvType .required );
71
+ return modEnvs ;
72
+ }
73
+ }
0 commit comments