use of com.structurizr.Workspace in project tutorials by eugenp.
the class StructurizrSimple method getSoftwareSystem.
private static Workspace getSoftwareSystem() {
Workspace workspace = new Workspace("Payment Gateway", "Payment Gateway");
Model model = workspace.getModel();
Person user = model.addPerson("Merchant", "Merchant");
SoftwareSystem paymentTerminal = model.addSoftwareSystem(PAYMENT_TERMINAL, "Payment Terminal");
user.uses(paymentTerminal, "Makes payment");
SoftwareSystem fraudDetector = model.addSoftwareSystem(FRAUD_DETECTOR, "Fraud Detector");
paymentTerminal.uses(fraudDetector, "Obtains fraud score");
ViewSet viewSet = workspace.getViews();
SystemContextView contextView = viewSet.createSystemContextView(workspace.getModel().getSoftwareSystemWithName(PAYMENT_TERMINAL), SOFTWARE_SYSTEM_VIEW, "Payment Gateway Diagram");
contextView.addAllElements();
return workspace;
}
use of com.structurizr.Workspace 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.Workspace 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));
}
use of com.structurizr.Workspace in project archifacts by archifacts.
the class C4ModelBuilderTest method assert_that_computation_rule_is_applied_to_container.
@Test
void assert_that_computation_rule_is_applied_to_container() {
final JavaClasses javaClasses = new ClassFileImporter().importPackages("org.archifacts.integration.c4.model.domain");
final Application application = Application.builder().descriptor(defaultContainerDescriptor).buildApplication(javaClasses);
final C4ModelBuilder c4ModelBuilder = C4Model.builder(new Workspace(this.getClass().getSimpleName(), null));
application.getArtifacts().stream().map(Artifact::getContainer).filter(Optional::isPresent).map(Optional::get).distinct().forEach(c4ModelBuilder::container);
application.getBuildingBlocksOfType(buildingBlockType1).forEach(c4ModelBuilder::artifact);
c4ModelBuilder.containerRule().predicate(a -> true).computation((container, lookup) -> Set.of(lookup.softwareSystem().addContainer("CustomName1", null, "CustomTechnology1"), lookup.softwareSystem().addContainer("CustomName2", null, "CustomTechnology2")));
final C4Model c4Model = c4ModelBuilder.build();
final Set<Container> containers = c4Model.softwareSystem().getContainers();
assertThat(containers).hasSize(2).extracting(Container::getName, Container::getTechnology).containsExactlyInAnyOrder(tuple("CustomName1", "CustomTechnology1"), tuple("CustomName2", "CustomTechnology2"));
}
use of com.structurizr.Workspace in project archifacts by archifacts.
the class C4ModelBuilderTest method assert_that_an_IllegalStateException_is_thrown_if_a_building_block_does_not_have_a_container.
@Test
void assert_that_an_IllegalStateException_is_thrown_if_a_building_block_does_not_have_a_container() {
final JavaClasses javaClasses = new ClassFileImporter().importPackages("org.archifacts.integration.c4.model.domain");
final Application application = Application.builder().descriptor(buildingBlockType1Descriptor).buildApplication(javaClasses);
final C4ModelBuilder c4ModelBuilder = C4Model.builder(new Workspace(this.getClass().getSimpleName(), null));
application.getBuildingBlocksOfType(buildingBlockType1).forEach(c4ModelBuilder::artifact);
assertThatIllegalStateException().isThrownBy(() -> c4ModelBuilder.build()).withMessage("No container present for <BuildingBlockType1> org.archifacts.integration.c4.model.domain.Class1ForBuildingBlockType1");
}
Aggregations