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