Skip to content

Commit

Permalink
Extend tests for external software systems
Browse files Browse the repository at this point in the history
  • Loading branch information
jp7677 committed Oct 29, 2023
1 parent 0c9d82b commit 2f1612d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")

Expand All @@ -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 {
Expand All @@ -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")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,23 @@ 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)

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))
}
}

0 comments on commit 2f1612d

Please sign in to comment.