Skip to content

Commit f4cc2c5

Browse files
committed
started wiith test cases
1 parent 316b6e0 commit f4cc2c5

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed
Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,60 @@
11
package org.hydev.mcpm.client.database;
22

3-
public class TestLocalPluginTracker {
3+
import com.opencsv.CSVReader;
4+
import com.opencsv.CSVWriter;
5+
import com.opencsv.exceptions.CsvException;
6+
7+
import com.fasterxml.jackson.core.JsonParseException;
8+
import com.fasterxml.jackson.databind.JsonMappingException;
9+
import com.fasterxml.jackson.databind.ObjectMapper;
10+
11+
import org.apache.commons.lang3.tuple.Pair;
12+
import org.hydev.mcpm.client.database.boundary.SearchPackagesBoundary;
13+
import org.hydev.mcpm.client.database.inputs.SearchPackagesInput;
14+
import org.hydev.mcpm.client.database.inputs.SearchPackagesType;
15+
import org.hydev.mcpm.client.database.results.SearchPackagesResult;
16+
import org.hydev.mcpm.client.models.PluginModel;
17+
import org.hydev.mcpm.client.models.PluginVersion;
18+
import org.hydev.mcpm.client.models.PluginYml;
19+
import org.hydev.mcpm.utils.PluginJarFile;
20+
21+
import org.junit.Assert;
22+
import org.junit.Before;
23+
import org.junit.Test;
24+
25+
import java.io.*;
26+
import java.nio.file.Paths;
27+
import java.util.*;
28+
import java.util.stream.Collectors;
29+
30+
public class ListAllTestCases {
31+
final String pluginDirectory = "plugins";
32+
33+
private ArrayList<PluginYml> listAllPluginsHelper() {
34+
ArrayList<PluginYml> plugins = new ArrayList<>();
35+
36+
try (PluginJarFile InstancePluginJarFile = new PluginJarFile(new File(pluginDirectory))) {
37+
for (File file : Objects.requireNonNull(new File(pluginDirectory).listFiles())) {
38+
if (file.getName().endsWith(".jar")) {
39+
PluginYml pluginYml = InstancePluginJarFile.readPluginYaml();
40+
if (pluginYml != null) {
41+
plugins.add(pluginYml);
42+
}
43+
}
44+
}
45+
} catch (Exception e) {
46+
System.out.println("Error reading plugin.yml from " + pluginDirectory);
47+
}
48+
return plugins;
49+
50+
}
51+
452
@Test
5-
public void testReadMetadata() {
53+
public void testListAll() {
654
LocalPluginTracker localPluginTracker = new LocalPluginTracker();
7-
localPluginTracker.readMeta();
55+
var installed = localPluginTracker.listInstalled();
856

57+
var allInstalled = listAllPluginsHelper();
58+
assertEquals(installed, allInstalled);
959
}
1060
}

0 commit comments

Comments
 (0)