Skip to content

Commit

Permalink
#236 return default value Unspecified for the C4Location
Browse files Browse the repository at this point in the history
  • Loading branch information
klu2 committed Aug 4, 2024
1 parent f69a44f commit c64e1a0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var SoftwareSystem.c4Location: Location
/**
* Returns the [Location] of the SoftwareSystem.
*/
get() = Location.valueOf(this.properties.getValue(LOCATION_PROPERTY))
get() = Location.valueOf(this.properties.getOrDefault(LOCATION_PROPERTY, Location.Unspecified.name))

/**
* Sets the [Location] of the SoftwareSystem.
Expand All @@ -24,7 +24,7 @@ var Container.c4Location: Location
/**
* Returns the [Location] of the container.
*/
get() = Location.valueOf(this.properties.getValue(LOCATION_PROPERTY))
get() = Location.valueOf(this.properties.getOrDefault(LOCATION_PROPERTY, Location.Unspecified.name))

/**
* Sets the [Location] of the container.
Expand All @@ -37,7 +37,7 @@ var Person.c4Location: Location
/**
* Returns the [Location] of the Component.
*/
get() = Location.valueOf(this.properties.getValue(LOCATION_PROPERTY))
get() = Location.valueOf(this.properties.getOrDefault(LOCATION_PROPERTY, Location.Unspecified.name))

/**
* Sets the [Location] of the Component.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.github.chriskn.structurizrextension.view

import com.github.chriskn.structurizrextension.api.writeDiagrams
import com.structurizr.Workspace
import com.structurizr.model.Model
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import java.io.File

/**
* Tests the combination of models created directly from Structurizr and models created with the extension. This
* is especially required as the Location has been removed from the Structurizr API and is now part of the extension.
*
* @see https://github.com/chriskn/structurizr-c4puml-extension/issues/236
*/
class StructurizrCompatibilityTest {

private lateinit var workspace: Workspace
private lateinit var model: Model

@BeforeEach
fun setUp() {
workspace = Workspace("", "")
model = workspace.model
}

@Test
fun `addPerson can be called directly on the Structurizr Methods`() {
model.addPerson("Person 1", "Description")
workspace.views.createSystemLandscapeView("SystemLandscape", "Description").addAllElements()
workspace.writeDiagrams(File("build/structurizr"))
}

@Test
fun `addSoftwareSystem can be called directly on the Structurizr Methods`() {
model.addSoftwareSystem("Software System")
workspace.views.createSystemLandscapeView("SystemLandscape", "Description").addAllElements()
workspace.writeDiagrams(File("build/structurizr"))
}

@Test
fun `addContainer can be called directly on the Structurizr Methods`() {
val softwareSystem = model.addSoftwareSystem("Software System")
softwareSystem.addContainer("Container")
workspace.views.createContainerView(softwareSystem, "Container", "Container").addAllElements()
workspace.writeDiagrams(File("build/structurizr"))
}
}

0 comments on commit c64e1a0

Please sign in to comment.