From e544673a4d6fd911161095c4562a8f486512338b Mon Sep 17 00:00:00 2001 From: Maksim Date: Fri, 6 Mar 2020 10:55:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=EF=BC=8C=E9=98=B2=E6=AD=A2=E7=A9=BA=E6=8C=87=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 7 ++- .../com/fr/design/EnvChangeEntranceTest.java | 52 +++++++++++++++++++ .../write/submit/CheckServiceDialogTest.java | 19 +++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java create mode 100644 designer-base/src/test/java/com/fr/design/write/submit/CheckServiceDialogTest.java diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index eca98c8bea..2efef818aa 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -27,6 +27,7 @@ import com.fr.log.FineLoggerFactory; import com.fr.rpc.Result; import com.fr.stable.AssistUtils; import com.fr.stable.EnvChangedListener; +import com.fr.stable.StringUtils; import com.fr.start.server.ServerTray; import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContextCallback; @@ -38,6 +39,7 @@ import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import com.fr.workspace.engine.exception.WorkspaceAuthException; import com.fr.workspace.engine.exception.WorkspaceConnectionException; import com.fr.workspace.engine.rpc.WorkspaceProxyPool; +import jdk.nashorn.internal.objects.annotations.Function; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; @@ -262,6 +264,9 @@ public class EnvChangeEntrance { try { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); + if(StringUtils.isEmpty(selectedEnv.getRemindTime())){ + return true; + } //获取记录的时间 Date remindTime = format.parse(selectedEnv.getRemindTime()); calendar.setTime(remindTime); @@ -325,7 +330,7 @@ public class EnvChangeEntrance { return noExistServiceSet; } catch (Exception e){ FineLoggerFactory.getLogger().error(e.getMessage(),e); - return null; + return noExistServiceSet; } } diff --git a/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java new file mode 100644 index 0000000000..989b0fdbbd --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java @@ -0,0 +1,52 @@ +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.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 { + 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); + } + +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/write/submit/CheckServiceDialogTest.java b/designer-base/src/test/java/com/fr/design/write/submit/CheckServiceDialogTest.java new file mode 100644 index 0000000000..fc18eb607c --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/write/submit/CheckServiceDialogTest.java @@ -0,0 +1,19 @@ +package com.fr.design.write.submit; + +import com.fr.design.mainframe.DesignerContext; +import org.junit.Test; + +/** + * @author: Maksim + * @Date: Created in 2020/3/5 + * @Description: + */ +public class CheckServiceDialogTest { + + @Test + public void dialogTest(){ + CheckServiceDialog dialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), "无","2020-02-01","2020-03-01"); + dialog.setVisible(true); + } + +} \ No newline at end of file