From 4020cf334a2942ee5de4c694b6bbdf6908d272aa Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Fri, 5 Jul 2019 14:43:44 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-19058=20=E7=8E=AF=E5=A2=83=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E6=9A=82=E5=AD=98=E6=96=87=E4=BB=B6=E4=B8=BA=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/file/StashedFILE.java | 5 ++++ .../java/com/fr/file/StashedFILETest.java | 23 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 designer-base/src/test/java/com/fr/file/StashedFILETest.java diff --git a/designer-base/src/main/java/com/fr/file/StashedFILE.java b/designer-base/src/main/java/com/fr/file/StashedFILE.java index 181af2860..454433874 100644 --- a/designer-base/src/main/java/com/fr/file/StashedFILE.java +++ b/designer-base/src/main/java/com/fr/file/StashedFILE.java @@ -71,4 +71,9 @@ public class StashedFILE extends AbstractFILE { public boolean isEnvFile() { return false; } + + @Override + public String toString() { + return FILEFactory.MEM_PREFIX + getName(); + } } diff --git a/designer-base/src/test/java/com/fr/file/StashedFILETest.java b/designer-base/src/test/java/com/fr/file/StashedFILETest.java new file mode 100644 index 000000000..f3c358574 --- /dev/null +++ b/designer-base/src/test/java/com/fr/file/StashedFILETest.java @@ -0,0 +1,23 @@ +package com.fr.file; + +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; + +public class StashedFILETest { + + /** + * 用于测试暂存文件未保存时的提示 + */ + @Test + public void testToString() { + FILE file = EasyMock.mock(FILE.class); + String name = "getA.cpt"; + EasyMock.expect(file.getName()).andReturn(name).once(); + EasyMock.replay(file); + FILE stashedFILE = new StashedFILE(file, new byte[0]); + String expectString = FILEFactory.MEM_PREFIX + name; + Assert.assertEquals(expectString, stashedFILE + ""); + EasyMock.verify(file); + } +}