use of com.structurizr.Workspace in project dsl by structurizr.
the class DslTests method test_aws.
@Test
void test_aws() throws Exception {
StructurizrDslParser parser = new StructurizrDslParser();
parser.parse(new File("src/test/dsl/amazon-web-services.dsl"));
Workspace workspace = parser.getWorkspace();
assertEquals(13, workspace.getModel().getElements().size());
assertEquals(0, workspace.getModel().getPeople().size());
assertEquals(1, workspace.getModel().getSoftwareSystems().size());
assertEquals(2, workspace.getModel().getSoftwareSystemWithName("Spring PetClinic").getContainers().size());
assertEquals(1, workspace.getModel().getDeploymentNodes().size());
assertEquals(6, workspace.getModel().getElements().stream().filter(e -> e instanceof DeploymentNode).count());
assertEquals(2, workspace.getModel().getElements().stream().filter(e -> e instanceof ContainerInstance).count());
assertEquals(2, workspace.getModel().getElements().stream().filter(e -> e instanceof InfrastructureNode).count());
assertEquals(4, workspace.getModel().getRelationships().size());
assertEquals(0, 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(1, workspace.getViews().getDeploymentViews().size());
DeploymentView deploymentView = workspace.getViews().getDeploymentViews().iterator().next();
assertEquals(10, deploymentView.getElements().size());
assertEquals(3, deploymentView.getRelationships().size());
assertEquals(4, deploymentView.getAnimations().size());
assertEquals(3, workspace.getViews().getConfiguration().getStyles().getElements().size());
assertEquals(0, workspace.getViews().getConfiguration().getStyles().getRelationships().size());
assertEquals(1, workspace.getViews().getConfiguration().getThemes().length);
}
use of com.structurizr.Workspace in project dsl by structurizr.
the class DslTests method test_extendWorkspaceFromJsonUrl.
@Test
void test_extendWorkspaceFromJsonUrl() throws Exception {
StructurizrDslParser parser = new StructurizrDslParser();
parser.parse(new File("src/test/dsl/extend/extend-workspace-from-json-url.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_extendWorkspaceFromJsonFile.
@Test
void test_extendWorkspaceFromJsonFile() throws Exception {
StructurizrDslParser parser = new StructurizrDslParser();
parser.parse(new File("src/test/dsl/extend/extend-workspace-from-json-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_frs.
@Test
void test_frs() throws Exception {
StructurizrDslParser parser = new StructurizrDslParser();
parser.parse(new File("src/test/dsl/financial-risk-system.dsl"));
Workspace workspace = parser.getWorkspace();
assertEquals(9, workspace.getModel().getElements().size());
assertEquals(2, workspace.getModel().getPeople().size());
assertEquals(7, workspace.getModel().getSoftwareSystems().size());
assertEquals(0, workspace.getModel().getDeploymentNodes().size());
assertEquals(0, workspace.getModel().getElements().stream().filter(e -> e instanceof DeploymentNode).count());
assertEquals(0, workspace.getModel().getElements().stream().filter(e -> e instanceof ContainerInstance).count());
assertEquals(0, workspace.getModel().getElements().stream().filter(e -> e instanceof InfrastructureNode).count());
assertEquals(9, workspace.getModel().getRelationships().size());
assertEquals(0, workspace.getViews().getSystemLandscapeViews().size());
assertEquals(1, 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(9, workspace.getViews().getSystemContextViews().iterator().next().getElements().size());
assertEquals(9, workspace.getViews().getSystemContextViews().iterator().next().getRelationships().size());
assertEquals(5, workspace.getViews().getConfiguration().getStyles().getElements().size());
assertEquals(4, 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_includeLocalFile.
@Test
void test_includeLocalFile() throws Exception {
StructurizrDslParser parser = new StructurizrDslParser();
parser.parse(new File("src/test/dsl/include-file.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