Search in sources :

Example 11 with SystemContextView

use of com.structurizr.view.SystemContextView in project java by structurizr.

the class StructurizrClientIntegrationTests method test_putAndGetWorkspace_WithEncryption.

@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);
    assertNotNull(workspace.getModel().getSoftwareSystemWithName("Software System"));
    assertNotNull(workspace.getModel().getPersonWithName("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);
    assertEquals(1, workspaceArchiveLocation.listFiles().length);
}
Also used : AesEncryptionStrategy(com.structurizr.encryption.AesEncryptionStrategy) EncryptedJsonReader(com.structurizr.io.json.EncryptedJsonReader) SystemContextView(com.structurizr.view.SystemContextView) SoftwareSystem(com.structurizr.model.SoftwareSystem) EncryptedWorkspace(com.structurizr.encryption.EncryptedWorkspace) FileReader(java.io.FileReader) Person(com.structurizr.model.Person) Workspace(com.structurizr.Workspace) EncryptedWorkspace(com.structurizr.encryption.EncryptedWorkspace) Test(org.junit.Test)

Aggregations

SystemContextView (com.structurizr.view.SystemContextView)11 SoftwareSystem (com.structurizr.model.SoftwareSystem)6 Workspace (com.structurizr.Workspace)5 Person (com.structurizr.model.Person)4 ComponentView (com.structurizr.view.ComponentView)4 Test (org.junit.jupiter.api.Test)4 ContainerView (com.structurizr.view.ContainerView)3 ViewSet (com.structurizr.view.ViewSet)3 EncryptedWorkspace (com.structurizr.encryption.EncryptedWorkspace)2 EncryptedJsonReader (com.structurizr.io.json.EncryptedJsonReader)2 Model (com.structurizr.model.Model)2 SystemLandscapeView (com.structurizr.view.SystemLandscapeView)2 FileReader (java.io.FileReader)2 Test (org.junit.Test)2 ComponentFinder (com.structurizr.analysis.ComponentFinder)1 StructurizrAnnotationsComponentFinderStrategy (com.structurizr.analysis.StructurizrAnnotationsComponentFinderStrategy)1 StructurizrDslParser (com.structurizr.dsl.StructurizrDslParser)1 StructurizrDslParserException (com.structurizr.dsl.StructurizrDslParserException)1 AesEncryptionStrategy (com.structurizr.encryption.AesEncryptionStrategy)1 Diagram (com.structurizr.export.Diagram)1