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/06/16 17:12:40 UTC

[isis] 03/03: ISIS-2505 LinkTreeDiagram/LogEntryDecorator added as debugging aid; EventLogDetail amended

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 8c21b7684f82e0009398e49660a85badf2e78103
Author: Jörg Rade <jo...@kuehne-nagel.com>
AuthorDate: Wed Jun 16 19:12:13 2021 +0200

    ISIS-2505 LinkTreeDiagram/LogEntryDecorator added as debugging aid; EventLogDetail amended
---
 .../isis/client/kroviz/core/event/EventStore.kt    |  12 ++
 .../isis/client/kroviz/core/event/LogEntry.kt      |  34 +++--
 .../client/kroviz/core/event/LogEntryDecorator.kt  | 160 +++++++++++++++++++++
 .../apache/isis/client/kroviz/ui/core/Constants.kt |   1 +
 .../client/kroviz/ui/diagram/LinkTreeDiagram.kt    |  45 ++++++
 .../client/kroviz/ui/diagram/SequenceDiagram.kt    |  66 ---------
 .../isis/client/kroviz/ui/dialog/EventLogDetail.kt |  11 ++
 .../client/kroviz/ui/panel/EventLogTableMgr.kt     |  14 +-
 ...quenceDiagramTest.kt => LinkTreeDiagramTest.kt} |  61 ++------
 9 files changed, 270 insertions(+), 134 deletions(-)

diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/EventStore.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/EventStore.kt
index 89ea050..768039f 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/EventStore.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/EventStore.kt
@@ -22,6 +22,7 @@ import io.kvision.panel.SimplePanel
 import io.kvision.state.observableListOf
 import org.apache.isis.client.kroviz.core.aggregator.BaseAggregator
 import org.apache.isis.client.kroviz.core.aggregator.SvgDispatcher
+import org.apache.isis.client.kroviz.to.HasLinks
 import org.apache.isis.client.kroviz.to.TObject
 import org.apache.isis.client.kroviz.to.mb.Menubars
 import org.apache.isis.client.kroviz.ui.core.UiManager
@@ -199,4 +200,15 @@ object EventStore {
         log.removeAll(log)
     }
 
+
+    fun getLinked(): List<LogEntry> {
+        // we use all LE's - eventually to be refined to a single LE (chain up and down)
+        val linked = mutableListOf<LogEntry>()
+        log.forEach {
+            if (it.obj is HasLinks) linked.add(it)
+        }
+        return linked
+    }
+
+
 }
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntry.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntry.kt
index 206ad37..8dadcc2 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntry.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntry.kt
@@ -25,16 +25,17 @@ import kotlinx.serialization.Serializable
 import org.apache.isis.client.kroviz.core.aggregator.ActionDispatcher
 import org.apache.isis.client.kroviz.core.aggregator.BaseAggregator
 import org.apache.isis.client.kroviz.core.aggregator.CollectionAggregator
+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.to.TransferObject
 import org.apache.isis.client.kroviz.ui.core.Constants
-import org.apache.isis.client.kroviz.ui.core.UiManager
-import org.apache.isis.client.kroviz.utils.Utils.removeHexCode
 import kotlin.js.Date
 
 // use color codes from css instead?
 enum class EventState(val id: String, val iconName: String, val style: ButtonStyle) {
     INITIAL("INITIAL", "fas fa-power-off", ButtonStyle.LIGHT),
-    RUNNING("RUNNING", "fas fa-hourglass-start fa-rotate-90", ButtonStyle.WARNING),
+    RUNNING("RUNNING", "fas fa-hourglass-start", ButtonStyle.WARNING),
     ERROR("ERROR", "fas fa-exclamation-circle", ButtonStyle.DANGER),
     SUCCESS_JS("SUCCESS_JS", "fab fa-js", ButtonStyle.SUCCESS),
     SUCCESS_XML("SUCCESS_XML", "fas fa-code", ButtonStyle.SUCCESS),
@@ -67,7 +68,7 @@ data class LogEntry(
         state = EventState.RUNNING
         title = url // stripHostPort(url)
         requestLength = request?.length
-                ?: 0 // if this is simplyfied to request.length, Tabulator.js goes in ERROR and EventLogTable shows no entries
+                ?: 0 // ?. is required, otherwise Tabulator.js/EventLogTable shows no entries
     }
 
     @Contextual
@@ -177,17 +178,6 @@ data class LogEntry(
 
     //end region response
 
-    private fun stripHostPort(url: String): String {
-        var result = url
-        val signature = "restful/"
-        if (url.contains(signature)) {
-            val protocolHostPort = UiManager.getUrl()
-            result = result.replace(protocolHostPort + signature, "")
-            result = removeHexCode(result)
-        }
-        return result
-    }
-
     fun isView(): Boolean {
         return isOpenView() || isClosedView()
     }
@@ -221,4 +211,18 @@ data class LogEntry(
         return url == reSpec.url && subType.equals(reSpec.subType)
     }
 
+    fun selfHref(): String {
+        return selfLink().href
+    }
+
+    fun selfLink(): Link {
+        return getLinks().first { it.relation() == Relation.SELF }
+    }
+
+    fun getLinks(): List<Link> {
+        return (obj as HasLinks).getLinks()
+    }
+
+
+
 }
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntryDecorator.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntryDecorator.kt
new file mode 100644
index 0000000..2f696d9
--- /dev/null
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/core/event/LogEntryDecorator.kt
@@ -0,0 +1,160 @@
+/*
+ *  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.core.event
+
+import org.apache.isis.client.kroviz.to.Link
+import org.apache.isis.client.kroviz.to.Relation
+import org.apache.isis.client.kroviz.ui.core.Constants
+import org.apache.isis.client.kroviz.utils.Utils
+
+class LogEntryDecorator(val logEntry: LogEntry) {
+
+    val href: String
+    val links: List<Link>
+    val linked: List<LogEntry>
+
+    init {
+        href = logEntry.selfHref()
+        links = logEntry.getLinks()
+        linked = EventStore.getLinked()
+    }
+
+    fun findOrphans(children: Set<LogEntry>): Set<String> {
+        console.log("[LED.findOrphans] $href")
+        val kids = children.map { it.url }
+        val orphans = mutableSetOf<String>()
+        links.forEach {
+            console.log(it)
+            val rel = it.relation()
+            when {
+                (rel == Relation.UP) -> {
+                }
+                (rel == Relation.SELF) -> {
+                }
+                else -> {
+                    val url = it.href
+                    if (!kids.contains(url))
+                        orphans.add(url)
+                }
+            }
+        }
+        return orphans
+    }
+
+    fun findChildren(): Set<LogEntry> {
+        val children = findChildrenByUpRelation()
+        children.plus(findChildrenByReference())
+        children.plus(findChildrenByLinks())
+        return children
+    }
+
+    private fun findChildrenByUpRelation(): Set<LogEntry> {
+        val children = mutableSetOf<LogEntry>()
+        linked.forEach {
+            it.getLinks().forEach { l ->
+                if ((l.relation() == Relation.UP) && (l.href == href)) {
+                    children.add(it)
+                }
+            }
+        }
+        return children
+    }
+
+    private fun findChildrenByLinks(): Set<LogEntry> {
+        console.log("[LED.findChildrenByLinks] $href")
+        val children = mutableSetOf<LogEntry>()
+        links.forEach {
+            console.log(it)
+            val rel = it.relation()
+            when {
+                (rel == Relation.UP) -> {
+                }
+                (rel == Relation.SELF) -> {
+                }
+                else -> {
+                    val rsj = ResourceSpecification(it.href, Constants.subTypeJson)
+                    var le = EventStore.findBy(rsj)
+                    if (le == null) {
+                        val rsx = ResourceSpecification(it.href, Constants.subTypeXml)
+                        le = EventStore.findBy(rsx)
+                    }
+                    console.log(le)
+                    if (le != null) children.add(le)
+                }
+            }
+        }
+        return children
+    }
+
+    private fun findChildrenByReference(): Set<LogEntry> {
+        val str = logEntry.response
+        console.log("[LED.findChildrenByReference]")
+        val children = mutableSetOf<LogEntry>()
+        linked.forEach {
+            if (it != logEntry && str.contains(it.url)) {
+                console.log(it.url)
+                children.add(it)
+            }
+        }
+        return children
+    }
+
+    fun selfType(): String {
+        return logEntry.selfLink().representation().type
+    }
+
+    private fun hasUp(): Boolean {
+        links.forEach {
+            if (it.relation() == Relation.UP) {
+                return true
+            }
+        }
+        return false
+    }
+
+    fun hasParent(): Boolean {
+        val answer = hasUp()
+        if (answer) return true
+        return findParent() != null
+    }
+
+    private fun findParent(): LogEntry? {
+        val url = logEntry.url
+        linked.forEach {
+            when {
+                it.selfHref() == url -> return null
+                it.response.contains(url) -> return it
+            }
+        }
+        return null
+    }
+
+    fun shortTitle(): String {
+        var result = logEntry.url
+        val signature = Constants.restInfix
+        if (logEntry.url.contains(signature)) {
+            // strip off protocol, host, port
+            //           val protocolHostPort = UiManager.getUrl()
+//            result = result.replace(protocolHostPort + signature, "")
+            result = Utils.removeHexCode(result)
+        }
+        return result
+    }
+
+}
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/Constants.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/Constants.kt
index 8cb4e8c..2165c4a 100644
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/Constants.kt
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/core/Constants.kt
@@ -20,6 +20,7 @@ package org.apache.isis.client.kroviz.ui.core
 
 object Constants {
 
+    const val restInfix = "restful/"
     const val stdMimeType = "text/plain"
     const val svgMimeType = "image/svg+xml"
     const val xmlMimeType = "application/xml"
diff --git a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LinkTreeDiagram.kt b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LinkTreeDiagram.kt
new file mode 100644
index 0000000..d49321c
--- /dev/null
+++ b/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/LinkTreeDiagram.kt
@@ -0,0 +1,45 @@
+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.LogEntryDecorator
+
+object LinkTreeDiagram {
+
+    private val NL = "\n"
+    private val SEP = " | "
+    private val OPEN = "{"
+    private val CLOSE = "}"
+    private val PLUS = "+"
+
+    fun build(): String {
+        var code = "@startsalt$NL$OPEN$NL$OPEN T#$NL"
+        val roots: List<LogEntry> = findRoots()
+        roots.forEach {
+            code += iterateOverChildren(it, PLUS)
+        }
+        code += "$CLOSE$NL$CLOSE$NL@endsalt"
+        return code
+    }
+
+    private fun findRoots(): List<LogEntry> {
+        val rootSet = mutableListOf<LogEntry>()
+        EventStore.getLinked().forEach { le ->
+            val led = LogEntryDecorator(le)
+            if (!led.hasParent()) rootSet.add(le)  // this may still include
+        }
+        return rootSet
+    }
+
+    private fun iterateOverChildren(logEntry: LogEntry, prefix: String): String {
+        val led = LogEntryDecorator(logEntry)
+        val children = led.findChildren()
+        val orphans = led.findOrphans(children)
+        var code = prefix + " " + led.shortTitle() + SEP + led.selfType() + SEP + orphans.toString() + NL
+        children.forEach {
+            code += iterateOverChildren(it, prefix + PLUS)
+        }
+        return code
+    }
+
+}
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
deleted file mode 100644
index 167c54f..0000000
--- a/incubator/clients/kroviz/src/main/kotlin/org/apache/isis/client/kroviz/ui/diagram/SequenceDiagram.kt
+++ /dev/null
@@ -1,66 +0,0 @@
-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.findBy(rs)
-        if (childLE != null) {
-            code += iterateOverChildren(childLE)
-        }
-        return code
-    }
-
-}
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 3a1ccc9..a4098ce 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
@@ -21,6 +21,7 @@ package org.apache.isis.client.kroviz.ui.dialog
 import org.apache.isis.client.kroviz.core.aggregator.CollectionAggregator
 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.LogEntryDecorator
 import org.apache.isis.client.kroviz.core.event.ResourceSpecification
 import org.apache.isis.client.kroviz.to.ValueType
 import org.apache.isis.client.kroviz.to.bs3.Grid
@@ -34,6 +35,7 @@ import org.apache.isis.client.kroviz.utils.XmlHelper
 
 class EventLogDetail(val logEntryFromTabulator: LogEntry) : Command() {
     private var logEntry: LogEntry
+
     init {
         // For a yet unknown reason, aggregators are not transmitted via tabulator.
         // As a WORKAROUND, we fetch the full blown LogEntry from the EventStore again.
@@ -52,10 +54,18 @@ class EventLogDetail(val logEntryFromTabulator: LogEntry) : Command() {
             XmlHelper.format(logEntry.response)
         }
 
+        val led = LogEntryDecorator(logEntry)
+        val children = led.findChildren()
+        var kids:String = ""
+        children.forEach { kids += it.url + "\n" }
+        var orphans = ""
+        led.findOrphans(children).forEach { orphans += it + "\n" }
         val formItems = mutableListOf<FormItem>()
         formItems.add(FormItem("Url", ValueType.TEXT, logEntry.title))
         formItems.add(FormItem("Response", ValueType.TEXT_AREA, responseStr, 10))
         formItems.add(FormItem("Aggregators", ValueType.TEXT, content = logEntry.aggregators))
+        formItems.add(FormItem("Children", ValueType.TEXT_AREA, kids, size = 5))
+        formItems.add(FormItem("Orphans", ValueType.TEXT_AREA, orphans, size = 5))
         formItems.add(FormItem("Object Diagram", ValueType.BUTTON, null, callBack = this, callBackAction = OBJ))
         formItems.add(FormItem("Console", ValueType.BUTTON, null, callBack = this, callBackAction = LOG))
 
@@ -88,6 +98,7 @@ class EventLogDetail(val logEntryFromTabulator: LogEntry) : Command() {
             console.log(it)
             if (it is CollectionAggregator) {
                 val displayModel = it.dpm
+                // https://github.com/moll/json-stringify-safe/blob/master/stringify.js
                 val jsonStr = JSON.stringify(displayModel)
                 console.log(jsonStr)
                 val pumlCode = JsonDiagram.build(jsonStr)
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 abc6f31..3ce35f4 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
@@ -23,7 +23,7 @@ import io.kvision.utils.obj
 import org.apache.isis.client.kroviz.core.event.EventStore
 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.ui.diagram.LinkTreeDiagram
 import org.apache.isis.client.kroviz.ui.dialog.DiagramDialog
 import org.apache.isis.client.kroviz.ui.dialog.EventExportDialog
 import org.apache.isis.client.kroviz.utils.IconManager
@@ -33,8 +33,8 @@ class EventLogTableMgr {
     fun buildTableMenu(table: EventLogTable): dynamic {
         val menu = mutableListOf<dynamic>()
 
-        val a1 = buildMenuEntry("Hierarchy", "Event Diagram",
-                { this.eventDiagram() })
+        val a1 = buildMenuEntry("Hierarchy", "Link Tree Diagram",
+                { this.linkTreeDiagram() })
         menu.add(a1)
 
         val a2 = buildMenuEntry("Export", "Export Events ...", {
@@ -65,9 +65,11 @@ class EventLogTableMgr {
         }
     }
 
-    private fun eventDiagram() {
-        val code = SequenceDiagram.build(EventStore.log)!!
-        DiagramDialog("Event Diagram", code).open()
+    private fun linkTreeDiagram() {
+        val code = LinkTreeDiagram.build()
+        console.log("[ETM.eventDiagrm]")
+        console.log(code)
+        DiagramDialog("Link Tree Diagram", code).open()
     }
 
     private fun downLoadCsv(table: EventLogTable) {
diff --git a/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/table/SequenceDiagramTest.kt b/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/table/LinkTreeDiagramTest.kt
similarity index 57%
rename from incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/table/SequenceDiagramTest.kt
rename to incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/table/LinkTreeDiagramTest.kt
index 021ceea..e0b457e 100644
--- a/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/table/SequenceDiagramTest.kt
+++ b/incubator/clients/kroviz/src/test/kotlin/org/apache/isis/client/kroviz/ui/table/LinkTreeDiagramTest.kt
@@ -20,75 +20,42 @@
 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
 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.Method
-import org.apache.isis.client.kroviz.ui.core.UiManager
-import org.apache.isis.client.kroviz.ui.diagram.SequenceDiagram
+import org.apache.isis.client.kroviz.ui.diagram.LinkTreeDiagram
 import kotlin.test.*
 
-class SequenceDiagramTest {
-
-    @BeforeTest
-    fun setup() {
-        val user = "sven"
-        val pw = "pass"
-        val url = "http://${user}:${pw}@localhost:8080/restful/"
-        UiManager.login(url, user, pw)
-    }
-
-    //@Test   //TODO IntegrationTest ?
-    fun testSequenceDiagram() {
-        //given
-        val rootLe = fillEventStoreWith(RESTFUL)
-        fillEventStoreWith(RESTFUL_SERVICES)
-        fillEventStoreWith(RESTFUL_MENUBARS)
-        //when
-        val actual = SequenceDiagram.with(rootLe)
-        //then
-        assertEquals(3, EventStore.log.size)
-        console.log("[PBT.testSequenceDiagram]")
-        console.log(actual)
-        assertTrue(actual.startsWith("\"@startuml"))
-        assertTrue(actual.endsWith("@enduml\""))
-        assertTrue(actual.contains("-> restful_services"))
-    }
-
-    private fun fillEventStoreWith(r: Response): LogEntry {
-        val rs = ResourceSpecification(r.url)
-        EventStore.start(rs, Method.GET.operation)
-        val logEntry = EventStore.end(rs, r.str)!!
-        ResponseHandler.handle(logEntry)
-        return logEntry
-    }
+class LinkTreeDiagramTest {
 
     @Test
-    fun testEventDiagram() {
-        //given
+    fun testLinkTreeDiagram() {
+        //when
         load(RESTFUL, RestfulHandler())
         load(RESTFUL_SERVICES, ServiceHandler())
         load(RESTFUL_USER, UserHandler())
         load(RESTFUL_MENUBARS, MenuBarsHandler())
         load(RESTFUL_VERSION, VersionHandler())
         load(RESTFUL_DOMAIN_TYPES, DomainTypesHandler())
-
+        // then
+        assertTrue(EventStore.log.size >= 6)
         val rootRs = ResourceSpecification(RESTFUL.url)
-
-        // when
         val rootLogEntry = EventStore.findBy(rootRs)
-        // then
         assertNotNull(rootLogEntry)  //1
 
         // when
-        val code = SequenceDiagram.with(rootLogEntry)
+        val code = LinkTreeDiagram.build().trim()
         // then
-        console.log("[PumlBuilderTest.testEventDiagram]")
+        console.log("[LTDT.testLinkTreeDiagram]")
         console.log(code)
-        val wrong = "@startuml\n@enduml"
-        assertNotEquals(wrong, code)
+        assertTrue(code.startsWith("@startsalt"))
+        assertTrue(code.endsWith("@endsalt"))
+        assertTrue(code.contains("+ /http://localhost:8080/restful/"))
+        assertTrue(code.contains("++ /http://localhost:8080/restful/version"))
+        //menuBars json doesn't have UP nor SELF nor a reference to it's parent
+//        assertTrue(code.contains("++ /http://localhost:8080/restful/menuBars"))
     }
 
     private fun load(response: Response, handler: BaseHandler) {