use of com.structurizr.model.Container in project archifacts by archifacts.
the class C4ModelBuilderTest method assert_that_computation_rule_is_applied_to_artifact.
@Test
void assert_that_computation_rule_is_applied_to_artifact() {
final JavaClasses javaClasses = new ClassFileImporter().importPackages("org.archifacts.integration.c4.model.domain");
final Application application = Application.builder().descriptor(buildingBlockType1Descriptor).descriptor(defaultContainerDescriptor).buildApplication(javaClasses);
final C4ModelBuilder c4ModelBuilder = C4Model.builder(new Workspace(this.getClass().getSimpleName(), null));
final Set<ArtifactContainer> artifactContainers = application.getContainersOfType(containerType1);
assertThat(artifactContainers).hasSize(1);
final ArtifactContainer defaultContainer = artifactContainers.iterator().next();
application.getBuildingBlocksOfType(buildingBlockType1).forEach(c4ModelBuilder::artifact);
c4ModelBuilder.artifactRule().predicate(artifact -> artifact.getName().equals("Class1ForBuildingBlockType1")).computation((artifact, lookup) -> Set.of(lookup.container(defaultContainer).addComponent("CustomName1", null, "CustomTechnology1"), lookup.container(defaultContainer).addComponent("CustomName2", null, "CustomTechnology2")));
final C4Model c4Model = c4ModelBuilder.build();
final Set<Container> containers = c4Model.softwareSystem().getContainers();
assertThat(containers).hasSize(1).extracting(Container::getName, Container::getTechnology).containsExactly(tuple("DefaultContainer", "ContainerType1"));
final Set<Component> components = containers.iterator().next().getComponents();
assertThat(components).hasSize(2).extracting(Component::getName, Component::getTechnology).containsExactlyInAnyOrder(tuple("CustomName1", "CustomTechnology1"), tuple("CustomName2", "CustomTechnology2"));
}
use of com.structurizr.model.Container in project tutorials by eugenp.
the class StructurizrSimple method addSpringComponents.
private static void addSpringComponents(Workspace workspace) throws Exception {
Container jvm2 = workspace.getModel().getSoftwareSystemWithName(PAYMENT_TERMINAL).getContainerWithName("JVM-2");
findComponents(jvm2);
ComponentView view = workspace.getViews().createComponentView(jvm2, JVM2_COMPONENT_VIEW, "JVM2ComponentView");
view.addAllComponents();
}
use of com.structurizr.model.Container in project tutorials by eugenp.
the class StructurizrSimple method addComponents.
private static void addComponents(Workspace workspace) {
Model model = workspace.getModel();
SoftwareSystem paymentTerminal = model.getSoftwareSystemWithName(PAYMENT_TERMINAL);
Container jvm1 = paymentTerminal.getContainerWithName("JVM-1");
Component jaxrs = jvm1.addComponent("jaxrs-jersey", "restful webservice implementation", "rest");
Component gemfire = jvm1.addComponent("gemfire", "Clustered Cache Gemfire", "cache");
Component hibernate = jvm1.addComponent("hibernate", "Data Access Layer", "jpa");
jaxrs.uses(gemfire, "");
gemfire.uses(hibernate, "");
ComponentView componentView = workspace.getViews().createComponentView(jvm1, COMPONENT_VIEW, "JVM Components");
componentView.addAllComponents();
}
use of com.structurizr.model.Container in project cia by Hack23.
the class AwsPublicSystemDocumentation method main.
/**
* The main method.
*
* @param args
* the arguments
* @throws Exception
* the exception
*/
public static void main(final String[] args) throws Exception {
final Workspace workspace = new Workspace("Citizen Intelligence Agency", "Public Aws System Documentation");
final Model model = workspace.getModel();
final ViewSet viewSet = workspace.getViews();
final SoftwareSystem ciaSystem = model.addSoftwareSystem("Citizen Intelligence Agency", "Tracking politicians like bugs!");
final DeploymentNode masterAccountNode = model.addDeploymentNode("Master Account", "AWS", "Aws Account");
final Container awsAccountContainer = ciaSystem.addContainer("Master Account", "AWS", "Aws Account");
final DeploymentNode iamAccountNode = model.addDeploymentNode("IAM Account", "AWS", "Aws Account");
final Container iamAccountContainer = ciaSystem.addContainer("IAM Account", "AWS", "Aws Account");
final DeploymentNode devAccountNode = model.addDeploymentNode("Development Account", "AWS", "Aws Account");
final Container devAccountContainer = ciaSystem.addContainer("Development Account", "AWS", "Aws Account");
final DeploymentNode opCenterAccountNode = model.addDeploymentNode("Operation Center Account", "AWS", "Aws Account");
final Container opCenterAccountContainer = ciaSystem.addContainer("Operation Center Account", "AWS", "Aws Account");
final DeploymentNode auditAccountNode = model.addDeploymentNode("Audit Account", "AWS", "Aws Account");
final Container auditAccountContainer = ciaSystem.addContainer("Audit Account", "AWS", "Aws Account");
final DeploymentNode appAccountNode = model.addDeploymentNode("Application Account", "AWS", "Aws Account");
final Container appAccountContainer = ciaSystem.addContainer("Application Account", "AWS", "Aws Account");
awsAccountContainer.uses(iamAccountContainer, "create/restrict");
awsAccountContainer.uses(devAccountContainer, "create/restrict");
awsAccountContainer.uses(opCenterAccountContainer, "create/restrict");
awsAccountContainer.uses(auditAccountContainer, "create/restrict");
awsAccountContainer.uses(appAccountContainer, "create/restrict");
awsAccountContainer.uses(auditAccountContainer, "publish event/audit");
iamAccountContainer.uses(auditAccountContainer, "publish event/audit");
devAccountContainer.uses(auditAccountContainer, "publish event/audit");
opCenterAccountContainer.uses(auditAccountContainer, "publish event/audit");
appAccountContainer.uses(auditAccountContainer, "publish event/audit");
opCenterAccountContainer.uses(auditAccountContainer, "Monitor event/audit");
iamAccountContainer.uses(devAccountContainer, "manage access");
iamAccountContainer.uses(appAccountContainer, "manage access");
iamAccountContainer.uses(opCenterAccountContainer, "manage access");
opCenterAccountNode.add(opCenterAccountContainer);
devAccountNode.add(devAccountContainer);
auditAccountNode.add(auditAccountContainer);
appAccountNode.add(appAccountContainer);
iamAccountNode.add(iamAccountContainer);
masterAccountNode.add(awsAccountContainer);
final DeploymentView developmentDeploymentView = viewSet.createDeploymentView(ciaSystem, "\"Production Aws Account structure\"", "\"Production Aws Account structure\"");
developmentDeploymentView.add(masterAccountNode);
developmentDeploymentView.add(iamAccountNode);
developmentDeploymentView.add(devAccountNode);
developmentDeploymentView.add(opCenterAccountNode);
developmentDeploymentView.add(auditAccountNode);
developmentDeploymentView.add(appAccountNode);
final Styles styles = viewSet.getConfiguration().getStyles();
styles.addElementStyle(Tags.COMPONENT).background("#1168bd").color("#ffffff");
styles.addElementStyle(Tags.CONTAINER).background("#1168bd").color("#ffffff");
styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#1168bd").color("#ffffff");
styles.addElementStyle(Tags.PERSON).background("#519823").color("#ffffff").shape(Shape.Person);
styles.addElementStyle("Database").shape(Shape.Cylinder);
printPlantUml(workspace);
System.setProperty("PLANTUML_LIMIT_SIZE", "8192");
Run.main(new String[] { Paths.get(".").toAbsolutePath().normalize().toString() + File.separator + "target" + File.separator + "site" + File.separator + "architecture" + File.separator });
}
use of com.structurizr.model.Container in project archifacts by archifacts.
the class C4ModelBuilderTest method assert_that_relationship_source_and_target_is_automatically_added_to_the_c4_model.
@Test
void assert_that_relationship_source_and_target_is_automatically_added_to_the_c4_model() {
final JavaClasses javaClasses = new ClassFileImporter().importPackages("org.archifacts.integration.c4.model.domain");
final Application application = Application.builder().descriptor(buildingBlockType1Descriptor).descriptor(defaultContainerDescriptor).descriptor(referenceDescriptor).buildApplication(javaClasses);
final C4ModelBuilder c4ModelBuilder = C4Model.builder(new Workspace(this.getClass().getSimpleName(), null));
application.getRelationships().stream().forEach(c4ModelBuilder::relationship);
final C4Model c4Model = c4ModelBuilder.build();
final Set<Container> containers = c4Model.softwareSystem().getContainers();
assertThat(containers).hasSize(1).extracting(Container::getName, Container::getTechnology).containsExactly(tuple("DefaultContainer", "ContainerType1"));
final Container container = containers.iterator().next();
final Component class1ForBuildingBlockType1 = container.getComponentWithName("Class1ForBuildingBlockType1");
assertThat(class1ForBuildingBlockType1).isNotNull();
final Component miscArtifact1 = container.getComponentWithName("MiscArtifact1");
assertThat(miscArtifact1).isNotNull();
assertThat(container.getComponents()).flatMap(Component::getRelationships).hasSize(1).extracting(Relationship::getDescription, Relationship::getSource, Relationship::getDestination).containsExactly(tuple("references", class1ForBuildingBlockType1, miscArtifact1));
}
Aggregations