Search in sources :

Example 96 with Workspace

use of com.structurizr.Workspace in project dsl by structurizr.

the class DslTests method test_bigbankplc_systemlandscape.

@Test
void test_bigbankplc_systemlandscape() throws Exception {
    StructurizrDslParser parser = new StructurizrDslParser();
    parser.parse(new File("src/test/dsl/big-bank-plc/system-landscape.dsl"));
    Workspace workspace = parser.getWorkspace();
    assertEquals(Location.External, workspace.getModel().getPersonWithName("Personal Banking Customer").getLocation());
    assertEquals(Location.Internal, workspace.getModel().getPersonWithName("Customer Service Staff").getLocation());
    assertEquals(Location.Internal, workspace.getModel().getPersonWithName("Back Office Staff").getLocation());
    assertEquals(7, workspace.getModel().getElements().size());
    assertEquals(3, workspace.getModel().getPeople().size());
    assertEquals(4, workspace.getModel().getSoftwareSystems().size());
    assertEquals(9, workspace.getModel().getRelationships().size());
    assertEquals(1, workspace.getViews().getSystemLandscapeViews().size());
    assertEquals(0, workspace.getViews().getSystemContextViews().size());
    assertEquals(0, workspace.getViews().getContainerViews().size());
    assertEquals(0, workspace.getViews().getComponentViews().size());
    assertEquals(0, workspace.getViews().getDynamicViews().size());
    assertEquals(0, workspace.getViews().getDeploymentViews().size());
    assertEquals(7, workspace.getViews().getSystemLandscapeViews().iterator().next().getElements().size());
    assertEquals(9, workspace.getViews().getSystemLandscapeViews().iterator().next().getRelationships().size());
    assertEquals(4, workspace.getViews().getConfiguration().getStyles().getElements().size());
    assertEquals(0, workspace.getViews().getConfiguration().getStyles().getRelationships().size());
    assertEquals(0, workspace.getViews().getConfiguration().getThemes().length);
}
Also used : File(java.io.File) Workspace(com.structurizr.Workspace) Test(org.junit.jupiter.api.Test)

Example 97 with Workspace

use of com.structurizr.Workspace in project dsl by structurizr.

the class DslTests method test_bigbankplc_internetbankingsystem.

@Test
void test_bigbankplc_internetbankingsystem() throws Exception {
    StructurizrDslParser parser = new StructurizrDslParser();
    parser.parse(new File("src/test/dsl/big-bank-plc/internet-banking-system.dsl"));
    Workspace workspace = parser.getWorkspace();
    assertEquals(Location.External, workspace.getModel().getPersonWithName("Personal Banking Customer").getLocation());
    assertEquals(Location.Internal, workspace.getModel().getPersonWithName("Customer Service Staff").getLocation());
    assertEquals(Location.Internal, workspace.getModel().getPersonWithName("Back Office Staff").getLocation());
    assertEquals(51, workspace.getModel().getElements().size());
    assertEquals(3, workspace.getModel().getPeople().size());
    assertEquals(4, workspace.getModel().getSoftwareSystems().size());
    assertEquals(5, workspace.getModel().getSoftwareSystemWithName("Internet Banking System").getContainers().size());
    assertEquals(6, workspace.getModel().getSoftwareSystemWithName("Internet Banking System").getContainerWithName("API Application").getComponents().size());
    assertEquals(5, workspace.getModel().getDeploymentNodes().size());
    assertEquals(21, workspace.getModel().getElements().stream().filter(e -> e instanceof DeploymentNode).count());
    assertEquals(2, workspace.getModel().getElements().stream().filter(e -> e instanceof SoftwareSystemInstance).count());
    assertEquals(10, workspace.getModel().getElements().stream().filter(e -> e instanceof ContainerInstance).count());
    assertEquals(0, workspace.getModel().getElements().stream().filter(e -> e instanceof InfrastructureNode).count());
    assertEquals(42, workspace.getModel().getRelationships().size());
    assertEquals(0, workspace.getViews().getSystemLandscapeViews().size());
    assertEquals(1, workspace.getViews().getSystemContextViews().size());
    assertEquals(1, workspace.getViews().getContainerViews().size());
    assertEquals(1, workspace.getViews().getComponentViews().size());
    assertEquals(1, workspace.getViews().getDynamicViews().size());
    assertEquals(2, workspace.getViews().getDeploymentViews().size());
    assertEquals(4, workspace.getViews().getSystemContextViews().iterator().next().getElements().size());
    assertEquals(4, workspace.getViews().getSystemContextViews().iterator().next().getRelationships().size());
    assertEquals(8, workspace.getViews().getContainerViews().iterator().next().getElements().size());
    assertEquals(10, workspace.getViews().getContainerViews().iterator().next().getRelationships().size());
    assertEquals(11, workspace.getViews().getComponentViews().iterator().next().getElements().size());
    assertEquals(13, workspace.getViews().getComponentViews().iterator().next().getRelationships().size());
    assertEquals(4, workspace.getViews().getDynamicViews().iterator().next().getElements().size());
    assertEquals(6, workspace.getViews().getDynamicViews().iterator().next().getRelationships().size());
    assertEquals(13, workspace.getViews().getDeploymentViews().stream().filter(v -> v.getKey().equals("DevelopmentDeployment")).findFirst().get().getElements().size());
    assertEquals(4, workspace.getViews().getDeploymentViews().stream().filter(v -> v.getKey().equals("DevelopmentDeployment")).findFirst().get().getRelationships().size());
    assertEquals(20, workspace.getViews().getDeploymentViews().stream().filter(v -> v.getKey().equals("LiveDeployment")).findFirst().get().getElements().size());
    assertEquals(7, workspace.getViews().getDeploymentViews().stream().filter(v -> v.getKey().equals("LiveDeployment")).findFirst().get().getRelationships().size());
    assertEquals(11, workspace.getViews().getConfiguration().getStyles().getElements().size());
    assertEquals(0, workspace.getViews().getConfiguration().getStyles().getRelationships().size());
    assertEquals(0, workspace.getViews().getConfiguration().getThemes().length);
    assertEquals(4, workspace.getModel().getSoftwareSystemWithName("Internet Banking System").getDocumentation().getSections().size());
    assertEquals(1, workspace.getModel().getSoftwareSystemWithName("Internet Banking System").getDocumentation().getDecisions().size());
}
Also used : com.structurizr.model(com.structurizr.model) Test(org.junit.jupiter.api.Test) Base64(java.util.Base64) List(java.util.List) Assertions(org.junit.jupiter.api.Assertions) com.structurizr.view(com.structurizr.view) File(java.io.File) Workspace(com.structurizr.Workspace) ArrayList(java.util.ArrayList) File(java.io.File) Workspace(com.structurizr.Workspace) Test(org.junit.jupiter.api.Test)

Example 98 with Workspace

use of com.structurizr.Workspace in project dsl by structurizr.

the class DslTests method test_extendWorkspaceFromDslFile.

@Test
void test_extendWorkspaceFromDslFile() throws Exception {
    StructurizrDslParser parser = new StructurizrDslParser();
    parser.parse(new File("src/test/dsl/extend/extend-workspace-from-dsl-file.dsl"));
    Workspace workspace = parser.getWorkspace();
    Model model = workspace.getModel();
    ViewSet views = workspace.getViews();
    assertEquals("A new name", workspace.getName());
    assertEquals("A new description", workspace.getDescription());
    assertEquals(1, model.getPeople().size());
    Person user = model.getPersonWithName("User");
    assertEquals("A user of my software system.", user.getDescription());
    assertEquals(1, workspace.getModel().getSoftwareSystems().size());
    SoftwareSystem softwareSystem = model.getSoftwareSystemWithName("Software System");
    assertEquals("My software system.", softwareSystem.getDescription());
    assertEquals(1, softwareSystem.getContainers().size());
    assertEquals("Web Application", softwareSystem.getContainers().iterator().next().getName());
    assertEquals(1, workspace.getModel().getRelationships().size());
    Relationship relationship = user.getRelationships().iterator().next();
    assertEquals("Uses", relationship.getDescription());
    assertSame(softwareSystem, relationship.getDestination());
    assertEquals(1, views.getViews().size());
    assertEquals(1, views.getSystemContextViews().size());
    SystemContextView view = views.getSystemContextViews().iterator().next();
    assertEquals("SystemContext", view.getKey());
    assertEquals("An example of a System Context diagram.", view.getDescription());
    assertEquals(2, view.getElements().size());
    assertEquals(1, view.getRelationships().size());
    assertEquals(2, views.getConfiguration().getStyles().getElements().size());
    ElementStyle personStyle = views.getConfiguration().getStyles().getElements().stream().filter(es -> es.getTag().equals("Person")).findFirst().get();
    assertEquals(Shape.Person, personStyle.getShape());
    assertEquals("#08427b", personStyle.getBackground());
    assertEquals("#ffffff", personStyle.getColor());
    ElementStyle softwareSystemStyle = views.getConfiguration().getStyles().getElements().stream().filter(es -> es.getTag().equals("Software System")).findFirst().get();
    assertEquals("#1168bd", softwareSystemStyle.getBackground());
    assertEquals("#ffffff", softwareSystemStyle.getColor());
}
Also used : File(java.io.File) Workspace(com.structurizr.Workspace) Test(org.junit.jupiter.api.Test)

Example 99 with Workspace

use of com.structurizr.Workspace in project dsl by structurizr.

the class DslTests method test_gettingstarted.

@Test
void test_gettingstarted() throws Exception {
    StructurizrDslParser parser = new StructurizrDslParser();
    parser.parse(new File("src/test/dsl/getting-started.dsl"));
    Workspace workspace = parser.getWorkspace();
    Model model = workspace.getModel();
    ViewSet views = workspace.getViews();
    assertEquals(1, model.getPeople().size());
    Person user = model.getPersonWithName("User");
    assertEquals(1, workspace.getModel().getSoftwareSystems().size());
    SoftwareSystem softwareSystem = model.getSoftwareSystemWithName("Software System");
    assertEquals(1, workspace.getModel().getRelationships().size());
    Relationship relationship = user.getRelationships().iterator().next();
    assertEquals("Uses", relationship.getDescription());
    assertSame(softwareSystem, relationship.getDestination());
    assertEquals(1, views.getViews().size());
    assertEquals(1, views.getSystemContextViews().size());
    SystemContextView view = views.getSystemContextViews().iterator().next();
    assertEquals("SoftwareSystem-SystemContext", view.getKey());
    assertEquals(2, view.getElements().size());
    assertEquals(1, view.getRelationships().size());
}
Also used : File(java.io.File) Workspace(com.structurizr.Workspace) Test(org.junit.jupiter.api.Test)

Example 100 with Workspace

use of com.structurizr.Workspace in project dsl by structurizr.

the class DslTests method test_includeUrl.

@Test
void test_includeUrl() throws Exception {
    StructurizrDslParser parser = new StructurizrDslParser();
    parser.parse(new File("src/test/dsl/include-url.dsl"));
    Workspace workspace = parser.getWorkspace();
    Model model = workspace.getModel();
    ViewSet views = workspace.getViews();
    assertEquals("Getting Started", workspace.getName());
    assertEquals("This is a model of my software system.", workspace.getDescription());
    assertEquals(1, model.getPeople().size());
    Person user = model.getPersonWithName("User");
    assertEquals("A user of my software system.", user.getDescription());
    assertEquals(1, workspace.getModel().getSoftwareSystems().size());
    SoftwareSystem softwareSystem = model.getSoftwareSystemWithName("Software System");
    assertEquals("My software system, code-named \"X\".", softwareSystem.getDescription());
    assertEquals(1, workspace.getModel().getRelationships().size());
    Relationship relationship = user.getRelationships().iterator().next();
    assertEquals("Uses", relationship.getDescription());
    assertSame(softwareSystem, relationship.getDestination());
    assertEquals(1, views.getViews().size());
    assertEquals(1, views.getSystemContextViews().size());
    SystemContextView view = views.getSystemContextViews().iterator().next();
    assertEquals("SystemContext", view.getKey());
    assertEquals("An example of a System Context diagram.", view.getDescription());
    assertEquals(2, view.getElements().size());
    assertEquals(1, view.getRelationships().size());
    assertEquals(2, views.getConfiguration().getStyles().getElements().size());
    ElementStyle personStyle = views.getConfiguration().getStyles().getElements().stream().filter(es -> es.getTag().equals("Person")).findFirst().get();
    assertEquals(Shape.Person, personStyle.getShape());
    assertEquals("#08427b", personStyle.getBackground());
    assertEquals("#ffffff", personStyle.getColor());
    ElementStyle softwareSystemStyle = views.getConfiguration().getStyles().getElements().stream().filter(es -> es.getTag().equals("Software System")).findFirst().get();
    assertEquals("#1168bd", softwareSystemStyle.getBackground());
    assertEquals("#ffffff", softwareSystemStyle.getColor());
    assertEquals("workspace \"Getting Started\" \"This is a model of my software system.\" {\n" + "\n" + "    model {\n" + "user = person \"User\" \"A user of my software system.\"\n" + "softwareSystem = softwareSystem \"Software System\" \"My software system, code-named \\\"X\\\".\"\n" + "\n" + "user -> softwareSystem \"Uses\"\n" + "    }\n" + "\n" + "    views {\n" + "        systemContext softwareSystem \"SystemContext\" \"An example of a System Context diagram.\" {\n" + "            include *\n" + "            autoLayout\n" + "        }\n" + "\n" + "        styles {\n" + "            element \"Software System\" {\n" + "                background #1168bd\n" + "                color #ffffff\n" + "            }\n" + "            element \"Person\" {\n" + "                shape person\n" + "                background #08427b\n" + "                color #ffffff\n" + "            }\n" + "        }\n" + "    }\n" + "\n" + "}\n", new String(Base64.getDecoder().decode(workspace.getProperties().get("structurizr.dsl"))));
}
Also used : File(java.io.File) Workspace(com.structurizr.Workspace) Test(org.junit.jupiter.api.Test)

Aggregations

Workspace (com.structurizr.Workspace)155 Test (org.junit.Test)98 Test (org.junit.jupiter.api.Test)36 File (java.io.File)23 Container (com.structurizr.model.Container)22 SoftwareSystem (com.structurizr.model.SoftwareSystem)22 Component (com.structurizr.model.Component)12 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)12 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)12 Application (org.archifacts.core.model.Application)12 ArtifactContainer (org.archifacts.core.model.ArtifactContainer)10 ArrayList (java.util.ArrayList)6 EncryptedWorkspace (com.structurizr.encryption.EncryptedWorkspace)5 Element (com.structurizr.model.Element)5 Model (com.structurizr.model.Model)5 Artifact (org.archifacts.core.model.Artifact)5 MiscArtifact (org.archifacts.core.model.MiscArtifact)5 Person (com.structurizr.model.Person)4 Relationship (com.structurizr.model.Relationship)4 SystemContextView (com.structurizr.view.SystemContextView)4