forked from fanruan/design
Browse Source
Merge in DESIGN/design from ~LUCIAN.CHEN/design:feature/10.0 to feature/10.0 * commit '41ec46537ce98f80f38f5103cb63004532306eb6': 无jira任务,单元测试误屏蔽 REPORT-46971 设计面板-普通报表&决策报表-参数面板-插件类控件右侧第四个tab页悬浮时和设置页面上方均显示“组件设置”,应“控件设置” REPORT-46892 切换目录有插件版本不匹配目录配置页面显示问题 REPORT-46584 【10.0.13冒烟】设计器卡死 REPORT-46892 【冒烟】切换到本地目录有插件版本不匹配时,远程配置页面会消失的比较慢 REPORT-46585 fix 单个插件监听逻辑保持与之前一致 REPORT-46585 切换工作目录时 先移除后添加插件监听 REPORT-46285 jdk11-背景图标,有一点异常的红色显示 【问题原因】这个问题是由jdk差异造成的,前景色和背景色图标都是由上面的图标+下面的取色矩形组成,下面的取色矩形的位置由整个图标的宽高决定,而在jdk11下,拿到的宽高与jdk8一样,但是最终绘制出来的取色矩形会往左边偏移一点,大概是1px,而背景色图标之前下面的取色矩形初始为红色,在偏移了之后,绘制底下取色矩形不能完全覆盖初始红色,所以漏了一点出来,表现为异常的红色。 【改动思路】与产品确认后,决定先把背景色图标取色矩形设置为透明色,这样就不会漏出一点红色,而取色矩形绘制有点偏移的问题需要去改一下UIColorButton的UI,这个在换完相关图标后再统一修改比较好 REPORT-45689 加上判空 CHART-17822 设计器界面内的图形不小心切换到其他图形且不保存,点击撤销键没法返回到切换前的图形 REPORT-46574 & REPORT-46813 & REPORT-46550 无jira任务,新增的方法代码合并重复feature/10.0
ju|剧浩宇
4 years ago
14 changed files with 471 additions and 365 deletions
Before Width: | Height: | Size: 938 B After Width: | Height: | Size: 850 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 2.7 KiB |
@ -1,143 +1,140 @@
|
||||
//package com.fr.design;
|
||||
//
|
||||
////import com.fr.decision.webservice.v10.plugin.helper.PluginErrorRemindHandler;
|
||||
//import com.fr.design.env.DesignerWorkspaceInfo;
|
||||
//import com.fr.design.env.DesignerWorkspaceType;
|
||||
//import com.fr.design.env.LocalDesignerWorkspaceInfo;
|
||||
//import com.fr.design.env.RemoteDesignerWorkspaceInfo;
|
||||
//import com.fr.env.CheckServiceDialog;
|
||||
//import com.fr.env.PluginErrorRemindDialog;
|
||||
//import com.fr.invoke.Reflect;
|
||||
//import com.fr.workspace.connect.WorkspaceConnectionInfo;
|
||||
//import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
|
||||
//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.awt.Frame;
|
||||
//
|
||||
///**
|
||||
// * @author: Maksim
|
||||
// * @Date: Created in 2020/3/5
|
||||
// * @Description:
|
||||
// */
|
||||
//@RunWith(PowerMockRunner.class)
|
||||
//@PrepareForTest({FunctionalHttpRequest.class,
|
||||
// EnvChangeEntrance.class,
|
||||
// CheckServiceDialog.class,
|
||||
// DesignerEnvManager.class,
|
||||
// PluginErrorRemindHandler.class})
|
||||
//public class EnvChangeEntranceTest {
|
||||
//
|
||||
// @Test
|
||||
// public void showServiceDialog() throws Exception {
|
||||
// try {
|
||||
// EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
|
||||
// DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class);
|
||||
// WorkspaceConnectionInfo connectionInfo = EasyMock.mock(WorkspaceConnectionInfo.class);
|
||||
//
|
||||
// String remoteBranch = "Build#persist-2020.02.15.01.01.12.12";
|
||||
// EasyMock.expect(selectedEnv.getConnection()).andReturn(connectionInfo);
|
||||
// EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote);
|
||||
// EasyMock.expect(selectedEnv.getRemindTime()).andReturn(null);
|
||||
//
|
||||
// FunctionalHttpRequest request = EasyMock.mock(FunctionalHttpRequest.class);
|
||||
// EasyMock.expect(request.getServiceList()).andReturn(null);
|
||||
//
|
||||
// PowerMock.expectNew(FunctionalHttpRequest.class, connectionInfo).andReturn(request).anyTimes();
|
||||
// EasyMock.expect(request.getServerBranch()).andReturn(remoteBranch);
|
||||
//
|
||||
// CheckServiceDialog dialog = EasyMock.mock(CheckServiceDialog.class);
|
||||
// PowerMock.expectNew(CheckServiceDialog.class, EasyMock.anyObject(Frame.class), EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyString()).andReturn(dialog);
|
||||
//
|
||||
// EasyMock.replay(request, selectedEnv, connectionInfo);
|
||||
// PowerMock.replayAll();
|
||||
//
|
||||
// entrance.showServiceDialog(selectedEnv);
|
||||
//
|
||||
// }catch (Exception e){
|
||||
// Assert.fail();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testUpdateNotRememberPwdEnv() {
|
||||
//
|
||||
// DesignerEnvManager manager = new DesignerEnvManager();
|
||||
//
|
||||
// PowerMock.mockStatic(DesignerEnvManager.class);
|
||||
// EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(manager).anyTimes();
|
||||
//
|
||||
// PowerMock.replayAll();
|
||||
//
|
||||
// EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
|
||||
//
|
||||
// manager.putEnv("test1", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)));
|
||||
// manager.putEnv("test2", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", false)));
|
||||
// manager.putEnv("test3", LocalDesignerWorkspaceInfo.create("name", "path"));
|
||||
//
|
||||
// Reflect.on(entrance).call("updateNotRememberPwdEnv");
|
||||
//
|
||||
// Assert.assertEquals(manager.getWorkspaceInfo("test1").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)).getConnection());
|
||||
// Assert.assertEquals(manager.getWorkspaceInfo("test2").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "", "", "", false)).getConnection());
|
||||
// Assert.assertEquals(manager.getWorkspaceInfo("test3").getName(), "name");
|
||||
// Assert.assertEquals(manager.getWorkspaceInfo("test3").getPath(), "path");
|
||||
//
|
||||
// PowerMock.verifyAll();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testIsNotRememberPwd() {
|
||||
// EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
|
||||
//
|
||||
// DesignerWorkspaceInfo info1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true));
|
||||
// DesignerWorkspaceInfo info2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "111", "", "", false));
|
||||
// DesignerWorkspaceInfo info3 = LocalDesignerWorkspaceInfo.create("name", "path");
|
||||
// DesignerWorkspaceInfo info4 = null;
|
||||
//
|
||||
// Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info1).get());
|
||||
// Assert.assertTrue(Reflect.on(entrance).call("isNotRememberPwd", info2).get());
|
||||
// Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info3).get());
|
||||
// Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info4).get());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testPluginErrorRemind() throws Exception {
|
||||
//
|
||||
// try {
|
||||
// DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class);
|
||||
// EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote).once();
|
||||
// EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Local).times(2);
|
||||
//
|
||||
// PowerMock.mockStatic(PluginErrorRemindHandler.class);
|
||||
// EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("").once();
|
||||
// EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("111").once();
|
||||
//
|
||||
// PluginErrorRemindDialog dialog = EasyMock.mock(PluginErrorRemindDialog.class);
|
||||
// PowerMock.expectNew(PluginErrorRemindDialog.class, EasyMock.anyObject(Frame.class), EasyMock.anyString()).andReturn(dialog).once();
|
||||
//
|
||||
// dialog.setVisible(true);
|
||||
// EasyMock.expectLastCall();
|
||||
//
|
||||
// EasyMock.replay(selectedEnv, dialog);
|
||||
// PowerMock.replayAll();
|
||||
//
|
||||
// EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
|
||||
//
|
||||
// entrance.pluginErrorRemind(selectedEnv);
|
||||
// entrance.pluginErrorRemind(selectedEnv);
|
||||
// entrance.pluginErrorRemind(selectedEnv);
|
||||
//
|
||||
//
|
||||
// EasyMock.verify(selectedEnv, dialog);
|
||||
// PowerMock.verifyAll();
|
||||
// } catch (Exception e) {
|
||||
// Assert.fail();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
package com.fr.design; |
||||
|
||||
import com.fr.decision.webservice.v10.plugin.helper.PluginErrorRemindHandler; |
||||
import com.fr.design.env.DesignerWorkspaceInfo; |
||||
import com.fr.design.env.DesignerWorkspaceType; |
||||
import com.fr.design.env.LocalDesignerWorkspaceInfo; |
||||
import com.fr.design.env.RemoteDesignerWorkspaceInfo; |
||||
import com.fr.env.CheckServiceDialog; |
||||
import com.fr.env.PluginErrorRemindDialog; |
||||
import com.fr.invoke.Reflect; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.Workspace; |
||||
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
||||
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; |
||||
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.awt.Frame; |
||||
|
||||
/** |
||||
* @author: Maksim |
||||
* @Date: Created in 2020/3/5 |
||||
* @Description: |
||||
*/ |
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest({FunctionalHttpRequest.class, |
||||
EnvChangeEntrance.class, |
||||
CheckServiceDialog.class, |
||||
DesignerEnvManager.class, |
||||
PluginErrorRemindHandler.class, |
||||
WorkContext.class}) |
||||
public class EnvChangeEntranceTest { |
||||
|
||||
@Test |
||||
public void showServiceDialog() throws Exception { |
||||
try { |
||||
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); |
||||
DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class); |
||||
WorkspaceConnectionInfo connectionInfo = EasyMock.mock(WorkspaceConnectionInfo.class); |
||||
|
||||
String remoteBranch = "Build#persist-2020.02.15.01.01.12.12"; |
||||
EasyMock.expect(selectedEnv.getConnection()).andReturn(connectionInfo); |
||||
EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote); |
||||
EasyMock.expect(selectedEnv.getRemindTime()).andReturn(null); |
||||
|
||||
FunctionalHttpRequest request = EasyMock.mock(FunctionalHttpRequest.class); |
||||
EasyMock.expect(request.getServiceList()).andReturn(null); |
||||
|
||||
PowerMock.expectNew(FunctionalHttpRequest.class, connectionInfo).andReturn(request).anyTimes(); |
||||
EasyMock.expect(request.getServerBranch()).andReturn(remoteBranch); |
||||
|
||||
CheckServiceDialog dialog = EasyMock.mock(CheckServiceDialog.class); |
||||
PowerMock.expectNew(CheckServiceDialog.class, EasyMock.anyObject(Frame.class), EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyString()).andReturn(dialog); |
||||
|
||||
EasyMock.replay(request, selectedEnv, connectionInfo); |
||||
PowerMock.replayAll(); |
||||
|
||||
entrance.showServiceDialog(selectedEnv); |
||||
|
||||
}catch (Exception e){ |
||||
Assert.fail(); |
||||
} |
||||
} |
||||
|
||||
@Test |
||||
public void testUpdateNotRememberPwdEnv() { |
||||
|
||||
DesignerEnvManager manager = new DesignerEnvManager(); |
||||
|
||||
PowerMock.mockStatic(DesignerEnvManager.class); |
||||
EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(manager).anyTimes(); |
||||
|
||||
PowerMock.replayAll(); |
||||
|
||||
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); |
||||
|
||||
manager.putEnv("test1", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true))); |
||||
manager.putEnv("test2", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", false))); |
||||
manager.putEnv("test3", LocalDesignerWorkspaceInfo.create("name", "path")); |
||||
|
||||
Reflect.on(entrance).call("updateNotRememberPwdEnv"); |
||||
|
||||
Assert.assertEquals(manager.getWorkspaceInfo("test1").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)).getConnection()); |
||||
Assert.assertEquals(manager.getWorkspaceInfo("test2").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "", "", "", false)).getConnection()); |
||||
Assert.assertEquals(manager.getWorkspaceInfo("test3").getName(), "name"); |
||||
Assert.assertEquals(manager.getWorkspaceInfo("test3").getPath(), "path"); |
||||
|
||||
PowerMock.verifyAll(); |
||||
|
||||
} |
||||
|
||||
@Test |
||||
public void testIsNotRememberPwd() { |
||||
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); |
||||
|
||||
DesignerWorkspaceInfo info1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)); |
||||
DesignerWorkspaceInfo info2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "111", "", "", false)); |
||||
DesignerWorkspaceInfo info3 = LocalDesignerWorkspaceInfo.create("name", "path"); |
||||
DesignerWorkspaceInfo info4 = null; |
||||
|
||||
Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info1).get()); |
||||
Assert.assertTrue(Reflect.on(entrance).call("isNotRememberPwd", info2).get()); |
||||
Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info3).get()); |
||||
Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info4).get()); |
||||
} |
||||
|
||||
@Test |
||||
public void testPluginErrorRemind() { |
||||
|
||||
try { |
||||
|
||||
Workspace workspace = EasyMock.mock(Workspace.class); |
||||
EasyMock.expect(workspace.isLocal()).andReturn(false).once(); |
||||
EasyMock.expect(workspace.isLocal()).andReturn(true).once(); |
||||
PowerMock.mockStatic(WorkContext.class); |
||||
EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes(); |
||||
|
||||
PowerMock.mockStatic(PluginErrorRemindHandler.class); |
||||
EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("").once(); |
||||
|
||||
EasyMock.replay(workspace); |
||||
PowerMock.replayAll(); |
||||
|
||||
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); |
||||
|
||||
entrance.pluginErrorRemind(); |
||||
entrance.pluginErrorRemind(); |
||||
|
||||
EasyMock.verify(workspace); |
||||
PowerMock.verifyAll(); |
||||
} catch (Exception e) { |
||||
Assert.fail(); |
||||
} |
||||
} |
||||
} |
@ -1,155 +1,155 @@
|
||||
//package com.fr.design.extra;
|
||||
//
|
||||
//import com.fr.invoke.Reflect;
|
||||
//import com.fr.json.JSONObject;
|
||||
//import com.fr.plugin.context.PluginContext;
|
||||
//import com.fr.plugin.context.PluginMarker;
|
||||
//import com.fr.plugin.context.PluginMarkerAdapter;
|
||||
//import com.fr.plugin.error.PluginErrorCode;
|
||||
//import com.fr.plugin.manage.PluginManager;
|
||||
//import com.fr.plugin.manage.control.PluginTask;
|
||||
//import com.fr.plugin.manage.control.PluginTaskResult;
|
||||
//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.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * @author Lucian.Chen
|
||||
// * @version 10.0
|
||||
// * Created by Lucian.Chen on 2020/12/17
|
||||
// */
|
||||
//@RunWith(PowerMockRunner.class)
|
||||
//@PrepareForTest({PluginManager.class, PluginUtils.class})
|
||||
//public class PluginOperateUtilsTest {
|
||||
//
|
||||
// @Test
|
||||
// public void testGetSuccessInfo() {
|
||||
// PluginTaskResult pluginTaskResult = EasyMock.mock(PluginTaskResult.class);
|
||||
// PluginTaskResult pluginTaskResult1 = EasyMock.mock(PluginTaskResult.class);
|
||||
// PluginTaskResult pluginTaskResult2 = EasyMock.mock(PluginTaskResult.class);
|
||||
//
|
||||
// List<PluginTaskResult> pluginTaskResults1 = new ArrayList<>();
|
||||
// pluginTaskResults1.add(pluginTaskResult1);
|
||||
// List<PluginTaskResult> pluginTaskResults2 = new ArrayList<>();
|
||||
// pluginTaskResults2.add(pluginTaskResult1);
|
||||
// pluginTaskResults2.add(pluginTaskResult2);
|
||||
//
|
||||
// PluginMarker pluginMarker1 = PluginMarker.create("plugin-1", "1.0");
|
||||
// PluginMarker pluginMarker2 = PluginMarkerAdapter.create("plugin-2", "2.0", "name-2");
|
||||
// PluginTask pluginTask1 = PluginTask.installTask(pluginMarker1);
|
||||
// PluginTask pluginTask2 = PluginTask.installTask(pluginMarker2);
|
||||
//
|
||||
// EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults1).times(2);
|
||||
// EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults2).times(2);
|
||||
// EasyMock.expect(pluginTaskResult1.getCurrentTask()).andReturn(pluginTask1).anyTimes();
|
||||
// EasyMock.expect(pluginTaskResult2.getCurrentTask()).andReturn(pluginTask2).anyTimes();
|
||||
//
|
||||
// EasyMock.expect(pluginTaskResult1.errorCode()).andReturn(PluginErrorCode.BelowSystem).anyTimes();
|
||||
// EasyMock.expect(pluginTaskResult2.errorCode()).andReturn(PluginErrorCode.BeyondSystem).anyTimes();
|
||||
//
|
||||
// PluginContext plugin1 = EasyMock.mock(PluginContext.class);
|
||||
// PluginContext plugin2 = EasyMock.mock(PluginContext.class);
|
||||
// EasyMock.expect(plugin1.getName()).andReturn("context-1").anyTimes();
|
||||
// EasyMock.expect(plugin2.getName()).andReturn("context-2").anyTimes();
|
||||
// PowerMock.mockStatic(PluginManager.class);
|
||||
// EasyMock.expect(PluginManager.getContext(pluginMarker1.getPluginID()))
|
||||
// .andReturn(plugin1).once().andReturn(null).once().andReturn(plugin1).once().andReturn(null).once();
|
||||
// EasyMock.expect(PluginManager.getContext(pluginMarker2.getPluginID()))
|
||||
// .andReturn(plugin2).once().andReturn(null).once();
|
||||
//
|
||||
// EasyMock.replay(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2);
|
||||
// PowerMock.replayAll();
|
||||
//
|
||||
// // 1个
|
||||
// Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem");
|
||||
// Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem");
|
||||
//
|
||||
//
|
||||
// // 2个
|
||||
// Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem\ncontext-2Fine-Core_Plugin_Error_BeyondSystem");
|
||||
// Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem\nname-2Fine-Core_Plugin_Error_BeyondSystem");
|
||||
//
|
||||
// EasyMock.verify(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2);
|
||||
// PowerMock.verifyAll();
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void testGetPluginName() {
|
||||
// PluginContext pluginContext = EasyMock.mock(PluginContext.class);
|
||||
// EasyMock.expect(pluginContext.getName()).andReturn("pluginContext").once();
|
||||
//
|
||||
// PluginMarker pluginMarker1 = PluginMarker.create("id-1", "1");
|
||||
// PluginMarker pluginMarker2 = PluginMarkerAdapter.create("id-2", "2", "name-2");
|
||||
//
|
||||
// EasyMock.replay(pluginContext);
|
||||
//
|
||||
// Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, null).get(), "");
|
||||
// Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", pluginContext, pluginMarker1).get(), "pluginContext");
|
||||
// Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker1).get(), "id-1");
|
||||
// Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker2).get(), "name-2");
|
||||
//
|
||||
// EasyMock.verify(pluginContext);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testUpdateMarker2Online() {
|
||||
//
|
||||
// try {
|
||||
// PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0");
|
||||
// String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}";
|
||||
// JSONObject object = new JSONObject(pluginJson);
|
||||
//
|
||||
// PowerMock.mockStatic(PluginUtils.class);
|
||||
// EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once();
|
||||
// EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andThrow(new NullPointerException()).once();
|
||||
//
|
||||
// PowerMock.replayAll();
|
||||
//
|
||||
// PluginMarker marker1 = PluginOperateUtils.updateMarker2Online(pluginMarker);
|
||||
// PluginMarker marker2 = PluginOperateUtils.updateMarker2Online(pluginMarker);
|
||||
//
|
||||
// Assert.assertTrue(marker1 instanceof PluginMarkerAdapter);
|
||||
// Assert.assertEquals(marker1.getPluginID(), "plugin-1");
|
||||
// Assert.assertEquals(marker1.getVersion(), "1.0");
|
||||
// Assert.assertEquals(((PluginMarkerAdapter) marker1).getPluginName(), "图表(新特性)");
|
||||
// Assert.assertEquals(marker2, pluginMarker);
|
||||
//
|
||||
// PowerMock.verifyAll();
|
||||
// } catch (Exception e) {
|
||||
// Assert.fail();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void testUpdatePluginOnline() {
|
||||
// try {
|
||||
// PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0");
|
||||
// String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}";
|
||||
// JSONObject object = new JSONObject(pluginJson);
|
||||
//
|
||||
// PowerMock.mockStatic(PluginUtils.class);
|
||||
// EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once();
|
||||
// EasyMock.expect(PluginUtils.getInstalledPluginMarkerByID("plugin-1")).andReturn(pluginMarker).once();
|
||||
//
|
||||
// PowerMock.replayAll();
|
||||
//
|
||||
// PluginOperateUtils.updatePluginOnline(pluginMarker, null);
|
||||
//
|
||||
// PowerMock.verifyAll();
|
||||
// } catch (Exception e) {
|
||||
// Assert.fail();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
package com.fr.design.extra; |
||||
|
||||
import com.fr.invoke.Reflect; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.context.PluginMarker; |
||||
import com.fr.plugin.context.PluginMarkerAdapter; |
||||
import com.fr.plugin.error.PluginErrorCode; |
||||
import com.fr.plugin.manage.PluginManager; |
||||
import com.fr.plugin.manage.control.PluginTask; |
||||
import com.fr.plugin.manage.control.PluginTaskResult; |
||||
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.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Lucian.Chen |
||||
* @version 10.0 |
||||
* Created by Lucian.Chen on 2020/12/17 |
||||
*/ |
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest({PluginManager.class, PluginUtils.class}) |
||||
public class PluginOperateUtilsTest { |
||||
|
||||
@Test |
||||
public void testGetSuccessInfo() { |
||||
PluginTaskResult pluginTaskResult = EasyMock.mock(PluginTaskResult.class); |
||||
PluginTaskResult pluginTaskResult1 = EasyMock.mock(PluginTaskResult.class); |
||||
PluginTaskResult pluginTaskResult2 = EasyMock.mock(PluginTaskResult.class); |
||||
|
||||
List<PluginTaskResult> pluginTaskResults1 = new ArrayList<>(); |
||||
pluginTaskResults1.add(pluginTaskResult1); |
||||
List<PluginTaskResult> pluginTaskResults2 = new ArrayList<>(); |
||||
pluginTaskResults2.add(pluginTaskResult1); |
||||
pluginTaskResults2.add(pluginTaskResult2); |
||||
|
||||
PluginMarker pluginMarker1 = PluginMarker.create("plugin-1", "1.0"); |
||||
PluginMarker pluginMarker2 = PluginMarkerAdapter.create("plugin-2", "2.0", "name-2"); |
||||
PluginTask pluginTask1 = PluginTask.installTask(pluginMarker1); |
||||
PluginTask pluginTask2 = PluginTask.installTask(pluginMarker2); |
||||
|
||||
EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults1).times(2); |
||||
EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults2).times(2); |
||||
EasyMock.expect(pluginTaskResult1.getCurrentTask()).andReturn(pluginTask1).anyTimes(); |
||||
EasyMock.expect(pluginTaskResult2.getCurrentTask()).andReturn(pluginTask2).anyTimes(); |
||||
|
||||
EasyMock.expect(pluginTaskResult1.errorCode()).andReturn(PluginErrorCode.BelowSystem).anyTimes(); |
||||
EasyMock.expect(pluginTaskResult2.errorCode()).andReturn(PluginErrorCode.BeyondSystem).anyTimes(); |
||||
|
||||
PluginContext plugin1 = EasyMock.mock(PluginContext.class); |
||||
PluginContext plugin2 = EasyMock.mock(PluginContext.class); |
||||
EasyMock.expect(plugin1.getName()).andReturn("context-1").anyTimes(); |
||||
EasyMock.expect(plugin2.getName()).andReturn("context-2").anyTimes(); |
||||
PowerMock.mockStatic(PluginManager.class); |
||||
EasyMock.expect(PluginManager.getContext(pluginMarker1.getPluginID())) |
||||
.andReturn(plugin1).once().andReturn(null).once().andReturn(plugin1).once().andReturn(null).once(); |
||||
EasyMock.expect(PluginManager.getContext(pluginMarker2.getPluginID())) |
||||
.andReturn(plugin2).once().andReturn(null).once(); |
||||
|
||||
EasyMock.replay(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2); |
||||
PowerMock.replayAll(); |
||||
|
||||
// 1个
|
||||
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem"); |
||||
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem"); |
||||
|
||||
|
||||
// 2个
|
||||
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem\ncontext-2Fine-Core_Plugin_Error_BeyondSystem"); |
||||
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem\nname-2Fine-Core_Plugin_Error_BeyondSystem"); |
||||
|
||||
EasyMock.verify(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2); |
||||
PowerMock.verifyAll(); |
||||
|
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void testGetPluginName() { |
||||
PluginContext pluginContext = EasyMock.mock(PluginContext.class); |
||||
EasyMock.expect(pluginContext.getName()).andReturn("pluginContext").once(); |
||||
|
||||
PluginMarker pluginMarker1 = PluginMarker.create("id-1", "1"); |
||||
PluginMarker pluginMarker2 = PluginMarkerAdapter.create("id-2", "2", "name-2"); |
||||
|
||||
EasyMock.replay(pluginContext); |
||||
|
||||
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, null).get(), ""); |
||||
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", pluginContext, pluginMarker1).get(), "pluginContext"); |
||||
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker1).get(), "id-1"); |
||||
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker2).get(), "name-2"); |
||||
|
||||
EasyMock.verify(pluginContext); |
||||
} |
||||
|
||||
@Test |
||||
public void testUpdateMarker2Online() { |
||||
|
||||
try { |
||||
PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0"); |
||||
String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}"; |
||||
JSONObject object = new JSONObject(pluginJson); |
||||
|
||||
PowerMock.mockStatic(PluginUtils.class); |
||||
EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once(); |
||||
EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andThrow(new NullPointerException()).once(); |
||||
|
||||
PowerMock.replayAll(); |
||||
|
||||
PluginMarker marker1 = PluginOperateUtils.updateMarker2Online(pluginMarker); |
||||
PluginMarker marker2 = PluginOperateUtils.updateMarker2Online(pluginMarker); |
||||
|
||||
Assert.assertTrue(marker1 instanceof PluginMarkerAdapter); |
||||
Assert.assertEquals(marker1.getPluginID(), "plugin-1"); |
||||
Assert.assertEquals(marker1.getVersion(), "1.0"); |
||||
Assert.assertEquals(((PluginMarkerAdapter) marker1).getPluginName(), "图表(新特性)"); |
||||
Assert.assertEquals(marker2, pluginMarker); |
||||
|
||||
PowerMock.verifyAll(); |
||||
} catch (Exception e) { |
||||
Assert.fail(); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void testUpdatePluginOnline() { |
||||
try { |
||||
PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0"); |
||||
String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}"; |
||||
JSONObject object = new JSONObject(pluginJson); |
||||
|
||||
PowerMock.mockStatic(PluginUtils.class); |
||||
EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once(); |
||||
EasyMock.expect(PluginUtils.getInstalledPluginMarkerByID("plugin-1")).andReturn(pluginMarker).once(); |
||||
|
||||
PowerMock.replayAll(); |
||||
|
||||
PluginOperateUtils.updatePluginOnline(pluginMarker, null); |
||||
|
||||
PowerMock.verifyAll(); |
||||
} catch (Exception e) { |
||||
Assert.fail(); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
@ -0,0 +1,50 @@
|
||||
package com.fr.start.module; |
||||
|
||||
import com.fr.design.constants.DesignerLaunchStatus; |
||||
import com.fr.event.EventDispatcher; |
||||
import com.fr.invoke.Reflect; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.Workspace; |
||||
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; |
||||
|
||||
/** |
||||
* @author Lucian.Chen |
||||
* @version 10.0 |
||||
* Created by Lucian.Chen on 2021/1/7 |
||||
*/ |
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest({WorkContext.class}) |
||||
public class DesignerWorkspaceProviderTest { |
||||
|
||||
@Test |
||||
public void testPluginErrorRemind() { |
||||
|
||||
try { |
||||
Workspace workspace = EasyMock.mock(Workspace.class); |
||||
EasyMock.expect(workspace.isLocal()).andReturn(false).once(); |
||||
PowerMock.mockStatic(WorkContext.class); |
||||
EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes(); |
||||
|
||||
EasyMock.replay(workspace); |
||||
PowerMock.replayAll(); |
||||
|
||||
DesignerWorkspaceProvider provider = new DesignerWorkspaceProvider(); |
||||
Reflect.on(provider).call("pluginErrorRemind"); |
||||
EventDispatcher.fire(DesignerLaunchStatus.STARTUP_COMPLETE); |
||||
|
||||
EasyMock.verify(workspace); |
||||
PowerMock.verifyAll(); |
||||
|
||||
} catch (Exception e) { |
||||
Assert.fail(e.getMessage()); |
||||
} |
||||
|
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue