use of com.structurizr.Workspace in project dsl by structurizr.
the class DslTests method test_awsLocal.
@Test
void test_awsLocal() throws Exception {
StructurizrDslParser parser = new StructurizrDslParser();
parser.parse(new File("src/test/dsl/amazon-web-services-local.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 StructurizrDslFormatterTests method test_escapingQuotes.
@Test
void test_escapingQuotes() throws Exception {
Workspace workspace = new Workspace("Name", "Description");
workspace.getModel().addPerson("Hello \"World\"");
StructurizrDslFormatter formatter = new StructurizrDslFormatter();
assertEquals("workspace \"Name\" \"Description\" {\n" + "\n" + " !impliedRelationships \"false\" \n" + " !identifiers \"hierarchical\" \n" + "\n" + " model {\n" + " HelloWorld = person \"Hello \\\"World\\\"\" \n" + " }\n" + "\n" + "}\n", formatter.format(WorkspaceUtils.toJson(workspace, false)));
}
use of com.structurizr.Workspace in project dsl by structurizr.
the class StructurizrDslFormatterTests 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();
StructurizrDslFormatter formatter = new StructurizrDslFormatter();
assertEquals("workspace \"Name\" \"Description\" {\n" + "\n" + " !impliedRelationships \"false\" \n" + " !identifiers \"hierarchical\" \n" + "\n" + " model {\n" + " User = person \"User\" \n" + " SoftwareSystem = softwareSystem \"Software System\" \n" + " User -> SoftwareSystem \"Uses\" \n" + " }\n" + "\n" + " views {\n" + " systemContext SoftwareSystem \"SoftwareSystem-SystemContext\" {\n" + " include User \n" + " include SoftwareSystem \n" + " autolayout tb 300 300 \n" + " }\n" + "\n" + " themes \"https://static.structurizr.com/themes/default/theme.json\" \n" + "\n" + " }\n" + "\n" + "}\n", formatter.format(WorkspaceUtils.toJson(workspace, false)));
}
use of com.structurizr.Workspace in project dsl by structurizr.
the class StructurizrDslFormatterTests 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();
StructurizrDslFormatter formatter = new StructurizrDslFormatter();
assertEquals("workspace \"Amazon Web Services Example\" \"An example AWS deployment architecture.\" {\n" + "\n" + " !impliedRelationships \"false\" \n" + " !identifiers \"hierarchical\" \n" + "\n" + " model {\n" + " SpringPetClinic = softwareSystem \"Spring PetClinic\" \"Allows employees to view and manage information regarding the veterinarians, the clients, and their pets.\" \"Spring Boot Application\" {\n" + " WebApplication = container \"Web Application\" \"Allows employees to view and manage information regarding the veterinarians, the clients, and their pets.\" \"Java and Spring Boot\" \n" + " Database = container \"Database\" \"Stores information regarding the veterinarians, the clients, and their pets.\" \"Relational database schema\" \"Database\" \n" + " }\n" + " SpringPetClinic.WebApplication -> SpringPetClinic.Database \"Reads from and writes to\" \"MySQL Protocol/SSL\" \n" + "\n" + " Live = deploymentEnvironment \"Live\" {\n" + " AmazonWebServices = deploymentNode \"Amazon Web Services\" \"\" \"\" \"Amazon Web Services - Cloud\" {\n" + " USEast1 = deploymentNode \"US-East-1\" \"\" \"\" \"Amazon Web Services - Region\" {\n" + " Route53 = infrastructureNode \"Route 53\" \"\" \"\" \"Amazon Web Services - Route 53\" \n" + " ElasticLoadBalancer = infrastructureNode \"Elastic Load Balancer\" \"\" \"\" \"Amazon Web Services - Elastic Load Balancing\" \n" + " AmazonRDS = deploymentNode \"Amazon RDS\" \"\" \"\" \"Amazon Web Services - RDS\" {\n" + " MySQL = deploymentNode \"MySQL\" \"\" \"\" \"Amazon Web Services - RDS MySQL instance\" {\n" + " Database_1 = containerInstance SpringPetClinic.Database \n" + " }\n" + " }\n" + " Autoscalinggroup = deploymentNode \"Autoscaling group\" \"\" \"\" \"Amazon Web Services - Auto Scaling\" {\n" + " AmazonEC2 = deploymentNode \"Amazon EC2\" \"\" \"\" \"Amazon Web Services - EC2\" {\n" + " WebApplication_1 = containerInstance SpringPetClinic.WebApplication \n" + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" + "\n" + " Live.AmazonWebServices.USEast1.Route53 -> Live.AmazonWebServices.USEast1.ElasticLoadBalancer \"Forwards requests to\" \"HTTPS\" \n" + " Live.AmazonWebServices.USEast1.ElasticLoadBalancer -> Live.AmazonWebServices.USEast1.Autoscalinggroup.AmazonEC2.WebApplication_1 \"Forwards requests to\" \"HTTPS\" \n" + " }\n" + "\n" + " views {\n" + " deployment SpringPetClinic \"Live\" \"AmazonWebServicesDeployment\" {\n" + " include Live.AmazonWebServices.USEast1.Autoscalinggroup.AmazonEC2 \n" + " include Live.AmazonWebServices.USEast1.AmazonRDS.MySQL \n" + " include Live.AmazonWebServices.USEast1 \n" + " autolayout lr 300 300 \n" + " }\n" + "\n" + " styles {\n" + " element \"Database\" {\n" + " shape \"Cylinder\" \n" + " }\n" + " element \"Element\" {\n" + " shape \"RoundedBox\" \n" + " background \"#ffffff\" \n" + " }\n" + " element \"Infrastructure Node\" {\n" + " shape \"RoundedBox\" \n" + " }\n" + " }\n" + " themes \"https://static.structurizr.com/themes/amazon-web-services-2020.04.30/theme.json\" \n" + "\n" + " }\n" + "\n" + "}\n", formatter.format(WorkspaceUtils.toJson(workspace, false)));
}
use of com.structurizr.Workspace in project dsl by structurizr.
the class StructurizrDslFormatterTests method test_formattingInternalSoftwareSystemsWhenNoEnterpriseSpecified.
@Test
void test_formattingInternalSoftwareSystemsWhenNoEnterpriseSpecified() throws Exception {
Workspace workspace = new Workspace("Name", "Description");
SoftwareSystem ss = workspace.getModel().addSoftwareSystem("Software System");
ss.setLocation(Location.Internal);
StructurizrDslFormatter formatter = new StructurizrDslFormatter();
String result = formatter.format(WorkspaceUtils.toJson(workspace, false));
assertEquals("workspace \"Name\" \"Description\" {\n" + "\n" + " !impliedRelationships \"false\" \n" + " !identifiers \"hierarchical\" \n" + "\n" + " model {\n" + " enterprise \"Enterprise\" {\n" + " SoftwareSystem = softwareSystem \"Software System\" \n" + " }\n" + " }\n" + "\n" + "}\n", result);
}
Aggregations