|
@@ -24,10 +24,16 @@ package com.dmdirc.ui.core.about;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.DMDircMBassador;
|
26
|
26
|
import com.dmdirc.interfaces.config.AggregateConfigProvider;
|
|
27
|
+import com.dmdirc.plugins.PluginInfo;
|
27
|
28
|
import com.dmdirc.plugins.PluginManager;
|
|
29
|
+import com.dmdirc.plugins.PluginMetaData;
|
28
|
30
|
import com.dmdirc.util.ClientInfo;
|
|
31
|
+import com.dmdirc.util.io.FileUtils;
|
|
32
|
+
|
|
33
|
+import com.google.common.collect.Lists;
|
29
|
34
|
|
30
|
35
|
import java.nio.file.Path;
|
|
36
|
+import java.util.List;
|
31
|
37
|
|
32
|
38
|
import org.junit.Before;
|
33
|
39
|
import org.junit.Test;
|
|
@@ -47,14 +53,29 @@ public class CoreAboutDialogModelTest {
|
47
|
53
|
@Mock private Path path;
|
48
|
54
|
@Mock private DMDircMBassador eventBus;
|
49
|
55
|
@Mock private PluginManager pluginManager;
|
|
56
|
+ @Mock private PluginMetaData pluginMetaData1;
|
|
57
|
+ @Mock private PluginMetaData pluginMetaData2;
|
|
58
|
+ @Mock private PluginInfo pluginInfo1;
|
|
59
|
+ @Mock private PluginInfo pluginInfo2;
|
|
60
|
+ private Path pluginPath1;
|
|
61
|
+ private Path pluginPath2;
|
50
|
62
|
private CoreAboutDialogModel instance;
|
51
|
63
|
|
52
|
64
|
@Before
|
53
|
65
|
public void setUp() throws Exception {
|
|
66
|
+ pluginPath1 = FileUtils.getPathForResource(getClass().getResource("license1"));
|
|
67
|
+ pluginPath2 = FileUtils.getPathForResource(getClass().getResource("license2"));
|
54
|
68
|
when(clientInfo.getVersionInformation()).thenReturn("DMDirc Version");
|
55
|
69
|
when(clientInfo.getOperatingSystemInformation()).thenReturn("OS Version");
|
56
|
70
|
when(clientInfo.getJavaInformation()).thenReturn("Java Version");
|
57
|
71
|
when(globalConfig.getOption("identity", "modealiasversion")).thenReturn("ModeAlias Version");
|
|
72
|
+ when(pluginManager.getPluginInfos()).thenReturn(Lists.newArrayList(pluginInfo1, pluginInfo2));
|
|
73
|
+ when(pluginInfo1.getPath("/META-INF/licenses/")).thenReturn(pluginPath1);
|
|
74
|
+ when(pluginInfo2.getPath("/META-INF/licenses/")).thenReturn(pluginPath2);
|
|
75
|
+ when(pluginInfo1.getMetaData()).thenReturn(pluginMetaData1);
|
|
76
|
+ when(pluginInfo2.getMetaData()).thenReturn(pluginMetaData2);
|
|
77
|
+ when(pluginMetaData1.getFriendlyName()).thenReturn("Plugin1");
|
|
78
|
+ when(pluginMetaData2.getFriendlyName()).thenReturn("Plugin2");
|
58
|
79
|
instance = new CoreAboutDialogModel(globalConfig, path, clientInfo, eventBus, pluginManager);
|
59
|
80
|
instance.load();
|
60
|
81
|
}
|
|
@@ -88,6 +109,25 @@ public class CoreAboutDialogModelTest {
|
88
|
109
|
|
89
|
110
|
@Test
|
90
|
111
|
public void testGetLicensedComponents() throws Exception {
|
91
|
|
- // TODO: Add a virtual file system, mock plugin manager test licences
|
|
112
|
+ final List<LicensedComponent> licensedComponents = instance.getLicensedComponents();
|
|
113
|
+ assertEquals(3, licensedComponents.size());
|
|
114
|
+ assertEquals("DMDirc", licensedComponents.get(0).getName());
|
|
115
|
+ assertEquals("Plugin1", licensedComponents.get(1).getName());
|
|
116
|
+ assertEquals("Plugin2", licensedComponents.get(2).getName());
|
|
117
|
+ assertEquals(1, licensedComponents.get(0).getLicences().size());
|
|
118
|
+ assertEquals("dmdirc", licensedComponents.get(0).getLicences().get(0).getComponent());
|
|
119
|
+ assertEquals("license4", licensedComponents.get(0).getLicences().get(0).getName());
|
|
120
|
+ assertEquals("License4-Body", licensedComponents.get(0).getLicences().get(0).getBody());
|
|
121
|
+ assertEquals(2, licensedComponents.get(1).getLicences().size());
|
|
122
|
+ assertEquals("component1", licensedComponents.get(1).getLicences().get(0).getComponent());
|
|
123
|
+ assertEquals("license1", licensedComponents.get(1).getLicences().get(0).getName());
|
|
124
|
+ assertEquals("License1-Body", licensedComponents.get(1).getLicences().get(0).getBody());
|
|
125
|
+ assertEquals("component2", licensedComponents.get(1).getLicences().get(1).getComponent());
|
|
126
|
+ assertEquals("license2", licensedComponents.get(1).getLicences().get(1).getName());
|
|
127
|
+ assertEquals("License2-Body", licensedComponents.get(1).getLicences().get(1).getBody());
|
|
128
|
+ assertEquals(1, licensedComponents.get(2).getLicences().size());
|
|
129
|
+ assertEquals("component3", licensedComponents.get(2).getLicences().get(0).getComponent());
|
|
130
|
+ assertEquals("license3", licensedComponents.get(2).getLicences().get(0).getName());
|
|
131
|
+ assertEquals("License3-Body", licensedComponents.get(2).getLicences().get(0).getBody());
|
92
|
132
|
}
|
93
|
133
|
}
|