You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by jo...@apache.org on 2021/05/21 14:11:29 UTC
[isis] 01/04: straighten out Diagram classes
This is an automated email from the ASF dual-hosted git repository.
joergrade pushed a commit to branch ISIS-2505_Catch_Up_With_Demo_Examples
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 836f9a4ade130075ed30c6f01d0cb5bbcd6b35a7
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Tue May 11 09:47:19 2021 +0200
straighten out Diagram classes
---
incubator/clients/kroviz/build.gradle.kts | 2 +-
.../isis/client/kroviz/ui/core/RoStatusBar.kt | 4 +-
.../ui/diagram/{PumlBuilder.kt => ClassDiagram.kt} | 74 +++++++---------------
.../isis/client/kroviz/ui/diagram/JsonDiagram.kt | 9 +++
.../isis/client/kroviz/ui/diagram/LayoutDiagram.kt | 35 ++++++++--
.../client/kroviz/ui/diagram/SequenceDiagram.kt | 66 +++++++++++++++++++
.../isis/client/kroviz/ui/diagram/UmlDiagram.kt | 59 -----------------
.../isis/client/kroviz/ui/dialog/DiagramDialog.kt | 2 +-
.../isis/client/kroviz/ui/dialog/EventLogDetail.kt | 19 +++---
.../client/kroviz/ui/panel/EventLogTableMgr.kt | 5 +-
.../client/kroviz/core/event/EventStoreTest.kt | 4 +-
.../isis/client/kroviz/ui/ClassDiagramTest.kt | 59 +++++++++++++++++
.../SequenceDiagramTest.kt} | 31 ++-------
13 files changed, 208 insertions(+), 161 deletions(-)
diff --git a/incubator/clients/kroviz/build.gradle.kts b/incubator/clients/kroviz/build.gradle.kts
index a2c2e47..01502fd 100644
--- a/incubator/clients/kroviz/build.gradle.kts
+++ b/incubator/clients/kroviz/build.gradle.kts
@@ -46,7 +46,7 @@ kotlin {
browser {
runTask {
outputFileName = "main.bundle.js"
- sourceMaps = false
+ sourceMaps = true
devServer = KotlinWebpackConfig.DevServer(
open = false,
port = 3000,
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoStatusBar.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoStatusBar.kt
index 3f5397a..a8d0020 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoStatusBar.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/RoStatusBar.kt
@@ -23,7 +23,7 @@ import org.apache.isis.client.kroviz.core.event.LogEntry
import org.apache.isis.client.kroviz.core.model.DiagramDM
import org.apache.isis.client.kroviz.ui.dialog.DiagramDialog
import org.apache.isis.client.kroviz.ui.dialog.NotificationDialog
-import org.apache.isis.client.kroviz.ui.diagram.UmlDiagram
+import org.apache.isis.client.kroviz.ui.diagram.ClassDiagram
import org.apache.isis.client.kroviz.utils.IconManager
import io.kvision.core.*
import io.kvision.html.Button
@@ -65,7 +65,7 @@ object RoStatusBar {
classDiagram.style = ButtonStyle.OUTLINESUCCESS
classDiagram.onClick {
val title = dd.title
- val code = UmlDiagram.buildClass(dd)
+ val code = ClassDiagram.build(dd)
DiagramDialog(title, code).open()
}
}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/PumlBuilder.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/ClassDiagram.kt
similarity index 59%
rename from incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/PumlBuilder.kt
rename to incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/ClassDiagram.kt
index 7ccd8c5..94991a4 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/PumlBuilder.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/ClassDiagram.kt
@@ -18,18 +18,32 @@
*/
package org.apache.isis.client.kroviz.ui.diagram
-import org.apache.isis.client.kroviz.core.event.EventStore
-import org.apache.isis.client.kroviz.core.event.LogEntry
-import org.apache.isis.client.kroviz.core.event.ResourceSpecification
+import org.apache.isis.client.kroviz.core.model.DiagramDM
import org.apache.isis.client.kroviz.core.model.meta.MetaClass
import org.apache.isis.client.kroviz.core.model.meta.MetaPackage
import org.apache.isis.client.kroviz.to.DomainType
-import org.apache.isis.client.kroviz.to.HasLinks
-import org.apache.isis.client.kroviz.to.Link
-import org.apache.isis.client.kroviz.to.Relation
-import org.apache.isis.client.kroviz.ui.core.UiManager
-class PumlBuilder {
+object ClassDiagram {
+
+ fun build(dd: DiagramDM): String {
+ val domainTypeList: Set<DomainType> = dd.classes
+ //TODO properties needed to set type
+ //val properties: Set<Property> = dd.properties
+ val packages = mutableSetOf<MetaPackage>()
+ domainTypeList.forEach { dt ->
+ val cls = MetaClass(dt)
+ val pkgName = cls.pkg.name
+ var pkg = packages.find { p -> p.name == pkgName }
+ if (pkg == null) {
+ pkg = cls.pkg
+ pkg.classes.add(cls)
+ packages.add(pkg)
+ } else {
+ pkg.classes.add(cls)
+ }
+ }
+ return with(packages)
+ }
private val Q = "\""
private val NL = "\\n"
@@ -84,49 +98,5 @@ class PumlBuilder {
return pumlCode
}
- fun with(rootLE: LogEntry): String {
- var code = "$Q@startuml$NL"
- code += iterateOverChildren(rootLE)
- code += "@enduml$Q"
- return code
- }
-
- fun asJsonDiagram(json: String): String {
- return "@startjson" + "\n" + json + "\n" + "@endjson"
- }
-
- private fun iterateOverChildren(logEntry: LogEntry): String {
- var code = ""
- val tObj = logEntry.obj
- val parentUrl = logEntry.url
- if (tObj is HasLinks) {
- tObj.getLinks().forEach { l ->
- val rel = l.relation()
- if (rel != Relation.UP && rel != Relation.SELF) {
- code += amendWithChild(parentUrl, l)
- }
- }
- }
- return code
- }
-
- private fun amendWithChild(parentUrl: String, child: Link): String {
- // kroki.io can not handle / (slash) in strings; escaping doesn't work either
- val baseUrl = UiManager.getUrl()
- var source = parentUrl.replace(baseUrl, "")
- source = source.replace("/" , "_")
- val childUrl = child.href
- var target = childUrl.replace(baseUrl, "")
- target = target.replace("/" , "_")
- var code = "$source -> $target $NL"
-
- val rs = ResourceSpecification(childUrl)
- val childLE = EventStore.find(rs)
- if (childLE != null) {
- code += iterateOverChildren(childLE)
- }
- return code
- }
}
-
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/JsonDiagram.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/JsonDiagram.kt
new file mode 100644
index 0000000..4f28a9d
--- /dev/null
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/JsonDiagram.kt
@@ -0,0 +1,9 @@
+package org.apache.isis.client.kroviz.ui.diagram
+
+object JsonDiagram {
+
+ fun build(json: String): String {
+ return "@startjson" + "\n" + json + "\n" + "@endjson"
+ }
+
+}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LayoutDiagram.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LayoutDiagram.kt
index a5d001b..201d281 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LayoutDiagram.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LayoutDiagram.kt
@@ -18,6 +18,10 @@
*/
package org.apache.isis.client.kroviz.ui.diagram
+import org.apache.isis.client.kroviz.layout.ColsLt
+import org.apache.isis.client.kroviz.layout.Layout
+import org.apache.isis.client.kroviz.layout.RowLt
+
object LayoutDiagram {
@Deprecated("pass in as arg")
@@ -29,14 +33,33 @@ object LayoutDiagram {
"}\n" +
"@endsalt"
- fun build(json: String): String {
- var pumlCode = sampleCode
- return pumlCode
+ fun build(layout: Layout): String {
+ var pumlCode = "@startsalt\n{#\n"
+ layout.row.forEach {
+ pumlCode += buildRow(it)
+ }
+ return pumlCode + "}\n@endsalt"
+ }
+
+ private fun buildRow(row: RowLt): String {
+ var s = ""
+ row.cols.forEach {
+ s += buildCol(it)
+ }
+ return s
}
- private fun buildRow(): String {
- val span = 1
- return ""
+ private fun buildCol(cols: ColsLt): String {
+ var s = ". "
+ val span: Int? = cols.col.span
+ if (span == null) {
+ s += "| . "
+ } else {
+ for (i in 1..span) {
+ s += "| * "
+ }
+ }
+ return s + "\n"
}
}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/SequenceDiagram.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/SequenceDiagram.kt
new file mode 100644
index 0000000..839285e
--- /dev/null
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/SequenceDiagram.kt
@@ -0,0 +1,66 @@
+package org.apache.isis.client.kroviz.ui.diagram
+
+import org.apache.isis.client.kroviz.core.event.EventStore
+import org.apache.isis.client.kroviz.core.event.LogEntry
+import org.apache.isis.client.kroviz.core.event.ResourceSpecification
+import org.apache.isis.client.kroviz.to.HasLinks
+import org.apache.isis.client.kroviz.to.Link
+import org.apache.isis.client.kroviz.to.Relation
+import org.apache.isis.client.kroviz.ui.core.UiManager
+
+object SequenceDiagram {
+
+ fun build(logEntries: List<LogEntry>): String? {
+ val first: LogEntry? = logEntries.find { le ->
+ le.url.endsWith("/restful/")
+ }
+ if (first != null) {
+ return with(first)
+ }
+ return null
+ }
+
+ private val Q = "\""
+ private val NL = "\\n"
+
+ fun with(rootLE: LogEntry): String {
+ var code = "$Q@startuml$NL"
+ code += iterateOverChildren(rootLE)
+ code += "@enduml$Q"
+ return code
+ }
+
+ private fun iterateOverChildren(logEntry: LogEntry): String {
+ var code = ""
+ val tObj = logEntry.obj
+ val parentUrl = logEntry.url
+ if (tObj is HasLinks) {
+ tObj.getLinks().forEach { l ->
+ val rel = l.relation()
+ if (rel != Relation.UP && rel != Relation.SELF) {
+ code += amendWithChild(parentUrl, l)
+ }
+ }
+ }
+ return code
+ }
+
+ private fun amendWithChild(parentUrl: String, child: Link): String {
+ // kroki.io can not handle / (slash) in strings; escaping doesn't work either
+ val baseUrl = UiManager.getUrl()
+ var source = parentUrl.replace(baseUrl, "")
+ source = source.replace("/", "_")
+ val childUrl = child.href
+ var target = childUrl.replace(baseUrl, "")
+ target = target.replace("/", "_")
+ var code = "$source -> $target $NL"
+
+ val rs = ResourceSpecification(childUrl)
+ val childLE = EventStore.find(rs)
+ if (childLE != null) {
+ code += iterateOverChildren(childLE)
+ }
+ return code
+ }
+
+}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/UmlDiagram.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/UmlDiagram.kt
deleted file mode 100644
index c87c7f9..0000000
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/UmlDiagram.kt
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.client.kroviz.ui.diagram
-
-import org.apache.isis.client.kroviz.core.event.LogEntry
-import org.apache.isis.client.kroviz.core.model.DiagramDM
-import org.apache.isis.client.kroviz.core.model.meta.MetaClass
-import org.apache.isis.client.kroviz.core.model.meta.MetaPackage
-import org.apache.isis.client.kroviz.to.DomainType
-
-object UmlDiagram {
-
- fun buildClass(dd: DiagramDM): String {
- val domainTypeList: Set<DomainType> = dd.classes
- //TODO properties needed to set type
- //val properties: Set<Property> = dd.properties
- val packages = mutableSetOf<MetaPackage>()
- domainTypeList.forEach { dt ->
- val cls = MetaClass(dt)
- val pkgName = cls.pkg.name
- var pkg = packages.find { p -> p.name == pkgName }
- if (pkg == null) {
- pkg = cls.pkg
- pkg.classes.add(cls)
- packages.add(pkg)
- } else {
- pkg.classes.add(cls)
- }
- }
- return PumlBuilder().with(packages)
- }
-
- fun buildSequence(logEntries: List<LogEntry>): String? {
- val first: LogEntry? = logEntries.find { le ->
- le.url.endsWith("/restful/")
- }
- if (first != null) {
- return PumlBuilder().with(first)
- }
- return null
- }
-
-}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/DiagramDialog.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/DiagramDialog.kt
index 810affd..919b34e 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/DiagramDialog.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/DiagramDialog.kt
@@ -85,7 +85,7 @@ class DiagramDialog(
val menu = mutableListOf<KvisionHtmlLink>()
val action = MenuFactory.buildActionLink(
label = "Pin",
- menuTitle = "pin")
+ menuTitle = "Pin")
action.onClick {
pin()
}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/EventLogDetail.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/EventLogDetail.kt
index c4abe76..267553a 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/EventLogDetail.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/dialog/EventLogDetail.kt
@@ -19,11 +19,13 @@
package org.apache.isis.client.kroviz.ui.dialog
import org.apache.isis.client.kroviz.core.event.LogEntry
+import org.apache.isis.client.kroviz.layout.Layout
import org.apache.isis.client.kroviz.to.ValueType
-import org.apache.isis.client.kroviz.ui.core.FormItem
-import org.apache.isis.client.kroviz.ui.diagram.PumlBuilder
import org.apache.isis.client.kroviz.ui.core.Constants
+import org.apache.isis.client.kroviz.ui.core.FormItem
import org.apache.isis.client.kroviz.ui.core.RoDialog
+import org.apache.isis.client.kroviz.ui.diagram.JsonDiagram
+import org.apache.isis.client.kroviz.ui.diagram.LayoutDiagram
import org.apache.isis.client.kroviz.utils.Utils
import org.apache.isis.client.kroviz.utils.XmlHelper
@@ -56,22 +58,17 @@ class EventLogDetail(val logEntry: LogEntry) : Command() {
widthPerc = 60).open()
}
-
override fun execute() {
val str = logEntry.response
- val json = when {
+ val pumlCode = when {
str.startsWith("<") -> {
- XmlHelper.xml2json(str)
+ LayoutDiagram.build(logEntry.obj as Layout)
}
- str.startsWith("{") -> str
+ str.startsWith("{") ->
+ JsonDiagram.build(str)
else -> "{}"
}
- val pumlCode = PumlBuilder().asJsonDiagram(json)
DiagramDialog("Response Diagram", pumlCode).open()
}
- fun executeConsole() {
- console.log(logEntry)
- }
-
}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/panel/EventLogTableMgr.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/panel/EventLogTableMgr.kt
index 2d5080ed..c393758 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/panel/EventLogTableMgr.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/panel/EventLogTableMgr.kt
@@ -22,9 +22,10 @@ package org.apache.isis.client.kroviz.ui.panel
import org.apache.isis.client.kroviz.core.event.EventStore
import org.apache.isis.client.kroviz.ui.dialog.DiagramDialog
import org.apache.isis.client.kroviz.ui.dialog.EventExportDialog
-import org.apache.isis.client.kroviz.ui.diagram.UmlDiagram
+import org.apache.isis.client.kroviz.ui.diagram.ClassDiagram
import org.apache.isis.client.kroviz.ui.chart.ChartFactory
import org.apache.isis.client.kroviz.ui.core.UiManager
+import org.apache.isis.client.kroviz.ui.diagram.SequenceDiagram
import org.apache.isis.client.kroviz.utils.IconManager
class EventLogTableMgr {
@@ -59,7 +60,7 @@ class EventLogTableMgr {
}
private fun eventDiagram() {
- val code = UmlDiagram.buildSequence(EventStore.log)!!
+ val code = SequenceDiagram.build(EventStore.log)!!
DiagramDialog("Event Diagram", code).open()
}
diff --git a/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/core/event/EventStoreTest.kt b/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/core/event/EventStoreTest.kt
index 5544b15..ce5c914 100644
--- a/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/core/event/EventStoreTest.kt
+++ b/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/core/event/EventStoreTest.kt
@@ -116,9 +116,9 @@ class EventStoreTest : IntegrationTest() {
// construct list with urls
EventStore.add(h1Spec)
- EventStore.addView(i1, agg, VPanel(), null)
+ EventStore.addView(i1, agg, VPanel())
EventStore.add(h2Spec)
- EventStore.addView(i2, agg, VPanel(), null)
+ EventStore.addView(i2, agg, VPanel())
val le1 = EventStore.find(h1Spec)!!
assertEquals(h1, le1.url) //1
diff --git a/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/ClassDiagramTest.kt b/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/ClassDiagramTest.kt
new file mode 100644
index 0000000..b94c65a
--- /dev/null
+++ b/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/ClassDiagramTest.kt
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.client.kroviz.ui
+
+import org.apache.isis.client.kroviz.handler.DomainTypeHandler
+import org.apache.isis.client.kroviz.snapshots.simpleapp1_16_0.SO
+import org.apache.isis.client.kroviz.to.DomainType
+import org.apache.isis.client.kroviz.ui.core.UiManager
+import org.apache.isis.client.kroviz.ui.diagram.ClassDiagram
+import kotlin.test.BeforeTest
+import kotlin.test.Test
+import kotlin.test.assertTrue
+
+class ClassDiagramTest {
+
+ @BeforeTest
+ fun setup() {
+ val user = "sven"
+ val pw = "pass"
+ val url = "http://${user}:${pw}@localhost:8080/restful/"
+ UiManager.login(url, user, pw)
+ }
+
+ @Test
+ fun testSimpleObject() {
+ //given
+ val pkg = "domainapp.modules.simple.dom.impl"
+ val cls = "SimpleObject"
+
+ val jsonStr = SO.str
+ val domainType = DomainTypeHandler().parse(jsonStr) as DomainType
+
+ //when
+ val actual = ClassDiagram.with(domainType)
+ //then
+ assertTrue(actual.startsWith("\"@startuml"))
+ assertTrue(actual.endsWith("@enduml\""))
+ assertTrue(actual.contains("package $pkg {\\n"))
+ assertTrue(actual.contains("class $cls\\n"))
+ }
+
+}
diff --git a/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/PumlBuilderTest.kt b/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/table/SequenceDiagramTest.kt
similarity index 78%
rename from incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/PumlBuilderTest.kt
rename to incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/table/SequenceDiagramTest.kt
index 39bd3ad..0c351dc 100644
--- a/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/PumlBuilderTest.kt
+++ b/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/table/SequenceDiagramTest.kt
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.isis.client.kroviz.ui
+package org.apache.isis.client.kroviz.ui.table
import org.apache.isis.client.kroviz.core.event.EventStore
import org.apache.isis.client.kroviz.core.event.LogEntry
@@ -25,13 +25,12 @@ import org.apache.isis.client.kroviz.core.event.ResourceSpecification
import org.apache.isis.client.kroviz.handler.*
import org.apache.isis.client.kroviz.snapshots.Response
import org.apache.isis.client.kroviz.snapshots.simpleapp1_16_0.*
-import org.apache.isis.client.kroviz.to.DomainType
import org.apache.isis.client.kroviz.to.Method
import org.apache.isis.client.kroviz.ui.core.UiManager
-import org.apache.isis.client.kroviz.ui.diagram.PumlBuilder
+import org.apache.isis.client.kroviz.ui.diagram.SequenceDiagram
import kotlin.test.*
-class PumlBuilderTest {
+class SequenceDiagramTest {
@BeforeTest
fun setup() {
@@ -41,24 +40,6 @@ class PumlBuilderTest {
UiManager.login(url, user, pw)
}
- @Test
- fun testSimpleObject() {
- //given
- val pkg = "domainapp.modules.simple.dom.impl"
- val cls = "SimpleObject"
-
- val jsonStr = SO.str
- val domainType = DomainTypeHandler().parse(jsonStr) as DomainType
-
- //when
- val actual = PumlBuilder().with(domainType)
- //then
- assertTrue(actual.startsWith("\"@startuml"))
- assertTrue(actual.endsWith("@enduml\""))
- assertTrue(actual.contains("package $pkg {\\n"))
- assertTrue(actual.contains("class $cls\\n"))
- }
-
//@Test //TODO IntegrationTest ?
fun testSequenceDiagram() {
//given
@@ -66,7 +47,7 @@ class PumlBuilderTest {
fillEventStoreWith(RESTFUL_SERVICES)
fillEventStoreWith(RESTFUL_MENUBARS)
//when
- val actual = PumlBuilder().with(rootLe)
+ val actual = SequenceDiagram.with(rootLe)
//then
assertEquals(3, EventStore.log.size)
console.log("[PBT.testSequenceDiagram]")
@@ -102,7 +83,7 @@ class PumlBuilderTest {
assertNotNull(rootLogEntry) //1
// when
- val code = PumlBuilder().with(rootLogEntry)
+ val code = SequenceDiagram.with(rootLogEntry)
// then
console.log("[PumlBuilderTest.testEventDiagram]")
console.log(code)
@@ -111,7 +92,7 @@ class PumlBuilderTest {
}
private fun load(response: Response, handler: BaseHandler) {
- val rs = ResourceSpecification(response.url)
+ val rs = ResourceSpecification(response.url)
EventStore.start(rs, Method.GET.operation)
val le = EventStore.end(rs, response.str)!!
val tObj = handler.parse(response.str)!!