Search in sources :

Example 51 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem 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 52 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem 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 53 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem in project dsl by structurizr.

the class DynamicViewContentParserTests method test_parseRelationship_AddsTheRelationshipWithTheSpecifiedTechnologyToTheView_WhenItAlreadyExistsInTheModel.

@Test
void test_parseRelationship_AddsTheRelationshipWithTheSpecifiedTechnologyToTheView_WhenItAlreadyExistsInTheModel() {
    Person user = model.addPerson("User", "Description");
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
    Relationship r1 = user.uses(softwareSystem, "Uses 1", "Tech 1");
    Relationship r2 = user.uses(softwareSystem, "Uses 2", "Tech 2");
    DynamicView view = views.createDynamicView("key", "Description");
    DynamicViewDslContext context = new DynamicViewDslContext(view);
    IdentifiersRegister elements = new IdentifiersRegister();
    elements.register("source", user);
    elements.register("destination", softwareSystem);
    context.setIdentifierRegister(elements);
    parser.parseRelationship(context, tokens("source", "->", "destination", "Description", "Tech 2"));
    assertEquals(1, view.getRelationships().size());
    RelationshipView rv = view.getRelationships().iterator().next();
    assertSame(r2, rv.getRelationship());
    assertSame(user, rv.getRelationship().getSource());
    assertSame(softwareSystem, rv.getRelationship().getDestination());
    assertEquals("Description", rv.getDescription());
    assertEquals("1", rv.getOrder());
}
Also used : RelationshipView(com.structurizr.view.RelationshipView) Relationship(com.structurizr.model.Relationship) SoftwareSystem(com.structurizr.model.SoftwareSystem) DynamicView(com.structurizr.view.DynamicView) Person(com.structurizr.model.Person) Test(org.junit.jupiter.api.Test)

Example 54 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem in project dsl by structurizr.

the class DynamicViewContentParserTests method test_parseRelationship_AddsTheRelationshipToTheView_WhenItAlreadyExistsInTheModel.

@Test
void test_parseRelationship_AddsTheRelationshipToTheView_WhenItAlreadyExistsInTheModel() {
    Person user = model.addPerson("User", "Description");
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
    user.uses(softwareSystem, "Uses");
    DynamicView view = views.createDynamicView("key", "Description");
    DynamicViewDslContext context = new DynamicViewDslContext(view);
    IdentifiersRegister elements = new IdentifiersRegister();
    elements.register("source", user);
    elements.register("destination", softwareSystem);
    context.setIdentifierRegister(elements);
    parser.parseRelationship(context, tokens("source", "->", "destination"));
    assertEquals(1, view.getRelationships().size());
    RelationshipView rv = view.getRelationships().iterator().next();
    assertSame(user, rv.getRelationship().getSource());
    assertSame(softwareSystem, rv.getRelationship().getDestination());
    assertEquals("", rv.getDescription());
    assertEquals("1", rv.getOrder());
}
Also used : RelationshipView(com.structurizr.view.RelationshipView) SoftwareSystem(com.structurizr.model.SoftwareSystem) DynamicView(com.structurizr.view.DynamicView) Person(com.structurizr.model.Person) Test(org.junit.jupiter.api.Test)

Example 55 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem in project dsl by structurizr.

the class ModelDslContextTests method end_MarksAllOtherSoftwareSystemsAsExternal_WhenSomeSoftwareSystemsAreMarkedAsInternal.

@Test
void end_MarksAllOtherSoftwareSystemsAsExternal_WhenSomeSoftwareSystemsAreMarkedAsInternal() {
    ModelDslContext context = new ModelDslContext();
    context.setWorkspace(workspace);
    workspace.getModel().setEnterprise(new Enterprise("Name"));
    SoftwareSystem softwareSystem1 = workspace.getModel().addSoftwareSystem("Name 1");
    SoftwareSystem softwareSystem2 = workspace.getModel().addSoftwareSystem("Name 2");
    softwareSystem1.setLocation(Location.Internal);
    assertEquals(Location.Internal, softwareSystem1.getLocation());
    assertEquals(Location.Unspecified, softwareSystem2.getLocation());
    context.end();
    assertEquals(Location.Internal, softwareSystem1.getLocation());
    assertEquals(Location.External, softwareSystem2.getLocation());
}
Also used : Enterprise(com.structurizr.model.Enterprise) SoftwareSystem(com.structurizr.model.SoftwareSystem) Test(org.junit.jupiter.api.Test)

Aggregations

SoftwareSystem (com.structurizr.model.SoftwareSystem)69 Test (org.junit.jupiter.api.Test)38 Container (com.structurizr.model.Container)23 Workspace (com.structurizr.Workspace)22 Test (org.junit.Test)17 Person (com.structurizr.model.Person)9 Component (com.structurizr.model.Component)8 DynamicView (com.structurizr.view.DynamicView)8 ArrayList (java.util.ArrayList)8 Model (com.structurizr.model.Model)7 DeploymentView (com.structurizr.view.DeploymentView)6 SystemContextView (com.structurizr.view.SystemContextView)6 ViewSet (com.structurizr.view.ViewSet)5 Element (com.structurizr.model.Element)4 Relationship (com.structurizr.model.Relationship)4 ContainerView (com.structurizr.view.ContainerView)4 RelationshipView (com.structurizr.view.RelationshipView)4 DeploymentNode (com.structurizr.model.DeploymentNode)3 ComponentView (com.structurizr.view.ComponentView)3 EncryptedWorkspace (com.structurizr.encryption.EncryptedWorkspace)2