use of com.structurizr.view.RelationshipView 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.view.RelationshipView 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.view.RelationshipView 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());
}
use of com.structurizr.view.RelationshipView 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());
}
use of com.structurizr.view.RelationshipView in project moduliths by moduliths.
the class Documenter method addComponentsToView.
private void addComponentsToView(Supplier<Stream<Module>> modules, ComponentView view, Options options, Consumer<ComponentView> afterCleanup) {
Styles styles = view.getViewSet().getConfiguration().getStyles();
Map<Module, Component> components = getComponents(options);
//
modules.get().distinct().filter(//
options.getExclusions().negate()).map(//
it -> applyBackgroundColor(it, components, options, styles)).filter(//
options.getComponentFilter()).forEach(view::add);
// view.getViewSet().getConfiguration().getStyles().findElementStyle(element).getBackground()
// Remove filtered dependency types
//
DependencyType.allBut(options.getDependencyTypes()).map(//
Object::toString).forEach(it -> view.removeRelationshipsWithTag(it));
afterCleanup.accept(view);
// Filter outgoing relationships of target-only modules
//
modules.get().filter(options.getTargetOnly()).forEach(module -> {
Component component = components.get(module);
//
view.getRelationships().stream().map(//
RelationshipView::getRelationship).filter(//
it -> it.getSource().equals(component)).forEach(it -> view.remove(it));
});
// … as well as all elements left without a relationship
if (options.hideElementsWithoutRelationships()) {
view.removeElementsWithNoRelationships();
}
afterCleanup.accept(view);
// Remove default relationships if more qualified ones exist
//
view.getRelationships().stream().map(//
RelationshipView::getRelationship).collect(//
Collectors.groupingBy(Connection::of)).values().stream().forEach(it -> potentiallyRemoveDefaultRelationship(view, it));
}
Aggregations