Search in sources :

Example 1 with Person

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

the class DynamicViewContentParserTests method test_parseRelationship_AddsTheRelationshipToTheViewWithAnOverriddenDescription_WhenItAlreadyExistsInTheModel.

@Test
void test_parseRelationship_AddsTheRelationshipToTheViewWithAnOverriddenDescription_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", "Does something with"));
    assertEquals(1, view.getRelationships().size());
    RelationshipView rv = view.getRelationships().iterator().next();
    assertSame(user, rv.getRelationship().getSource());
    assertSame(softwareSystem, rv.getRelationship().getDestination());
    assertEquals("Does something with", 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 2 with Person

use of com.structurizr.model.Person 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 3 with Person

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

the class ModelDslContextTests method end_MarksAllOtherPeopleAsExternal_WhenSomePeopleAreMarkedAsInternal.

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

Example 4 with Person

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

the class ModelDslContextTests method end_DoesNothing_WhenNoPeopleAreMarkedAsInternal.

@Test
void end_DoesNothing_WhenNoPeopleAreMarkedAsInternal() {
    ModelDslContext context = new ModelDslContext();
    context.setWorkspace(workspace);
    Person user1 = workspace.getModel().addPerson("Name 1");
    Person user2 = workspace.getModel().addPerson("Name 2");
    assertEquals(Location.Unspecified, user1.getLocation());
    assertEquals(Location.Unspecified, user2.getLocation());
    context.end();
    assertEquals(Location.Unspecified, user1.getLocation());
    assertEquals(Location.Unspecified, user2.getLocation());
}
Also used : Person(com.structurizr.model.Person) Test(org.junit.jupiter.api.Test)

Example 5 with Person

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

the class PersonParserTests method test_parse_CreatesAnInternalPerson.

@Test
void test_parse_CreatesAnInternalPerson() {
    EnterpriseDslContext context = new EnterpriseDslContext();
    context.setWorkspace(workspace);
    parser.parse(context, tokens("person", "User"));
    assertEquals(1, model.getElements().size());
    Person user = model.getPersonWithName("User");
    assertNotNull(user);
    assertEquals("", user.getDescription());
    assertEquals(Location.Internal, user.getLocation());
    assertEquals("Element,Person", user.getTags());
}
Also used : Person(com.structurizr.model.Person) Test(org.junit.jupiter.api.Test)

Aggregations

Person (com.structurizr.model.Person)19 Test (org.junit.jupiter.api.Test)13 SoftwareSystem (com.structurizr.model.SoftwareSystem)9 Workspace (com.structurizr.Workspace)5 DynamicView (com.structurizr.view.DynamicView)4 RelationshipView (com.structurizr.view.RelationshipView)4 SystemContextView (com.structurizr.view.SystemContextView)4 Model (com.structurizr.model.Model)3 ModelItem (com.structurizr.model.ModelItem)3 Relationship (com.structurizr.model.Relationship)3 ViewSet (com.structurizr.view.ViewSet)3 EncryptedWorkspace (com.structurizr.encryption.EncryptedWorkspace)2 EncryptedJsonReader (com.structurizr.io.json.EncryptedJsonReader)2 Container (com.structurizr.model.Container)2 Enterprise (com.structurizr.model.Enterprise)2 FileReader (java.io.FileReader)2 Test (org.junit.Test)2 ComponentFinder (com.structurizr.analysis.ComponentFinder)1 StructurizrAnnotationsComponentFinderStrategy (com.structurizr.analysis.StructurizrAnnotationsComponentFinderStrategy)1 AesEncryptionStrategy (com.structurizr.encryption.AesEncryptionStrategy)1