/** * Writes the views in the given workspace as DOT notation, to the specified Writer. * * @param workspace the workspace containing the views to be written * @param writer the Writer to write to */ public void write(Workspace workspace, Writer writer) { workspace.getViews().getSystemContextViews().forEach(v -> write(v, null, writer)); workspace.getViews().getContainerViews().forEach(v -> write(v, v.getSoftwareSystem(), writer)); workspace.getViews().getComponentViews().forEach(v -> write(v, v.getContainer(), writer)); }
/** * Writes the views in the given workspace as PlantUML definitions, to the specified writer. * * @param workspace the workspace containing the views to be written * @param writer the Writer to write to */ public void write(Workspace workspace, Writer writer) { if (workspace == null) { throw new IllegalArgumentException("A workspace must be provided."); } if (writer == null) { throw new IllegalArgumentException("A writer must be provided."); } workspace.getViews().getSystemLandscapeViews().forEach(v -> write(v, writer)); workspace.getViews().getSystemContextViews().forEach(v -> write(v, writer)); workspace.getViews().getContainerViews().forEach(v -> write(v, writer)); workspace.getViews().getComponentViews().forEach(v -> write(v, writer)); workspace.getViews().getDynamicViews().forEach(v -> write(v, writer)); workspace.getViews().getDeploymentViews().forEach(v -> write(v, writer)); }
@Test public void test_writeSystemContextView() throws Exception { populateWorkspace(); SystemContextView systemContextView = workspace.getViews().getSystemContextViews() .stream().findFirst().get(); plantUMLWriter.write(systemContextView, stringWriter); assertEquals(SYSTEM_CONTEXT_VIEW, stringWriter.toString()); }
.filter(v -> v.getKey() == null) .forEach(v -> warnings.add("System Landscape view \"" + v.getName() + "\": Missing key")); getViews().getSystemContextViews().stream() .filter(v -> v.getKey() == null) .forEach(v -> warnings.add("System Context view \"" + v.getName() + "\": Missing key"));
SystemContextView sourceView = findView(source.getSystemContextViews(), view); if (sourceView != null) { view.copyLayoutInformationFrom(sourceView);
@Test public void test_putAndGetWorkspace_WithoutEncryption() throws Exception { Workspace workspace = new Workspace("Structurizr client library tests - without encryption", "A test workspace for the Structurizr client library"); SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description"); Person person = workspace.getModel().addPerson("Person", "Description"); person.uses(softwareSystem, "Uses"); SystemContextView systemContextView = workspace.getViews().createSystemContextView(softwareSystem, "SystemContext", "Description"); systemContextView.addAllElements(); structurizrClient.putWorkspace(20081, workspace); workspace = structurizrClient.getWorkspace(20081); assertTrue(workspace.getModel().contains(softwareSystem)); assertTrue(workspace.getModel().contains(person)); assertEquals(1, workspace.getModel().getRelationships().size()); assertEquals(1, workspace.getViews().getSystemContextViews().size()); // and check the archive version is readable Workspace archivedWorkspace = new JsonReader().read(new FileReader(getArchivedWorkspace())); assertEquals(20081, archivedWorkspace.getId()); assertEquals("Structurizr client library tests - without encryption", archivedWorkspace.getName()); assertEquals(1, archivedWorkspace.getModel().getSoftwareSystems().size()); }
@Test public void test_putAndGetWorkspace_WithEncryption() throws Exception { structurizrClient.setEncryptionStrategy(new AesEncryptionStrategy("password")); Workspace workspace = new Workspace("Structurizr client library tests - with encryption", "A test workspace for the Structurizr client library"); SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description"); Person person = workspace.getModel().addPerson("Person", "Description"); person.uses(softwareSystem, "Uses"); SystemContextView systemContextView = workspace.getViews().createSystemContextView(softwareSystem, "SystemContext", "Description"); systemContextView.addAllElements(); structurizrClient.putWorkspace(20081, workspace); workspace = structurizrClient.getWorkspace(20081); assertTrue(workspace.getModel().contains(softwareSystem)); assertTrue(workspace.getModel().contains(person)); assertEquals(1, workspace.getModel().getRelationships().size()); assertEquals(1, workspace.getViews().getSystemContextViews().size()); // and check the archive version is readable EncryptedWorkspace archivedWorkspace = new EncryptedJsonReader().read(new FileReader(getArchivedWorkspace())); assertEquals(20081, archivedWorkspace.getId()); assertEquals("Structurizr client library tests - with encryption", archivedWorkspace.getName()); assertTrue(archivedWorkspace.getEncryptionStrategy() instanceof AesEncryptionStrategy); }