Search in sources :

Example 6 with SoftwareSystem

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

the class DynamicViewContentParserTests method test_parseRelationship_AddsTheRelationshipToTheModelAndView_WhenItDoesNotAlreadyExistInTheModel.

@Test
void test_parseRelationship_AddsTheRelationshipToTheModelAndView_WhenItDoesNotAlreadyExistInTheModel() {
    Person user = model.addPerson("User", "Description");
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
    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);
    assertEquals(0, model.getRelationships().size());
    parser.parseRelationship(context, tokens("source", "->", "destination", "Uses"));
    assertEquals(1, model.getRelationships().size());
    Relationship r = model.getRelationships().iterator().next();
    assertSame(user, r.getSource());
    assertSame(softwareSystem, r.getDestination());
    assertEquals("Uses", r.getDescription());
    assertEquals(1, view.getRelationships().size());
    RelationshipView rv = view.getRelationships().iterator().next();
    assertSame(user, rv.getRelationship().getSource());
    assertSame(softwareSystem, rv.getRelationship().getDestination());
    assertEquals("Uses", 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 7 with SoftwareSystem

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

the class DynamicViewParserTests method test_parse_CreatesADynamicViewWithSoftwareSystemScopeAndKey.

@Test
void test_parse_CreatesADynamicViewWithSoftwareSystemScopeAndKey() {
    DslContext context = context();
    IdentifiersRegister elements = new IdentifiersRegister();
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Name", "Description");
    elements.register("softwaresystem", softwareSystem);
    context.setIdentifierRegister(elements);
    parser.parse(context, tokens("dynamic", "softwareSystem", "key"));
    List<DynamicView> views = new ArrayList<>(this.views.getDynamicViews());
    assertEquals(1, views.size());
    assertEquals("key", views.get(0).getKey());
    assertEquals("", views.get(0).getDescription());
    assertSame(softwareSystem, views.get(0).getElement());
}
Also used : ArrayList(java.util.ArrayList) SoftwareSystem(com.structurizr.model.SoftwareSystem) DynamicView(com.structurizr.view.DynamicView) Test(org.junit.jupiter.api.Test)

Example 8 with SoftwareSystem

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

the class DynamicViewParserTests method test_parse_CreatesADynamicViewWithSoftwareSystemScopeAndKeyAndDescription.

@Test
void test_parse_CreatesADynamicViewWithSoftwareSystemScopeAndKeyAndDescription() {
    DslContext context = context();
    IdentifiersRegister elements = new IdentifiersRegister();
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Name", "Description");
    elements.register("softwaresystem", softwareSystem);
    context.setIdentifierRegister(elements);
    parser.parse(context, tokens("dynamic", "softwareSystem", "key", "Description"));
    List<DynamicView> views = new ArrayList<>(this.views.getDynamicViews());
    assertEquals(1, views.size());
    assertEquals("key", views.get(0).getKey());
    assertEquals("Description", views.get(0).getDescription());
    assertSame(softwareSystem, views.get(0).getElement());
}
Also used : ArrayList(java.util.ArrayList) SoftwareSystem(com.structurizr.model.SoftwareSystem) DynamicView(com.structurizr.view.DynamicView) Test(org.junit.jupiter.api.Test)

Example 9 with SoftwareSystem

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

the class ModelDslContextTests method end_DoesNothing_WhenNoSoftwareSystemsAreMarkedAsInternal.

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

Example 10 with SoftwareSystem

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

the class ModelItemParserTests method test_parseDescription_ThrowsAnException_WhenNoDescriptionIsSpecified.

@Test
void test_parseDescription_ThrowsAnException_WhenNoDescriptionIsSpecified() {
    try {
        SoftwareSystem softwareSystem = model.addSoftwareSystem("Name", "Description");
        ModelItemDslContext context = new SoftwareSystemDslContext(softwareSystem);
        parser.parseDescription(context, tokens("description"));
        fail();
    } catch (Exception e) {
        assertEquals("Expected: description <description>", e.getMessage());
    }
}
Also used : 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