Search in sources :

Example 11 with Workspace

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);
}
Also used : File(java.io.File) Workspace(com.structurizr.Workspace) Test(org.junit.jupiter.api.Test)

Example 12 with Workspace

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

Example 13 with Workspace

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)));
}
Also used : File(java.io.File) Workspace(com.structurizr.Workspace) Test(org.junit.jupiter.api.Test)

Example 14 with Workspace

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)));
}
Also used : File(java.io.File) Workspace(com.structurizr.Workspace) Test(org.junit.jupiter.api.Test)

Example 15 with Workspace

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);
}
Also used : SoftwareSystem(com.structurizr.model.SoftwareSystem) 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