|
1 | 1 | package org.hydev.mcpm.client.database;
|
2 | 2 |
|
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 | + |
4 | 52 | @Test
|
5 |
| - public void testReadMetadata() { |
| 53 | + public void testListAll() { |
6 | 54 | LocalPluginTracker localPluginTracker = new LocalPluginTracker();
|
7 |
| - localPluginTracker.readMeta(); |
| 55 | + var installed = localPluginTracker.listInstalled(); |
8 | 56 |
|
| 57 | + var allInstalled = listAllPluginsHelper(); |
| 58 | + assertEquals(installed, allInstalled); |
9 | 59 | }
|
10 | 60 | }
|
0 commit comments