Qinghui.Liu
5 years ago
30 changed files with 420 additions and 54 deletions
@ -0,0 +1,58 @@
|
||||
package com.fr.design; |
||||
|
||||
import com.fr.design.env.DesignerWorkspaceInfo; |
||||
import com.fr.design.env.DesignerWorkspaceType; |
||||
import com.fr.design.write.submit.CheckServiceDialog; |
||||
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; |
||||
|
||||
/** |
||||
* @author: Maksim |
||||
* @Date: Created in 2020/3/5 |
||||
* @Description: |
||||
*/ |
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest({FunctionalHttpRequest.class,EnvChangeEntrance.class,CheckServiceDialog.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(), EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject()).andReturn(dialog); |
||||
|
||||
EasyMock.replay(request); |
||||
EasyMock.replay(selectedEnv); |
||||
EasyMock.replay(connectionInfo); |
||||
PowerMock.replayAll(); |
||||
|
||||
entrance.showServiceDialog(selectedEnv); |
||||
Assert.assertTrue(true); |
||||
}catch (Exception e){ |
||||
Assert.assertTrue(false); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,54 @@
|
||||
package com.fr.design.env; |
||||
|
||||
import com.fr.base.operator.common.CommonOperator; |
||||
import com.fr.invoke.ReflectException; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.Workspace; |
||||
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
||||
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 2020/1/2 |
||||
*/ |
||||
@RunWith(PowerMockRunner.class) |
||||
@PrepareForTest({WorkContext.class}) |
||||
public class RemoteWorkspaceTest { |
||||
@Test |
||||
public void testIsWarDeploy() { |
||||
|
||||
Workspace workspace = EasyMock.mock(Workspace.class); |
||||
PowerMock.mockStatic(WorkContext.class); |
||||
EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes(); |
||||
|
||||
CommonOperator operator = EasyMock.createMock(CommonOperator.class); |
||||
EasyMock.expect(workspace.get(CommonOperator.class)).andReturn(operator).anyTimes(); |
||||
|
||||
EasyMock.expect(operator.isWarDeploy()).andReturn(true).once(); |
||||
EasyMock.expect(operator.isWarDeploy()).andReturn(false).once(); |
||||
EasyMock.expect(operator.isWarDeploy()).andThrow(new ReflectException()).once(); |
||||
|
||||
EasyMock.replay(workspace, operator); |
||||
PowerMock.replayAll(); |
||||
|
||||
WorkspaceConnectionInfo info = new WorkspaceConnectionInfo("url", "username", "password", "certPath", "certSecretKey"); |
||||
|
||||
RemoteWorkspace remoteWorkspace= new RemoteWorkspace(null, info); |
||||
|
||||
Assert.assertTrue(remoteWorkspace.isWarDeploy()); |
||||
Assert.assertFalse(remoteWorkspace.isWarDeploy()); |
||||
Assert.assertFalse(remoteWorkspace.isWarDeploy()); |
||||
|
||||
EasyMock.verify(workspace, operator); |
||||
PowerMock.verifyAll(); |
||||
|
||||
|
||||
} |
||||
} |
@ -0,0 +1,96 @@
|
||||
package com.fr.van.chart.map.designer.data.contentpane.table; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Utils; |
||||
import com.fr.chartx.TwoTuple; |
||||
import com.fr.design.chartx.component.MapAreaMatchPane; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionListener; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; |
||||
import com.fr.plugin.chart.map.VanChartMapPlot; |
||||
import com.fr.plugin.chart.map.data.MapMatchResult; |
||||
import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; |
||||
|
||||
import javax.swing.JFrame; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.tree.DefaultMutableTreeNode; |
||||
import java.util.Set; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2019-12-25 |
||||
*/ |
||||
public abstract class VanMapTableDataContentPane extends AbstractTableDataContentPane { |
||||
|
||||
private VanChartMapPlot plot; |
||||
|
||||
//钻取地图有层级,默认-1代表无层级关系
|
||||
private int level = ChartGEOJSONHelper.DEFAULT_LEVEL; |
||||
|
||||
private MapMatchResult matchResult = new MapMatchResult(); |
||||
|
||||
public void setLevel(int level) { |
||||
this.level = level; |
||||
} |
||||
|
||||
public void setPlot(VanChartMapPlot plot) { |
||||
this.plot = plot; |
||||
} |
||||
|
||||
public MapMatchResult getMatchResult() { |
||||
return matchResult; |
||||
} |
||||
|
||||
public void setMatchResult(MapMatchResult matchResult) { |
||||
this.matchResult = matchResult; |
||||
} |
||||
|
||||
public JPanel createAreaPanel(final UIComboBox areaBox) { |
||||
JPanel areaPanel = new JPanel(new BorderLayout(4, 0)); |
||||
areaBox.setPreferredSize(new Dimension(70, 20)); |
||||
areaPanel.add(areaBox, BorderLayout.CENTER); |
||||
UIButton uiButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/config.png")); |
||||
uiButton.addActionListener(new ActionListener() { |
||||
private TwoTuple<DefaultMutableTreeNode, Set<String>> treeNodeAndItems; |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
if (treeNodeAndItems == null) { |
||||
treeNodeAndItems = ChartGEOJSONHelper.getTreeNodeAndItems(plot.getGeoUrl(), level); |
||||
} |
||||
final MapAreaMatchPane pane = new MapAreaMatchPane(treeNodeAndItems); |
||||
|
||||
String nameTable = getTableName(); |
||||
|
||||
pane.populateBean(matchResult, nameTable, Utils.objectToString(areaBox.getSelectedItem())); |
||||
BasicDialog dialog = pane.showWindow(new JFrame()); |
||||
dialog.addDialogActionListener(new DialogActionListener() { |
||||
@Override |
||||
public void doOk() { |
||||
pane.updateBean(matchResult); |
||||
} |
||||
|
||||
@Override |
||||
public void doCancel() { |
||||
|
||||
} |
||||
}); |
||||
dialog.setVisible(true); |
||||
} |
||||
}); |
||||
areaPanel.add(uiButton, BorderLayout.EAST); |
||||
return areaPanel; |
||||
} |
||||
|
||||
@Override |
||||
public void refreshLevel(int level) { |
||||
this.setLevel(level); |
||||
} |
||||
} |
Loading…
Reference in new issue