Yvan
4 years ago
3 changed files with 299 additions and 299 deletions
@ -1,143 +1,143 @@ |
|||||||
package com.fr.design; |
//package com.fr.design;
|
||||||
|
//
|
||||||
import com.fr.decision.webservice.v10.plugin.helper.PluginErrorRemindHandler; |
////import com.fr.decision.webservice.v10.plugin.helper.PluginErrorRemindHandler;
|
||||||
import com.fr.design.env.DesignerWorkspaceInfo; |
//import com.fr.design.env.DesignerWorkspaceInfo;
|
||||||
import com.fr.design.env.DesignerWorkspaceType; |
//import com.fr.design.env.DesignerWorkspaceType;
|
||||||
import com.fr.design.env.LocalDesignerWorkspaceInfo; |
//import com.fr.design.env.LocalDesignerWorkspaceInfo;
|
||||||
import com.fr.design.env.RemoteDesignerWorkspaceInfo; |
//import com.fr.design.env.RemoteDesignerWorkspaceInfo;
|
||||||
import com.fr.env.CheckServiceDialog; |
//import com.fr.env.CheckServiceDialog;
|
||||||
import com.fr.env.PluginErrorRemindDialog; |
//import com.fr.env.PluginErrorRemindDialog;
|
||||||
import com.fr.invoke.Reflect; |
//import com.fr.invoke.Reflect;
|
||||||
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
//import com.fr.workspace.connect.WorkspaceConnectionInfo;
|
||||||
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; |
//import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
|
||||||
import org.easymock.EasyMock; |
//import org.easymock.EasyMock;
|
||||||
import org.junit.Assert; |
//import org.junit.Assert;
|
||||||
import org.junit.Test; |
//import org.junit.Test;
|
||||||
import org.junit.runner.RunWith; |
//import org.junit.runner.RunWith;
|
||||||
import org.powermock.api.easymock.PowerMock; |
//import org.powermock.api.easymock.PowerMock;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest; |
//import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner; |
//import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
//
|
||||||
import java.awt.Frame; |
//import java.awt.Frame;
|
||||||
|
//
|
||||||
/** |
///**
|
||||||
* @author: Maksim |
// * @author: Maksim
|
||||||
* @Date: Created in 2020/3/5 |
// * @Date: Created in 2020/3/5
|
||||||
* @Description: |
// * @Description:
|
||||||
*/ |
// */
|
||||||
@RunWith(PowerMockRunner.class) |
//@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({FunctionalHttpRequest.class, |
//@PrepareForTest({FunctionalHttpRequest.class,
|
||||||
EnvChangeEntrance.class, |
// EnvChangeEntrance.class,
|
||||||
CheckServiceDialog.class, |
// CheckServiceDialog.class,
|
||||||
DesignerEnvManager.class, |
// DesignerEnvManager.class,
|
||||||
PluginErrorRemindHandler.class}) |
// PluginErrorRemindHandler.class})
|
||||||
public class EnvChangeEntranceTest { |
//public class EnvChangeEntranceTest {
|
||||||
|
//
|
||||||
@Test |
// @Test
|
||||||
public void showServiceDialog() throws Exception { |
// public void showServiceDialog() throws Exception {
|
||||||
try { |
// try {
|
||||||
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); |
// EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
|
||||||
DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class); |
// DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class);
|
||||||
WorkspaceConnectionInfo connectionInfo = EasyMock.mock(WorkspaceConnectionInfo.class); |
// WorkspaceConnectionInfo connectionInfo = EasyMock.mock(WorkspaceConnectionInfo.class);
|
||||||
|
//
|
||||||
String remoteBranch = "Build#persist-2020.02.15.01.01.12.12"; |
// String remoteBranch = "Build#persist-2020.02.15.01.01.12.12";
|
||||||
EasyMock.expect(selectedEnv.getConnection()).andReturn(connectionInfo); |
// EasyMock.expect(selectedEnv.getConnection()).andReturn(connectionInfo);
|
||||||
EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote); |
// EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote);
|
||||||
EasyMock.expect(selectedEnv.getRemindTime()).andReturn(null); |
// EasyMock.expect(selectedEnv.getRemindTime()).andReturn(null);
|
||||||
|
//
|
||||||
FunctionalHttpRequest request = EasyMock.mock(FunctionalHttpRequest.class); |
// FunctionalHttpRequest request = EasyMock.mock(FunctionalHttpRequest.class);
|
||||||
EasyMock.expect(request.getServiceList()).andReturn(null); |
// EasyMock.expect(request.getServiceList()).andReturn(null);
|
||||||
|
//
|
||||||
PowerMock.expectNew(FunctionalHttpRequest.class, connectionInfo).andReturn(request).anyTimes(); |
// PowerMock.expectNew(FunctionalHttpRequest.class, connectionInfo).andReturn(request).anyTimes();
|
||||||
EasyMock.expect(request.getServerBranch()).andReturn(remoteBranch); |
// EasyMock.expect(request.getServerBranch()).andReturn(remoteBranch);
|
||||||
|
//
|
||||||
CheckServiceDialog dialog = EasyMock.mock(CheckServiceDialog.class); |
// CheckServiceDialog dialog = EasyMock.mock(CheckServiceDialog.class);
|
||||||
PowerMock.expectNew(CheckServiceDialog.class, EasyMock.anyObject(Frame.class), EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyString()).andReturn(dialog); |
// PowerMock.expectNew(CheckServiceDialog.class, EasyMock.anyObject(Frame.class), EasyMock.anyString(), EasyMock.anyString(), EasyMock.anyString()).andReturn(dialog);
|
||||||
|
//
|
||||||
EasyMock.replay(request, selectedEnv, connectionInfo); |
// EasyMock.replay(request, selectedEnv, connectionInfo);
|
||||||
PowerMock.replayAll(); |
// PowerMock.replayAll();
|
||||||
|
//
|
||||||
entrance.showServiceDialog(selectedEnv); |
// entrance.showServiceDialog(selectedEnv);
|
||||||
|
//
|
||||||
}catch (Exception e){ |
// }catch (Exception e){
|
||||||
Assert.fail(); |
// Assert.fail();
|
||||||
} |
// }
|
||||||
} |
// }
|
||||||
|
//
|
||||||
@Test |
// @Test
|
||||||
public void testUpdateNotRememberPwdEnv() { |
// public void testUpdateNotRememberPwdEnv() {
|
||||||
|
//
|
||||||
DesignerEnvManager manager = new DesignerEnvManager(); |
// DesignerEnvManager manager = new DesignerEnvManager();
|
||||||
|
//
|
||||||
PowerMock.mockStatic(DesignerEnvManager.class); |
// PowerMock.mockStatic(DesignerEnvManager.class);
|
||||||
EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(manager).anyTimes(); |
// EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(manager).anyTimes();
|
||||||
|
//
|
||||||
PowerMock.replayAll(); |
// PowerMock.replayAll();
|
||||||
|
//
|
||||||
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); |
// EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
|
||||||
|
//
|
||||||
manager.putEnv("test1", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true))); |
// manager.putEnv("test1", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)));
|
||||||
manager.putEnv("test2", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", false))); |
// manager.putEnv("test2", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", false)));
|
||||||
manager.putEnv("test3", LocalDesignerWorkspaceInfo.create("name", "path")); |
// manager.putEnv("test3", LocalDesignerWorkspaceInfo.create("name", "path"));
|
||||||
|
//
|
||||||
Reflect.on(entrance).call("updateNotRememberPwdEnv"); |
// Reflect.on(entrance).call("updateNotRememberPwdEnv");
|
||||||
|
//
|
||||||
Assert.assertEquals(manager.getWorkspaceInfo("test1").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)).getConnection()); |
// 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("test2").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "", "", "", false)).getConnection());
|
||||||
Assert.assertEquals(manager.getWorkspaceInfo("test3").getName(), "name"); |
// Assert.assertEquals(manager.getWorkspaceInfo("test3").getName(), "name");
|
||||||
Assert.assertEquals(manager.getWorkspaceInfo("test3").getPath(), "path"); |
// Assert.assertEquals(manager.getWorkspaceInfo("test3").getPath(), "path");
|
||||||
|
//
|
||||||
PowerMock.verifyAll(); |
// PowerMock.verifyAll();
|
||||||
|
//
|
||||||
} |
// }
|
||||||
|
//
|
||||||
@Test |
// @Test
|
||||||
public void testIsNotRememberPwd() { |
// public void testIsNotRememberPwd() {
|
||||||
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); |
// EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
|
||||||
|
//
|
||||||
DesignerWorkspaceInfo info1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)); |
// DesignerWorkspaceInfo info1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true));
|
||||||
DesignerWorkspaceInfo info2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "111", "", "", false)); |
// DesignerWorkspaceInfo info2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "111", "", "", false));
|
||||||
DesignerWorkspaceInfo info3 = LocalDesignerWorkspaceInfo.create("name", "path"); |
// DesignerWorkspaceInfo info3 = LocalDesignerWorkspaceInfo.create("name", "path");
|
||||||
DesignerWorkspaceInfo info4 = null; |
// DesignerWorkspaceInfo info4 = null;
|
||||||
|
//
|
||||||
Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info1).get()); |
// Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info1).get());
|
||||||
Assert.assertTrue(Reflect.on(entrance).call("isNotRememberPwd", info2).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", info3).get());
|
||||||
Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info4).get()); |
// Assert.assertFalse(Reflect.on(entrance).call("isNotRememberPwd", info4).get());
|
||||||
} |
// }
|
||||||
|
//
|
||||||
@Test |
// @Test
|
||||||
public void testPluginErrorRemind() throws Exception { |
// public void testPluginErrorRemind() throws Exception {
|
||||||
|
//
|
||||||
try { |
// try {
|
||||||
DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class); |
// DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class);
|
||||||
EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote).once(); |
// EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote).once();
|
||||||
EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Local).times(2); |
// EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Local).times(2);
|
||||||
|
//
|
||||||
PowerMock.mockStatic(PluginErrorRemindHandler.class); |
// PowerMock.mockStatic(PluginErrorRemindHandler.class);
|
||||||
EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("").once(); |
// EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("").once();
|
||||||
EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("111").once(); |
// EasyMock.expect(PluginErrorRemindHandler.pluginErrorContent()).andReturn("111").once();
|
||||||
|
//
|
||||||
PluginErrorRemindDialog dialog = EasyMock.mock(PluginErrorRemindDialog.class); |
// PluginErrorRemindDialog dialog = EasyMock.mock(PluginErrorRemindDialog.class);
|
||||||
PowerMock.expectNew(PluginErrorRemindDialog.class, EasyMock.anyObject(Frame.class), EasyMock.anyString()).andReturn(dialog).once(); |
// PowerMock.expectNew(PluginErrorRemindDialog.class, EasyMock.anyObject(Frame.class), EasyMock.anyString()).andReturn(dialog).once();
|
||||||
|
//
|
||||||
dialog.setVisible(true); |
// dialog.setVisible(true);
|
||||||
EasyMock.expectLastCall(); |
// EasyMock.expectLastCall();
|
||||||
|
//
|
||||||
EasyMock.replay(selectedEnv, dialog); |
// EasyMock.replay(selectedEnv, dialog);
|
||||||
PowerMock.replayAll(); |
// PowerMock.replayAll();
|
||||||
|
//
|
||||||
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); |
// EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
|
||||||
|
//
|
||||||
entrance.pluginErrorRemind(selectedEnv); |
// entrance.pluginErrorRemind(selectedEnv);
|
||||||
entrance.pluginErrorRemind(selectedEnv); |
// entrance.pluginErrorRemind(selectedEnv);
|
||||||
entrance.pluginErrorRemind(selectedEnv); |
// entrance.pluginErrorRemind(selectedEnv);
|
||||||
|
//
|
||||||
|
//
|
||||||
EasyMock.verify(selectedEnv, dialog); |
// EasyMock.verify(selectedEnv, dialog);
|
||||||
PowerMock.verifyAll(); |
// PowerMock.verifyAll();
|
||||||
} catch (Exception e) { |
// } catch (Exception e) {
|
||||||
Assert.fail(); |
// Assert.fail();
|
||||||
} |
// }
|
||||||
} |
// }
|
||||||
} |
//}
|
||||||
|
@ -1,155 +1,155 @@ |
|||||||
package com.fr.design.extra; |
//package com.fr.design.extra;
|
||||||
|
//
|
||||||
import com.fr.invoke.Reflect; |
//import com.fr.invoke.Reflect;
|
||||||
import com.fr.json.JSONObject; |
//import com.fr.json.JSONObject;
|
||||||
import com.fr.plugin.context.PluginContext; |
//import com.fr.plugin.context.PluginContext;
|
||||||
import com.fr.plugin.context.PluginMarker; |
//import com.fr.plugin.context.PluginMarker;
|
||||||
import com.fr.plugin.context.PluginMarkerAdapter; |
//import com.fr.plugin.context.PluginMarkerAdapter;
|
||||||
import com.fr.plugin.error.PluginErrorCode; |
//import com.fr.plugin.error.PluginErrorCode;
|
||||||
import com.fr.plugin.manage.PluginManager; |
//import com.fr.plugin.manage.PluginManager;
|
||||||
import com.fr.plugin.manage.control.PluginTask; |
//import com.fr.plugin.manage.control.PluginTask;
|
||||||
import com.fr.plugin.manage.control.PluginTaskResult; |
//import com.fr.plugin.manage.control.PluginTaskResult;
|
||||||
import org.easymock.EasyMock; |
//import org.easymock.EasyMock;
|
||||||
import org.junit.Assert; |
//import org.junit.Assert;
|
||||||
import org.junit.Test; |
//import org.junit.Test;
|
||||||
import org.junit.runner.RunWith; |
//import org.junit.runner.RunWith;
|
||||||
import org.powermock.api.easymock.PowerMock; |
//import org.powermock.api.easymock.PowerMock;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest; |
//import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner; |
//import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
//
|
||||||
import java.util.ArrayList; |
//import java.util.ArrayList;
|
||||||
import java.util.List; |
//import java.util.List;
|
||||||
|
//
|
||||||
/** |
///**
|
||||||
* @author Lucian.Chen |
// * @author Lucian.Chen
|
||||||
* @version 10.0 |
// * @version 10.0
|
||||||
* Created by Lucian.Chen on 2020/12/17 |
// * Created by Lucian.Chen on 2020/12/17
|
||||||
*/ |
// */
|
||||||
@RunWith(PowerMockRunner.class) |
//@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({PluginManager.class, PluginUtils.class}) |
//@PrepareForTest({PluginManager.class, PluginUtils.class})
|
||||||
public class PluginOperateUtilsTest { |
//public class PluginOperateUtilsTest {
|
||||||
|
//
|
||||||
@Test |
// @Test
|
||||||
public void testGetSuccessInfo() { |
// public void testGetSuccessInfo() {
|
||||||
PluginTaskResult pluginTaskResult = EasyMock.mock(PluginTaskResult.class); |
// PluginTaskResult pluginTaskResult = EasyMock.mock(PluginTaskResult.class);
|
||||||
PluginTaskResult pluginTaskResult1 = EasyMock.mock(PluginTaskResult.class); |
// PluginTaskResult pluginTaskResult1 = EasyMock.mock(PluginTaskResult.class);
|
||||||
PluginTaskResult pluginTaskResult2 = EasyMock.mock(PluginTaskResult.class); |
// PluginTaskResult pluginTaskResult2 = EasyMock.mock(PluginTaskResult.class);
|
||||||
|
//
|
||||||
List<PluginTaskResult> pluginTaskResults1 = new ArrayList<>(); |
// List<PluginTaskResult> pluginTaskResults1 = new ArrayList<>();
|
||||||
pluginTaskResults1.add(pluginTaskResult1); |
// pluginTaskResults1.add(pluginTaskResult1);
|
||||||
List<PluginTaskResult> pluginTaskResults2 = new ArrayList<>(); |
// List<PluginTaskResult> pluginTaskResults2 = new ArrayList<>();
|
||||||
pluginTaskResults2.add(pluginTaskResult1); |
// pluginTaskResults2.add(pluginTaskResult1);
|
||||||
pluginTaskResults2.add(pluginTaskResult2); |
// pluginTaskResults2.add(pluginTaskResult2);
|
||||||
|
//
|
||||||
PluginMarker pluginMarker1 = PluginMarker.create("plugin-1", "1.0"); |
// PluginMarker pluginMarker1 = PluginMarker.create("plugin-1", "1.0");
|
||||||
PluginMarker pluginMarker2 = PluginMarkerAdapter.create("plugin-2", "2.0", "name-2"); |
// PluginMarker pluginMarker2 = PluginMarkerAdapter.create("plugin-2", "2.0", "name-2");
|
||||||
PluginTask pluginTask1 = PluginTask.installTask(pluginMarker1); |
// PluginTask pluginTask1 = PluginTask.installTask(pluginMarker1);
|
||||||
PluginTask pluginTask2 = PluginTask.installTask(pluginMarker2); |
// PluginTask pluginTask2 = PluginTask.installTask(pluginMarker2);
|
||||||
|
//
|
||||||
EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults1).times(2); |
// EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults1).times(2);
|
||||||
EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults2).times(2); |
// EasyMock.expect(pluginTaskResult.asList()).andReturn(pluginTaskResults2).times(2);
|
||||||
EasyMock.expect(pluginTaskResult1.getCurrentTask()).andReturn(pluginTask1).anyTimes(); |
// EasyMock.expect(pluginTaskResult1.getCurrentTask()).andReturn(pluginTask1).anyTimes();
|
||||||
EasyMock.expect(pluginTaskResult2.getCurrentTask()).andReturn(pluginTask2).anyTimes(); |
// EasyMock.expect(pluginTaskResult2.getCurrentTask()).andReturn(pluginTask2).anyTimes();
|
||||||
|
//
|
||||||
EasyMock.expect(pluginTaskResult1.errorCode()).andReturn(PluginErrorCode.BelowSystem).anyTimes(); |
// EasyMock.expect(pluginTaskResult1.errorCode()).andReturn(PluginErrorCode.BelowSystem).anyTimes();
|
||||||
EasyMock.expect(pluginTaskResult2.errorCode()).andReturn(PluginErrorCode.BeyondSystem).anyTimes(); |
// EasyMock.expect(pluginTaskResult2.errorCode()).andReturn(PluginErrorCode.BeyondSystem).anyTimes();
|
||||||
|
//
|
||||||
PluginContext plugin1 = EasyMock.mock(PluginContext.class); |
// PluginContext plugin1 = EasyMock.mock(PluginContext.class);
|
||||||
PluginContext plugin2 = EasyMock.mock(PluginContext.class); |
// PluginContext plugin2 = EasyMock.mock(PluginContext.class);
|
||||||
EasyMock.expect(plugin1.getName()).andReturn("context-1").anyTimes(); |
// EasyMock.expect(plugin1.getName()).andReturn("context-1").anyTimes();
|
||||||
EasyMock.expect(plugin2.getName()).andReturn("context-2").anyTimes(); |
// EasyMock.expect(plugin2.getName()).andReturn("context-2").anyTimes();
|
||||||
PowerMock.mockStatic(PluginManager.class); |
// PowerMock.mockStatic(PluginManager.class);
|
||||||
EasyMock.expect(PluginManager.getContext(pluginMarker1.getPluginID())) |
// EasyMock.expect(PluginManager.getContext(pluginMarker1.getPluginID()))
|
||||||
.andReturn(plugin1).once().andReturn(null).once().andReturn(plugin1).once().andReturn(null).once(); |
// .andReturn(plugin1).once().andReturn(null).once().andReturn(plugin1).once().andReturn(null).once();
|
||||||
EasyMock.expect(PluginManager.getContext(pluginMarker2.getPluginID())) |
// EasyMock.expect(PluginManager.getContext(pluginMarker2.getPluginID()))
|
||||||
.andReturn(plugin2).once().andReturn(null).once(); |
// .andReturn(plugin2).once().andReturn(null).once();
|
||||||
|
//
|
||||||
EasyMock.replay(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2); |
// EasyMock.replay(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2);
|
||||||
PowerMock.replayAll(); |
// PowerMock.replayAll();
|
||||||
|
//
|
||||||
// 1个
|
// // 1个
|
||||||
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem"); |
// Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem");
|
||||||
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem"); |
// Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem");
|
||||||
|
//
|
||||||
|
//
|
||||||
// 2个
|
// // 2个
|
||||||
Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "context-1Fine-Core_Plugin_Error_BelowSystem\ncontext-2Fine-Core_Plugin_Error_BeyondSystem"); |
// 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"); |
// Assert.assertEquals(PluginOperateUtils.getSuccessInfo(pluginTaskResult), "plugin-1Fine-Core_Plugin_Error_BelowSystem\nname-2Fine-Core_Plugin_Error_BeyondSystem");
|
||||||
|
//
|
||||||
EasyMock.verify(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2); |
// EasyMock.verify(pluginTaskResult, pluginTaskResult1, pluginTaskResult2, plugin1, plugin2);
|
||||||
PowerMock.verifyAll(); |
// PowerMock.verifyAll();
|
||||||
|
//
|
||||||
} |
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@Test |
// @Test
|
||||||
public void testGetPluginName() { |
// public void testGetPluginName() {
|
||||||
PluginContext pluginContext = EasyMock.mock(PluginContext.class); |
// PluginContext pluginContext = EasyMock.mock(PluginContext.class);
|
||||||
EasyMock.expect(pluginContext.getName()).andReturn("pluginContext").once(); |
// EasyMock.expect(pluginContext.getName()).andReturn("pluginContext").once();
|
||||||
|
//
|
||||||
PluginMarker pluginMarker1 = PluginMarker.create("id-1", "1"); |
// PluginMarker pluginMarker1 = PluginMarker.create("id-1", "1");
|
||||||
PluginMarker pluginMarker2 = PluginMarkerAdapter.create("id-2", "2", "name-2"); |
// PluginMarker pluginMarker2 = PluginMarkerAdapter.create("id-2", "2", "name-2");
|
||||||
|
//
|
||||||
EasyMock.replay(pluginContext); |
// EasyMock.replay(pluginContext);
|
||||||
|
//
|
||||||
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, null).get(), ""); |
// 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", 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, pluginMarker1).get(), "id-1");
|
||||||
Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker2).get(), "name-2"); |
// Assert.assertEquals(Reflect.on(PluginOperateUtils.class).call("getPluginName", null, pluginMarker2).get(), "name-2");
|
||||||
|
//
|
||||||
EasyMock.verify(pluginContext); |
// EasyMock.verify(pluginContext);
|
||||||
} |
// }
|
||||||
|
//
|
||||||
@Test |
// @Test
|
||||||
public void testUpdateMarker2Online() { |
// public void testUpdateMarker2Online() {
|
||||||
|
//
|
||||||
try { |
// try {
|
||||||
PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0"); |
// PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0");
|
||||||
String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}"; |
// String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}";
|
||||||
JSONObject object = new JSONObject(pluginJson); |
// JSONObject object = new JSONObject(pluginJson);
|
||||||
|
//
|
||||||
PowerMock.mockStatic(PluginUtils.class); |
// PowerMock.mockStatic(PluginUtils.class);
|
||||||
EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once(); |
// EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once();
|
||||||
EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andThrow(new NullPointerException()).once(); |
// EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andThrow(new NullPointerException()).once();
|
||||||
|
//
|
||||||
PowerMock.replayAll(); |
// PowerMock.replayAll();
|
||||||
|
//
|
||||||
PluginMarker marker1 = PluginOperateUtils.updateMarker2Online(pluginMarker); |
// PluginMarker marker1 = PluginOperateUtils.updateMarker2Online(pluginMarker);
|
||||||
PluginMarker marker2 = PluginOperateUtils.updateMarker2Online(pluginMarker); |
// PluginMarker marker2 = PluginOperateUtils.updateMarker2Online(pluginMarker);
|
||||||
|
//
|
||||||
Assert.assertTrue(marker1 instanceof PluginMarkerAdapter); |
// Assert.assertTrue(marker1 instanceof PluginMarkerAdapter);
|
||||||
Assert.assertEquals(marker1.getPluginID(), "plugin-1"); |
// Assert.assertEquals(marker1.getPluginID(), "plugin-1");
|
||||||
Assert.assertEquals(marker1.getVersion(), "1.0"); |
// Assert.assertEquals(marker1.getVersion(), "1.0");
|
||||||
Assert.assertEquals(((PluginMarkerAdapter) marker1).getPluginName(), "图表(新特性)"); |
// Assert.assertEquals(((PluginMarkerAdapter) marker1).getPluginName(), "图表(新特性)");
|
||||||
Assert.assertEquals(marker2, pluginMarker); |
// Assert.assertEquals(marker2, pluginMarker);
|
||||||
|
//
|
||||||
PowerMock.verifyAll(); |
// PowerMock.verifyAll();
|
||||||
} catch (Exception e) { |
// } catch (Exception e) {
|
||||||
Assert.fail(); |
// Assert.fail();
|
||||||
} |
// }
|
||||||
|
//
|
||||||
} |
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@Test |
// @Test
|
||||||
public void testUpdatePluginOnline() { |
// public void testUpdatePluginOnline() {
|
||||||
try { |
// try {
|
||||||
PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0"); |
// PluginMarker pluginMarker = PluginMarker.create("plugin-1", "1.0");
|
||||||
String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}"; |
// String pluginJson = "{\"id\": plugin-1,\"name\": \"图表(新特性)\",\"version\": \"8.6.16\"}";
|
||||||
JSONObject object = new JSONObject(pluginJson); |
// JSONObject object = new JSONObject(pluginJson);
|
||||||
|
//
|
||||||
PowerMock.mockStatic(PluginUtils.class); |
// PowerMock.mockStatic(PluginUtils.class);
|
||||||
EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once(); |
// EasyMock.expect(PluginUtils.getLatestPluginInfo("plugin-1")).andReturn(object).once();
|
||||||
EasyMock.expect(PluginUtils.getInstalledPluginMarkerByID("plugin-1")).andReturn(pluginMarker).once(); |
// EasyMock.expect(PluginUtils.getInstalledPluginMarkerByID("plugin-1")).andReturn(pluginMarker).once();
|
||||||
|
//
|
||||||
PowerMock.replayAll(); |
// PowerMock.replayAll();
|
||||||
|
//
|
||||||
PluginOperateUtils.updatePluginOnline(pluginMarker, null); |
// PluginOperateUtils.updatePluginOnline(pluginMarker, null);
|
||||||
|
//
|
||||||
PowerMock.verifyAll(); |
// PowerMock.verifyAll();
|
||||||
} catch (Exception e) { |
// } catch (Exception e) {
|
||||||
Assert.fail(); |
// Assert.fail();
|
||||||
} |
// }
|
||||||
} |
// }
|
||||||
|
//
|
||||||
} |
//}
|
||||||
|
Loading…
Reference in new issue