Skip to content

Commit d76d18c

Browse files
Fixes #435.
1 parent d8467b3 commit d76d18c

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
- structurizr-dsl: Adds a `Shell` shape.
99
- structurizr-dsl: Adds a `Terminal` shape.
1010
- structurizr-dsl: Adds an 'instanceOf' keyword (an alternative for `softwareSystemInstance` and `containerInstance`).
11+
- structurizr-dsl: Relationships to/from software system/container instances can be now defined by using the software system/container identifier.
12+
- structurizr-dsl: Fixes https://github.com/structurizr/java/issues/435 (Relationship archetype not applied to implicit-source relationships).
1113

1214
## v4.1.0 (28th May 2025)
1315

structurizr-dsl/src/main/java/com/structurizr/dsl/StructurizrDslParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ void parse(List<String> lines, File dslFile, boolean fragment, boolean includeIn
345345
} else if (tokens.size() >= 2 && isRelationshipKeywordOrArchetype(tokens.get(0)) && inContext(ElementDslContext.class)) {
346346
// implicit without archetype: -> this
347347
// implicit with archetype: --https-> this
348-
Archetype archetype = getArchetype(RELATIONSHIP_TOKEN, tokens.get(1));
348+
Archetype archetype = getArchetype(RELATIONSHIP_TOKEN, tokens.get(0));
349349
Set<Relationship> relationships = new ImplicitRelationshipParser().parse(getContext(ElementDslContext.class), tokens.withoutContextStartToken(), archetype);
350350

351351
if (relationships.size() == 1) {

structurizr-dsl/src/test/java/com/structurizr/dsl/DslTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,22 @@ void test_archetypesForExtension() throws Exception {
15631563
assertTrue(r.hasTag("HTTPS"));
15641564
}
15651565

1566+
@Test
1567+
void test_archetypesForImplicitRelationships() throws Exception {
1568+
File parentDslFile = new File("src/test/resources/dsl/archetypes-for-implicit-relationships.dsl");
1569+
StructurizrDslParser parser = new StructurizrDslParser();
1570+
parser.parse(parentDslFile);
1571+
Workspace workspace = parser.getWorkspace();
1572+
1573+
SoftwareSystem a = workspace.getModel().getSoftwareSystemWithName("A");
1574+
SoftwareSystem b = workspace.getModel().getSoftwareSystemWithName("B");
1575+
1576+
Relationship r = b.getEfferentRelationshipWith(a);
1577+
assertEquals("Makes API calls to", r.getDescription());
1578+
assertEquals("HTTPS", r.getTechnology());
1579+
assertTrue(r.hasTag("HTTPS"));
1580+
}
1581+
15661582
@Test
15671583
void test_textBlock() throws Exception {
15681584
StructurizrDslParser parser = new StructurizrDslParser();
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
workspace {
2+
model {
3+
archetypes {
4+
https = -> {
5+
technology "HTTPS"
6+
tag "HTTPS"
7+
}
8+
}
9+
10+
a = softwareSystem "A"
11+
b = softwareSystem "B" {
12+
--https-> a "Makes API calls to"
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)