Search in sources :

Example 26 with DeploymentView

use of com.structurizr.view.DeploymentView in project dsl by structurizr.

the class DeploymentViewContentParserTests method test_parseInclude_AddsAllInstancesOfContainersWithTheSpecifiedTag.

@Test
void test_parseInclude_AddsAllInstancesOfContainersWithTheSpecifiedTag() {
    SoftwareSystem ss = model.addSoftwareSystem("SS", "Description");
    Container c1 = ss.addContainer("Container 1");
    c1.addTags("Tag 1");
    Container c2 = ss.addContainer("Container 2");
    c2.addTags("Tag 2");
    DeploymentNode dn = model.addDeploymentNode("Live", "Live", "Description", "Technology");
    ContainerInstance c1Instance = dn.add(c1);
    ContainerInstance c2Instance = dn.add(c2);
    DeploymentView view = views.createDeploymentView("key", "Description");
    view.setEnvironment("Live");
    DeploymentViewDslContext context = new DeploymentViewDslContext(view);
    context.setWorkspace(workspace);
    parser.parseInclude(context, tokens("include", "element.tag==Tag 1"));
    assertEquals(2, view.getElements().size());
    assertNotNull(view.getElementView(dn));
    assertNotNull(view.getElementView(c1Instance));
}
Also used : DeploymentView(com.structurizr.view.DeploymentView) Test(org.junit.jupiter.api.Test)

Example 27 with DeploymentView

use of com.structurizr.view.DeploymentView in project dsl by structurizr.

the class DeploymentViewParserTests method test_parse_CreatesADeploymentViewWithSoftwareSystemScopeAndKey.

@Test
void test_parse_CreatesADeploymentViewWithSoftwareSystemScopeAndKey() {
    DslContext context = context();
    context.getWorkspace().getModel().addDeploymentNode("Live", "Deployment Node", "Description", "Technology");
    IdentifiersRegister elements = new IdentifiersRegister();
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Name", "Description");
    elements.register("softwaresystem", softwareSystem);
    context.setIdentifierRegister(elements);
    parser.parse(context, tokens("deployment", "softwareSystem", "Live", "key"));
    List<DeploymentView> views = new ArrayList<>(this.views.getDeploymentViews());
    assertEquals(1, views.size());
    assertEquals("key", views.get(0).getKey());
    assertEquals("", views.get(0).getDescription());
    assertSame(softwareSystem, views.get(0).getSoftwareSystem());
}
Also used : ArrayList(java.util.ArrayList) SoftwareSystem(com.structurizr.model.SoftwareSystem) DeploymentView(com.structurizr.view.DeploymentView) Test(org.junit.jupiter.api.Test)

Example 28 with DeploymentView

use of com.structurizr.view.DeploymentView in project dsl by structurizr.

the class DeploymentViewParserTests method test_parse_CreatesADeploymentViewWithSoftwareSystemScopeAndKeyAndDescription.

@Test
void test_parse_CreatesADeploymentViewWithSoftwareSystemScopeAndKeyAndDescription() {
    DslContext context = context();
    context.getWorkspace().getModel().addDeploymentNode("Live", "Deployment Node", "Description", "Technology");
    IdentifiersRegister elements = new IdentifiersRegister();
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Name", "Description");
    elements.register("softwaresystem", softwareSystem);
    context.setIdentifierRegister(elements);
    parser.parse(context, tokens("deployment", "softwareSystem", "Live", "key", "Description"));
    List<DeploymentView> views = new ArrayList<>(this.views.getDeploymentViews());
    assertEquals(1, views.size());
    assertEquals("key", views.get(0).getKey());
    assertEquals("Description", views.get(0).getDescription());
    assertSame(softwareSystem, views.get(0).getSoftwareSystem());
}
Also used : ArrayList(java.util.ArrayList) SoftwareSystem(com.structurizr.model.SoftwareSystem) DeploymentView(com.structurizr.view.DeploymentView) Test(org.junit.jupiter.api.Test)

Example 29 with DeploymentView

use of com.structurizr.view.DeploymentView in project dsl by structurizr.

the class DeploymentViewParserTests method test_parse_CreatesADeploymentViewWithSoftwareSystemScope.

@Test
void test_parse_CreatesADeploymentViewWithSoftwareSystemScope() {
    DslContext context = context();
    context.getWorkspace().getModel().addDeploymentNode("Live", "Deployment Node", "Description", "Technology");
    IdentifiersRegister elements = new IdentifiersRegister();
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Name", "Description");
    elements.register("softwaresystem", softwareSystem);
    context.setIdentifierRegister(elements);
    parser.parse(context, tokens("deployment", "softwareSystem", "Live"));
    List<DeploymentView> views = new ArrayList<>(this.views.getDeploymentViews());
    assertEquals(1, views.size());
    assertEquals("Name-Live-Deployment", views.get(0).getKey());
    assertEquals("", views.get(0).getDescription());
    assertSame(softwareSystem, views.get(0).getSoftwareSystem());
}
Also used : ArrayList(java.util.ArrayList) SoftwareSystem(com.structurizr.model.SoftwareSystem) DeploymentView(com.structurizr.view.DeploymentView) Test(org.junit.jupiter.api.Test)

Example 30 with DeploymentView

use of com.structurizr.view.DeploymentView in project dsl by structurizr.

the class AbstractExpressionParserTests method test_parseExpression_ReturnsElementInstances_WhenUsingAnElementTagExpression.

@Test
void test_parseExpression_ReturnsElementInstances_WhenUsingAnElementTagExpression() {
    model.addPerson("User");
    SoftwareSystem ss = model.addSoftwareSystem("Software System");
    SoftwareSystemInstance ssi = model.addDeploymentNode("DN").add(ss);
    DeploymentView view = views.createDeploymentView("key", "Description");
    DeploymentViewDslContext context = new DeploymentViewDslContext(view);
    context.setWorkspace(workspace);
    context.setIdentifierRegister(new IdentifiersRegister());
    Set<ModelItem> elements = parser.parseExpression("element.tag==Software System", context);
    assertEquals(2, elements.size());
    // this is tagged "Software System"
    assertTrue(elements.contains(ss));
    // this is not tagged "Software System", but the element it's based upon is
    assertTrue(elements.contains(ssi));
}
Also used : DeploymentView(com.structurizr.view.DeploymentView) Test(org.junit.jupiter.api.Test)

Aggregations

DeploymentView (com.structurizr.view.DeploymentView)31 Test (org.junit.jupiter.api.Test)27 SoftwareSystem (com.structurizr.model.SoftwareSystem)6 com.structurizr.model (com.structurizr.model)4 RelationshipView (com.structurizr.view.RelationshipView)4 Assertions (org.junit.jupiter.api.Assertions)4 Workspace (com.structurizr.Workspace)3 ArrayList (java.util.ArrayList)3 Container (com.structurizr.model.Container)2 DeploymentNode (com.structurizr.model.DeploymentNode)2 Model (com.structurizr.model.Model)2 Styles (com.structurizr.view.Styles)2 SystemLandscapeView (com.structurizr.view.SystemLandscapeView)2 ViewSet (com.structurizr.view.ViewSet)2 StructurizrDslParser (com.structurizr.dsl.StructurizrDslParser)1 StructurizrDslParserException (com.structurizr.dsl.StructurizrDslParserException)1 Diagram (com.structurizr.export.Diagram)1 StructurizrPlantUMLExporter (com.structurizr.export.plantuml.StructurizrPlantUMLExporter)1 Element (com.structurizr.model.Element)1 Enterprise (com.structurizr.model.Enterprise)1