Search in sources :

Example 1 with SystemLandscapeView

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;
}
Also used : SystemLandscapeView(com.structurizr.view.SystemLandscapeView) Workspace(com.structurizr.Workspace)

Example 2 with SystemLandscapeView

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());
    }
}
Also used : SystemLandscapeView(com.structurizr.view.SystemLandscapeView) Test(org.junit.jupiter.api.Test)

Example 3 with SystemLandscapeView

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());
    }
}
Also used : SystemLandscapeView(com.structurizr.view.SystemLandscapeView) Test(org.junit.jupiter.api.Test)

Example 4 with SystemLandscapeView

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());
}
Also used : SystemLandscapeView(com.structurizr.view.SystemLandscapeView) Test(org.junit.jupiter.api.Test)

Example 5 with SystemLandscapeView

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());
}
Also used : com.structurizr.model(com.structurizr.model) Test(org.junit.jupiter.api.Test) ComponentView(com.structurizr.view.ComponentView) Assertions(org.junit.jupiter.api.Assertions) SystemContextView(com.structurizr.view.SystemContextView) SystemLandscapeView(com.structurizr.view.SystemLandscapeView) SystemLandscapeView(com.structurizr.view.SystemLandscapeView) Test(org.junit.jupiter.api.Test)

Aggregations

SystemLandscapeView (com.structurizr.view.SystemLandscapeView)46 Test (org.junit.jupiter.api.Test)43 ComponentView (com.structurizr.view.ComponentView)4 SystemContextView (com.structurizr.view.SystemContextView)4 com.structurizr.model (com.structurizr.model)3 Assertions (org.junit.jupiter.api.Assertions)3 Workspace (com.structurizr.Workspace)2 DeploymentView (com.structurizr.view.DeploymentView)2 StructurizrDslParser (com.structurizr.dsl.StructurizrDslParser)1 StructurizrDslParserException (com.structurizr.dsl.StructurizrDslParserException)1 Diagram (com.structurizr.export.Diagram)1 StructurizrPlantUMLExporter (com.structurizr.export.plantuml.StructurizrPlantUMLExporter)1 Container (com.structurizr.model.Container)1 DeploymentNode (com.structurizr.model.DeploymentNode)1 Enterprise (com.structurizr.model.Enterprise)1 Model (com.structurizr.model.Model)1 Person (com.structurizr.model.Person)1 SoftwareSystem (com.structurizr.model.SoftwareSystem)1 ContainerView (com.structurizr.view.ContainerView)1 DynamicView (com.structurizr.view.DynamicView)1