From a74462497d009febbba793f947a1e1e1a46ec1df Mon Sep 17 00:00:00 2001 From: plough Date: Tue, 23 Apr 2019 12:12:21 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-16391=20=E3=80=9010.03=E5=9F=8B=E7=82=B9?= =?UTF-8?q?-=E6=A8=A1=E6=9D=BF=E3=80=91=E5=B7=B2=E7=BB=8F=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E6=A8=A1=E6=9D=BF=E5=8F=A6=E5=AD=98=E4=B8=BA?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E4=BC=9A=E6=9C=89originid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/template/info/TemplateInfo.java | 4 +++ .../template/info/TemplateInfoCollector.java | 5 +--- .../info/TemplateInfoCollectorTest.java | 28 ++++++++++++++++++- .../design/mainframe/template/info/tpl.info | 4 +-- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java index 4c45ce823e..ffd9aaf3b4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java @@ -102,6 +102,10 @@ class TemplateInfo implements XMLReadable, XMLWriter { return templateID; } + String getOriginID() { + return originID; + } + int getTimeConsume() { return (int)consumingMap.get(ATTR_TIME_CONSUME); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java index 30bfb5e1d6..c16c6b6275 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java @@ -75,11 +75,8 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter { TemplateInfo templateInfo; if (this.contains(templateID)) { templateInfo = templateInfoMap.get(templateID); - } else if (!this.contains(originID)) { - templateInfo = TemplateInfo.newInstance(templateID); - templateInfoMap.put(templateID, templateInfo); } else { - int originTime = templateInfoMap.get(originID).getTimeConsume(); + int originTime = this.contains(originID) ? templateInfoMap.get(originID).getTimeConsume() : 0; templateInfo = TemplateInfo.newInstance(templateID, originID, originTime); templateInfoMap.put(templateID, templateInfo); } diff --git a/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java b/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java index 7b02f4bba2..e83a523fc4 100644 --- a/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java +++ b/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java @@ -66,9 +66,12 @@ public class TemplateInfoCollectorTest { @Test public void testReadXML() { + assertEquals(",,", DesignerOpenHistory.getInstance().toString()); + TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); - assertEquals("2019-04-18", Reflect.on(collector).field("designerOpenDate").get()); assertEquals(7, ((Map) Reflect.on(collector).field("templateInfoMap").get()).size()); + + assertEquals("2019-04-08,2019-04-03,2019-03-29", DesignerOpenHistory.getInstance().toString()); } @Test @@ -151,6 +154,29 @@ public class TemplateInfoCollectorTest { assertEquals(129, consumingMap.get("originTime")); } + @Test + public void testCollectInfoWhenSaveAsWithNoTrackOriginID() throws Exception { + setUpMockForNewInstance(); + + TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); + + String templateID = "423238d4-5223-22vj-vlsj-42jc49245iw3"; + String originID = "3kha8jcs-31xw-42f5-h2ww-2ee84935312z"; + int timeConsume = 200; + + collector.collectInfo(templateID, originID, mockProcessInfo, timeConsume); + + TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID); + assertEquals(templateID, templateInfo.getTemplateID()); + assertEquals(originID, templateInfo.getOriginID()); + + Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); + assertEquals(templateID, consumingMap.get("templateID")); + assertEquals(originID, consumingMap.get("originID")); + assertEquals(200, consumingMap.get("time_consume")); + assertEquals(0, consumingMap.get("originTime")); + } + @Test public void testAddIdleDateCount() { String templateID = "16a988ce-8529-42f5-b17c-2ee849355071"; diff --git a/designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info b/designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info index 39bec00067..eae77630fa 100644 --- a/designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info +++ b/designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info @@ -1,7 +1,7 @@ - - + +