use of com.structurizr.view.SystemLandscapeView in project dsl by structurizr.
the class SystemLandscapeViewParser method parse.
SystemLandscapeView parse(DslContext context, Tokens tokens) {
if (tokens.hasMoreThan(DESCRIPTION_INDEX)) {
throw new RuntimeException("Too many tokens, expected: " + GRAMMAR);
}
Workspace workspace = context.getWorkspace();
String key = "";
String description = "";
if (tokens.includes(KEY_INDEX)) {
key = tokens.get(KEY_INDEX);
} else {
key = VIEW_TYPE;
}
validateViewKey(key);
if (tokens.includes(DESCRIPTION_INDEX)) {
description = tokens.get(DESCRIPTION_INDEX);
}
SystemLandscapeView view = workspace.getViews().createSystemLandscapeView(key, description);
view.setEnterpriseBoundaryVisible(true);
return view;
}
use of com.structurizr.view.SystemLandscapeView in project dsl by structurizr.
the class AutoLayoutParserTests method test_parse_ThrowsAnException_WhenAnInvalidRankSeparationIsSpecified.
@Test
void test_parse_ThrowsAnException_WhenAnInvalidRankSeparationIsSpecified() {
SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "description");
SystemLandscapeViewDslContext context = new SystemLandscapeViewDslContext(view);
context.setWorkspace(workspace);
try {
parser.parse(context, tokens("autoLayout", "tb", "hello"));
fail();
} catch (Exception e) {
assertEquals("Rank separation must be positive integer in pixels", e.getMessage());
}
}
use of com.structurizr.view.SystemLandscapeView in project dsl by structurizr.
the class AutoLayoutParserTests method test_parse_ThrowsAnException_WhenAnInvalidNodeSeparationIsSpecified.
@Test
void test_parse_ThrowsAnException_WhenAnInvalidNodeSeparationIsSpecified() {
SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "description");
SystemLandscapeViewDslContext context = new SystemLandscapeViewDslContext(view);
context.setWorkspace(workspace);
try {
parser.parse(context, tokens("autoLayout", "tb", "300", "hello"));
fail();
} catch (Exception e) {
assertEquals("Node separation must be positive integer in pixels", e.getMessage());
}
}
use of com.structurizr.view.SystemLandscapeView in project dsl by structurizr.
the class AutoLayoutParserTests method test_parse_EnablesAutoLayoutWithAValidRankSeparation.
@Test
void test_parse_EnablesAutoLayoutWithAValidRankSeparation() {
SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "description");
SystemLandscapeViewDslContext context = new SystemLandscapeViewDslContext(view);
context.setWorkspace(workspace);
assertNull(view.getAutomaticLayout());
parser.parse(context, tokens("autoLayout", "tb", "123"));
assertEquals(AutomaticLayout.Implementation.Graphviz, view.getAutomaticLayout().getImplementation());
assertEquals(AutomaticLayout.RankDirection.TopBottom, view.getAutomaticLayout().getRankDirection());
assertEquals(123, view.getAutomaticLayout().getRankSeparation());
assertEquals(300, view.getAutomaticLayout().getNodeSeparation());
}
use of com.structurizr.view.SystemLandscapeView in project dsl by structurizr.
the class StaticViewContentParserTests method test_parseInclude_AddsTheSpecifiedElementsToASystemLandscapeView.
@Test
void test_parseInclude_AddsTheSpecifiedElementsToASystemLandscapeView() {
Person user = model.addPerson("User", "Description");
SoftwareSystem softwareSystem1 = model.addSoftwareSystem("Software System 1", "Description");
SoftwareSystem softwareSystem2 = model.addSoftwareSystem("Software System 2", "Description");
user.uses(softwareSystem1, "Uses");
softwareSystem1.uses(softwareSystem2, "Uses");
CustomElement box1 = model.addCustomElement("Box 1");
box1.uses(softwareSystem1, "");
SystemLandscapeView view = views.createSystemLandscapeView("key", "Description");
SystemLandscapeViewDslContext context = new SystemLandscapeViewDslContext(view);
context.setWorkspace(workspace);
IdentifiersRegister elements = new IdentifiersRegister();
elements.register("user", user);
elements.register("softwaresystem1", softwareSystem1);
elements.register("softwaresystem2", softwareSystem2);
elements.register("box1", box1);
context.setIdentifierRegister(elements);
parser.parseInclude(context, tokens("include", "user", "softwareSystem1", "box1"));
assertEquals(3, view.getElements().size());
assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(user)));
assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(softwareSystem1)));
assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(box1)));
assertTrue(view.getElements().stream().noneMatch(ev -> ev.getElement().equals(softwareSystem2)));
assertEquals(2, view.getRelationships().size());
}
Aggregations