From 2f1612d4ebc8319d9e753ea4f3da372f9fdeef07 Mon Sep 17 00:00:00 2001 From: Jens Peters Date: Sun, 29 Oct 2023 08:31:20 +0100 Subject: [PATCH] Extend tests for external software systems --- .../generatr/site/model/MenuViewModelTest.kt | 39 +++++++++---------- ...wareSystemDependenciesPageViewModelTest.kt | 16 +++++++- .../model/SoftwareSystemsPageViewModelTest.kt | 13 ++++++- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/MenuViewModelTest.kt b/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/MenuViewModelTest.kt index a41be598..e4821a99 100644 --- a/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/MenuViewModelTest.kt +++ b/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/MenuViewModelTest.kt @@ -136,7 +136,7 @@ class MenuViewModelTest : ViewModelTest() { } @Test - fun `do not show menu entries for software systems with an external location`() { + fun `do not show menu entries for software systems with an external location (outside enterprise boundary)`() { val generatorContext = generatorContext(branches = listOf("main", "branch-2"), currentBranch = "main") generatorContext.workspace.model.addSoftwareSystem(Location.External, "System 1", "") @@ -147,10 +147,10 @@ class MenuViewModelTest : ViewModelTest() { } @Test - fun `show software systems from single group in software systems list`() { + fun `do not show menu entries for software systems with an external location (outside of any group when using groups)`() { val generatorContext = generatorContext(branches = listOf("main", "branch-2"), currentBranch = "main") - generatorContext.workspace.views.configuration.addProperty("generatr.site.nestGroups", "true") - generatorContext.workspace.model.addSoftwareSystem("System 1").group = "Group 1" + generatorContext.workspace.model.addSoftwareSystem("System 1").apply { group = "Group 1" } + generatorContext.workspace.model.addSoftwareSystem("External system") MenuViewModel(generatorContext, createPageViewModel(generatorContext, url = HomePageViewModel.url())) .let { @@ -162,38 +162,37 @@ class MenuViewModelTest : ViewModelTest() { } @Test - fun `show nested groups in software systems list`() { + fun `show software systems in nested groups from single group in software systems list`() { val generatorContext = generatorContext(branches = listOf("main", "branch-2"), currentBranch = "main") generatorContext.workspace.views.configuration.addProperty("generatr.site.nestGroups", "true") - generatorContext.workspace.model.addProperty("structurizr.groupSeparator", "/") - generatorContext.workspace.model.addSoftwareSystem("System 1").group = "Group 1" - generatorContext.workspace.model.addSoftwareSystem("System 2").group = "Group 1" - generatorContext.workspace.model.addSoftwareSystem("System 3").group = "Group 2" - generatorContext.workspace.model.addSoftwareSystem("System 4").group = "Group 1/Group 3" + generatorContext.workspace.model.addSoftwareSystem("System 1").apply { group = "Group 1" } MenuViewModel(generatorContext, createPageViewModel(generatorContext, url = HomePageViewModel.url())) .let { - assertThat(it.softwareSystemNodes().children).hasSize(2) + assertThat(it.softwareSystemNodes().children).hasSize(1) assertThat(it.softwareSystemNodes().children[0].name).isEqualTo("Group 1") - assertThat(it.softwareSystemNodes().children[0].children).hasSize(3) - assertThat(it.softwareSystemNodes().children[0].children[0].name).isEqualTo("Group 3") - assertThat(it.softwareSystemNodes().children[0].children[0].children[0].name).isEqualTo("System 4") + assertThat(it.softwareSystemNodes().children[0].children).hasSize(1) + assertThat(it.softwareSystemNodes().children[0].children[0].name).isEqualTo("System 1") } } @Test - fun `do not show menu items of software systems outside of groups when groups are used`() { + fun `show nested groups in software systems list`() { val generatorContext = generatorContext(branches = listOf("main", "branch-2"), currentBranch = "main") generatorContext.workspace.views.configuration.addProperty("generatr.site.nestGroups", "true") - generatorContext.workspace.model.addSoftwareSystem("System 1").group = "Group 1" - generatorContext.workspace.model.addSoftwareSystem("External system") + generatorContext.workspace.model.addProperty("structurizr.groupSeparator", "/") + generatorContext.workspace.model.addSoftwareSystem("System 1").apply { group = "Group 1" } + generatorContext.workspace.model.addSoftwareSystem("System 2").apply { group = "Group 1" } + generatorContext.workspace.model.addSoftwareSystem("System 3").apply { group = "Group 2" } + generatorContext.workspace.model.addSoftwareSystem("System 4").apply { group = "Group 1/Group 3" } MenuViewModel(generatorContext, createPageViewModel(generatorContext, url = HomePageViewModel.url())) .let { - assertThat(it.softwareSystemNodes().children).hasSize(1) + assertThat(it.softwareSystemNodes().children).hasSize(2) assertThat(it.softwareSystemNodes().children[0].name).isEqualTo("Group 1") - assertThat(it.softwareSystemNodes().children[0].children).hasSize(1) - assertThat(it.softwareSystemNodes().children[0].children[0].name).isEqualTo("System 1") + assertThat(it.softwareSystemNodes().children[0].children).hasSize(3) + assertThat(it.softwareSystemNodes().children[0].children[0].name).isEqualTo("Group 3") + assertThat(it.softwareSystemNodes().children[0].children[0].children[0].name).isEqualTo("System 4") } } diff --git a/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/SoftwareSystemDependenciesPageViewModelTest.kt b/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/SoftwareSystemDependenciesPageViewModelTest.kt index b2a6a128..9641fbfc 100644 --- a/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/SoftwareSystemDependenciesPageViewModelTest.kt +++ b/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/SoftwareSystemDependenciesPageViewModelTest.kt @@ -90,7 +90,7 @@ class SoftwareSystemDependenciesPageViewModelTest : ViewModelTest() { } @Test - fun `dependencies from and to external systems`() { + fun `dependencies from and to external systems (outside enterprise boundary)`() { val externalSystem = generatorContext.workspace.model .addSoftwareSystem(Location.External, "External system", "") externalSystem.uses(softwareSystem1, "Uses", "REST") @@ -103,6 +103,20 @@ class SoftwareSystemDependenciesPageViewModelTest : ViewModelTest() { .isEqualTo(TableViewModel.TextCellViewModel("External system (External)", isHeader = true, greyText = true)) } + @Test + fun `dependencies from and to external systems (outside of any group when using groups)`() { + softwareSystem1.group = "Group 1" + val externalSystem = generatorContext.workspace.model.addSoftwareSystem("External system") + externalSystem.uses(softwareSystem1, "Uses", "REST") + softwareSystem1.uses(externalSystem, "Uses", "REST") + + val viewModel = SoftwareSystemDependenciesPageViewModel(generatorContext, softwareSystem1) + assertThat(viewModel.dependenciesInboundTable.bodyRows[0].columns[0]) + .isEqualTo(TableViewModel.TextCellViewModel("External system (External)", isHeader = true, greyText = true)) + assertThat(viewModel.dependenciesOutboundTable.bodyRows[0].columns[0]) + .isEqualTo(TableViewModel.TextCellViewModel("External system (External)", isHeader = true, greyText = true)) + } + @Test fun `sort by source system name case insensitive`() { val system = generatorContext.workspace.model.addSoftwareSystem("Software system 3") diff --git a/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/SoftwareSystemsPageViewModelTest.kt b/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/SoftwareSystemsPageViewModelTest.kt index 598303db..50f75be3 100644 --- a/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/SoftwareSystemsPageViewModelTest.kt +++ b/src/test/kotlin/nl/avisi/structurizr/site/generatr/site/model/SoftwareSystemsPageViewModelTest.kt @@ -69,7 +69,7 @@ class SoftwareSystemsPageViewModelTest : ViewModelTest() { } @Test - fun `external systems have grey text`() { + fun `external systems have grey text (outside enterprise boundary)`() { val generatorContext = generatorContext() generatorContext.workspace.model.addSoftwareSystem(Location.External, "system 1", "System 1 description") val viewModel = SoftwareSystemsPageViewModel(generatorContext) @@ -77,4 +77,15 @@ class SoftwareSystemsPageViewModelTest : ViewModelTest() { assertThat(viewModel.softwareSystemsTable.bodyRows[0].columns[0]) .isEqualTo(TableViewModel.TextCellViewModel("system 1 (External)", isHeader = true, greyText = true)) } + + @Test + fun `external systems have grey text (outside of any group when using groups)`() { + val generatorContext = generatorContext() + generatorContext.workspace.model.addSoftwareSystem("system 1", "System 1 description").apply { group = "Group 1" } + generatorContext.workspace.model.addSoftwareSystem("system 2", "System 2 description") + val viewModel = SoftwareSystemsPageViewModel(generatorContext) + + assertThat(viewModel.softwareSystemsTable.bodyRows[1].columns[0]) + .isEqualTo(TableViewModel.TextCellViewModel("system 2 (External)", isHeader = true, greyText = true)) + } }