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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations