Search in sources :

Example 21 with DeploymentView

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

the class DeploymentViewContentParserTests method test_parseInclude_AddsAllDeploymentNodesAndChildrenInTheDeploymentEnvironment_WhenTheWildcardIsSpecifiedAndTheViewHasASoftwareSystemScope.

@Test
void test_parseInclude_AddsAllDeploymentNodesAndChildrenInTheDeploymentEnvironment_WhenTheWildcardIsSpecifiedAndTheViewHasASoftwareSystemScope() {
    SoftwareSystem ss1 = model.addSoftwareSystem("SS1", "Description");
    Container c1 = ss1.addContainer("C1", "Description", "Technology");
    SoftwareSystem ss2 = model.addSoftwareSystem("SS2", "Description");
    Container c2 = ss2.addContainer("C2", "Description", "Technology");
    DeploymentNode dev1 = model.addDeploymentNode("Dev", "Dev 1", "Description", "Technology");
    DeploymentNode dev2 = dev1.addDeploymentNode("Dev 2", "Description", "Technology");
    InfrastructureNode dev3 = dev2.addInfrastructureNode("Dev 3", "Description", "Technology");
    ContainerInstance dev4 = dev2.add(c1);
    ContainerInstance dev5 = dev2.add(c2);
    DeploymentNode live1 = model.addDeploymentNode("Live", "Live 1", "Description", "Technology");
    DeploymentNode live2 = live1.addDeploymentNode("Live 2", "Description", "Technology");
    InfrastructureNode live3 = live2.addInfrastructureNode("Live 3", "Description", "Technology");
    ContainerInstance live4 = live2.add(c1);
    ContainerInstance live5 = live2.add(c2);
    DeploymentView view = views.createDeploymentView(ss1, "key", "Description");
    view.setEnvironment("Live");
    DeploymentViewDslContext context = new DeploymentViewDslContext(view);
    context.setWorkspace(workspace);
    parser.parseInclude(context, tokens("include", "*"));
    assertEquals(4, view.getElements().size());
    assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(live1)));
    assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(live2)));
    assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(live3)));
    assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(live4)));
}
Also used : com.structurizr.model(com.structurizr.model) Test(org.junit.jupiter.api.Test) Assertions(org.junit.jupiter.api.Assertions) RelationshipView(com.structurizr.view.RelationshipView) DeploymentView(com.structurizr.view.DeploymentView) DeploymentView(com.structurizr.view.DeploymentView) Test(org.junit.jupiter.api.Test)

Example 22 with DeploymentView

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

the class DeploymentViewContentParserTests method test_parseExclude_ExcludesReplicatedVersionsOfTheSpecifiedRelationship.

@Test
void test_parseExclude_ExcludesReplicatedVersionsOfTheSpecifiedRelationship() {
    SoftwareSystem ss1 = model.addSoftwareSystem("SS1", "Description");
    SoftwareSystem ss2 = model.addSoftwareSystem("SS2", "Description");
    Relationship rel = ss1.uses(ss2, "Uses");
    DeploymentNode dn = model.addDeploymentNode("Live", "Live", "Description", "Technology");
    dn.add(ss1);
    dn.add(ss2);
    DeploymentView view = views.createDeploymentView("key", "Description");
    view.setEnvironment("Live");
    DeploymentViewDslContext context = new DeploymentViewDslContext(view);
    context.setWorkspace(workspace);
    IdentifiersRegister identifersRegister = new IdentifiersRegister();
    identifersRegister.register("rel", rel);
    context.setIdentifierRegister(identifersRegister);
    view.addDefaultElements();
    assertEquals(1, view.getRelationships().stream().map(RelationshipView::getRelationship).filter(r -> r.getLinkedRelationshipId().equals(rel.getId())).count());
    parser.parseExclude(context, tokens("exclude", "rel"));
    assertEquals(0, view.getRelationships().size());
}
Also used : DeploymentView(com.structurizr.view.DeploymentView) Test(org.junit.jupiter.api.Test)

Example 23 with DeploymentView

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

the class DeploymentViewContentParserTests method test_parseExclude_RemovesTheRelationshipFromAView_WhenAnExpressionIsSpecifiedWithSource.

@Test
void test_parseExclude_RemovesTheRelationshipFromAView_WhenAnExpressionIsSpecifiedWithSource() {
    SoftwareSystem ss1 = model.addSoftwareSystem("SS1", "Description");
    SoftwareSystem ss2 = model.addSoftwareSystem("SS2", "Description");
    Relationship rel = ss1.uses(ss2, "Uses");
    DeploymentNode dn = model.addDeploymentNode("Live", "Live", "Description", "Technology");
    dn.add(ss1);
    dn.add(ss2);
    DeploymentView view = views.createDeploymentView("key", "Description");
    view.setEnvironment("Live");
    view.add(dn);
    DeploymentViewDslContext context = new DeploymentViewDslContext(view);
    context.setWorkspace(workspace);
    IdentifiersRegister elements = new IdentifiersRegister();
    elements.register("ss1", ss1);
    elements.register("ss2", ss2);
    context.setIdentifierRegister(elements);
    parser.parseExclude(context, tokens("exclude", "relationship.source==ss1"));
    assertEquals(0, view.getRelationships().size());
}
Also used : DeploymentView(com.structurizr.view.DeploymentView) Test(org.junit.jupiter.api.Test)

Example 24 with DeploymentView

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

the class DeploymentViewContentParserTests method test_parseInclude_AddsAllInstancesOfSoftwareSystemsWithTheSpecifiedTag.

@Test
void test_parseInclude_AddsAllInstancesOfSoftwareSystemsWithTheSpecifiedTag() {
    SoftwareSystem ss1 = model.addSoftwareSystem("SS1", "Description");
    ss1.addTags("Tag 1");
    SoftwareSystem ss2 = model.addSoftwareSystem("SS2", "Description");
    ss2.addTags("Tag 2");
    ss1.uses(ss2, "Uses");
    DeploymentNode dn = model.addDeploymentNode("Live", "Live", "Description", "Technology");
    SoftwareSystemInstance ss1Instance = dn.add(ss1);
    SoftwareSystemInstance ss2Instance = dn.add(ss2);
    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(ss1Instance));
}
Also used : DeploymentView(com.structurizr.view.DeploymentView) Test(org.junit.jupiter.api.Test)

Example 25 with DeploymentView

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

the class DeploymentViewContentParserTests method test_parseInclude_AddsTheSpecifiedElements.

@Test
void test_parseInclude_AddsTheSpecifiedElements() {
    SoftwareSystem ss1 = model.addSoftwareSystem("SS1", "Description");
    Container c1 = ss1.addContainer("C1", "Description", "Technology");
    SoftwareSystem ss2 = model.addSoftwareSystem("SS2", "Description");
    Container c2 = ss2.addContainer("C2", "Description", "Technology");
    CustomElement box1 = model.addCustomElement("Box 1");
    DeploymentNode dev1 = model.addDeploymentNode("Dev", "Dev 1", "Description", "Technology");
    DeploymentNode dev2 = dev1.addDeploymentNode("Dev 2", "Description", "Technology");
    InfrastructureNode dev3 = dev2.addInfrastructureNode("Dev 3", "Description", "Technology");
    ContainerInstance dev4 = dev2.add(c1);
    ContainerInstance dev5 = dev2.add(c2);
    DeploymentNode live1 = model.addDeploymentNode("Live", "Live 1", "Description", "Technology");
    DeploymentNode live2 = live1.addDeploymentNode("Live 2", "Description", "Technology");
    InfrastructureNode live3 = live2.addInfrastructureNode("Live 3", "Description", "Technology");
    ContainerInstance live4 = live2.add(c1);
    ContainerInstance live5 = live2.add(c2);
    IdentifiersRegister elements = new IdentifiersRegister();
    elements.register("element", live1);
    elements.register("box1", box1);
    DeploymentView view = views.createDeploymentView(ss1, "key", "Description");
    view.setEnvironment("Live");
    DeploymentViewDslContext context = new DeploymentViewDslContext(view);
    context.setWorkspace(workspace);
    context.setIdentifierRegister(elements);
    parser.parseInclude(context, tokens("include", "element", "box1"));
    assertEquals(5, view.getElements().size());
    assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(live1)));
    assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(live2)));
    assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(live3)));
    assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(live4)));
    assertTrue(view.getElements().stream().anyMatch(ev -> ev.getElement().equals(box1)));
}
Also used : com.structurizr.model(com.structurizr.model) Test(org.junit.jupiter.api.Test) Assertions(org.junit.jupiter.api.Assertions) RelationshipView(com.structurizr.view.RelationshipView) DeploymentView(com.structurizr.view.DeploymentView) 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