From e103647723b3a40d9fe94d21aabb8ee7acec4593 Mon Sep 17 00:00:00 2001 From: vito Date: Wed, 15 Dec 2021 17:32:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/app/DesignerAppUtilsTest.java | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/designer-realize/src/test/java/com/fr/design/mainframe/app/DesignerAppUtilsTest.java b/designer-realize/src/test/java/com/fr/design/mainframe/app/DesignerAppUtilsTest.java index 46aa574e9..f47d18d34 100644 --- a/designer-realize/src/test/java/com/fr/design/mainframe/app/DesignerAppUtilsTest.java +++ b/designer-realize/src/test/java/com/fr/design/mainframe/app/DesignerAppUtilsTest.java @@ -3,15 +3,11 @@ package com.fr.design.mainframe.app; import com.fr.invoke.Reflect; import com.fr.plugin.context.PluginMarker; import com.fr.plugin.context.PluginMarkerAdapter; -import com.fr.plugin.engine.remote.PluginRemoteSync; import com.fr.stable.TemplateIOErrorContextHolder; import com.fr.third.guava.collect.Multimap; -import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; -import org.powermock.api.easymock.PowerMock; -import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import java.util.Collection; @@ -24,13 +20,12 @@ import java.util.HashSet; * Created by vito on 2021/5/31 */ @RunWith(PowerMockRunner.class) -@PrepareForTest({PluginRemoteSync.class}) public class DesignerAppUtilsTest { @Test public void testDealWithErrorDetailMultiLineAndCache() { TemplateIOErrorContextHolder.registerPluginNameMap(new HashMap() {{ put("2", "好用的插件"); - }},new HashSet<>()); + }}, new HashSet<>()); TemplateIOErrorContextHolder.addNeedEnablePlugin(PluginMarkerAdapter.create("1", "1.0", "1插件")); TemplateIOErrorContextHolder.addNeedInstallPlugin(PluginMarker.create("2", "1.0")); TemplateIOErrorContextHolder.addNeedInstallPlugin(PluginMarker.create("3", "1.0")); @@ -47,7 +42,7 @@ public class DesignerAppUtilsTest { public void testInvalidatePlugins() { TemplateIOErrorContextHolder.registerPluginNameMap(new HashMap() {{ put("2", "好用的插件"); - }},new HashSet<>()); + }}, new HashSet<>()); TemplateIOErrorContextHolder.addNeedEnablePlugin(PluginMarkerAdapter.create("1", "1.0", "1插件")); TemplateIOErrorContextHolder.addNeedInstallPlugin(PluginMarker.create("2", "1.0")); TemplateIOErrorContextHolder.addNeedInstallPlugin(PluginMarker.create("3", "1.0")); @@ -60,19 +55,19 @@ public class DesignerAppUtilsTest { } @Test - public void testRearrange(){ + public void testRearrange() { // 远程插件模拟注册 - PluginRemoteSync pluginRemoteSync = EasyMock.createMock(PluginRemoteSync.class); - EasyMock.expect(pluginRemoteSync.getPluginRemoteStatusByIdIndex()).andReturn(new HashMap(){{ - put("com.fr.plugin1", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin1","1",true).get()); - put("com.fr.plugin2", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin2","1",true).get()); - put("com.fr.plugin3", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin3","1",false).get()); - put("com.fr.plugin4", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin4","1",false).get()); - }}).anyTimes(); - EasyMock.replay(pluginRemoteSync); - PowerMock.mockStaticPartial(PluginRemoteSync.class, "getInstance"); - EasyMock.expect(PluginRemoteSync.getInstance()).andReturn(pluginRemoteSync).anyTimes(); - PowerMock.replay(PluginRemoteSync.class); +// PluginRemoteSync pluginRemoteSync = EasyMock.createMock(PluginRemoteSync.class); +// EasyMock.expect(pluginRemoteSync.getPluginRemoteStatusByIdIndex()).andReturn(new HashMap(){{ +// put("com.fr.plugin1", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin1","1",true).get()); +// put("com.fr.plugin2", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin2","1",true).get()); +// put("com.fr.plugin3", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin3","1",false).get()); +// put("com.fr.plugin4", Reflect.on(PluginRemoteSync.PluginStatus.class).call("create","com.fr.plugin4","1",false).get()); +// }}).anyTimes(); +// EasyMock.replay(pluginRemoteSync); +// PowerMock.mockStaticPartial(PluginRemoteSync.class, "getInstance"); +// EasyMock.expect(PluginRemoteSync.getInstance()).andReturn(pluginRemoteSync).anyTimes(); +// PowerMock.replay(PluginRemoteSync.class); // 本地插件模拟检查 TemplateIOErrorContextHolder.registerPluginNameMap(new HashMap() {{ @@ -81,7 +76,7 @@ public class DesignerAppUtilsTest { put("com.fr.plugin3", "好用的插件3"); put("com.fr.plugin4", "好用的插件4"); put("com.fr.plugin5", "好用的插件5"); - }},new HashSet<>()); + }}, new HashSet<>()); // unknown TemplateIOErrorContextHolder.addNeedInstallPlugin(PluginMarker.create("com.fr.plugin7", "1")); // disable @@ -93,14 +88,14 @@ public class DesignerAppUtilsTest { Multimap pendingPlugins = TemplateIOErrorContextHolder.getPendingPlugin(); - Reflect.on(DesignerAppUtils.class).call("rearrange",pendingPlugins).get(); - Assert.assertEquals(1,pendingPlugins.get(TemplateIOErrorContextHolder.UNKNOWN_PLUGIN).size()); + Reflect.on(DesignerAppUtils.class).call("rearrange", pendingPlugins).get(); + Assert.assertEquals(1, pendingPlugins.get(TemplateIOErrorContextHolder.UNKNOWN_PLUGIN).size()); Collection pluginMarkerAdapters = pendingPlugins.get(TemplateIOErrorContextHolder.DISABLE_PLUGIN); Assert.assertEquals(2, pluginMarkerAdapters.size()); pluginMarkerAdapters.contains(PluginMarker.create("com.fr.plugin3", "1")); pluginMarkerAdapters.contains(PluginMarker.create("com.fr.plugin4", "1")); Collection pluginMarkerAdapters1 = pendingPlugins.get(TemplateIOErrorContextHolder.NOT_INSTALLED_PLUGIN); Assert.assertEquals(1, pluginMarkerAdapters1.size()); - pluginMarkerAdapters1.contains(PluginMarker.create("com.fr.plugin5","1")); + pluginMarkerAdapters1.contains(PluginMarker.create("com.fr.plugin5", "1")); } } \ No newline at end of file