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);
}
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());
}
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());
}
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());
}
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"))));
}
Aggregations