Search in sources :

Example 66 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem in project java by structurizr.

the class WorkspaceTests method test_countAndLogWarnings.

@Test
public void test_countAndLogWarnings() {
    Workspace workspace = new Workspace("Name", "Description");
    SoftwareSystem softwareSystem1 = workspace.getModel().addSoftwareSystem("Software System 1", null);
    SoftwareSystem softwareSystem2 = workspace.getModel().addSoftwareSystem("Software System 2", " ");
    Container container1 = softwareSystem1.addContainer("Name", "Description", null);
    Container container2 = softwareSystem2.addContainer("Name", "Description", " ");
    container1.uses(container2, null, null);
    container2.uses(container1, " ", " ");
    Component component1A = container1.addComponent("A", null, null);
    Component component1B = container1.addComponent("B", "", "");
    component1A.uses(component1B, null);
    component1B.uses(component1A, "");
    assertEquals(10, workspace.countAndLogWarnings());
}
Also used : Container(com.structurizr.model.Container) SoftwareSystem(com.structurizr.model.SoftwareSystem) Component(com.structurizr.model.Component) Test(org.junit.Test)

Example 67 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem in project java by structurizr.

the class StructurizrClientIntegrationTests method test_putAndGetWorkspace_WithoutEncryption.

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

Example 68 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem 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)

Example 69 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem in project java by structurizr.

the class StaticViewTests method test_addAnimationStep_ThrowsAnException_WhenElementsAreSpecifiedButNoneOfThemExistInTheView.

@Test
public void test_addAnimationStep_ThrowsAnException_WhenElementsAreSpecifiedButNoneOfThemExistInTheView() {
    try {
        SoftwareSystem element1 = model.addSoftwareSystem("Software System 1", "");
        SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "Description");
        view.addAnimation(element1);
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("None of the specified elements exist in this view.", iae.getMessage());
    }
}
Also used : SoftwareSystem(com.structurizr.model.SoftwareSystem) Test(org.junit.Test)

Aggregations

SoftwareSystem (com.structurizr.model.SoftwareSystem)69 Test (org.junit.jupiter.api.Test)38 Container (com.structurizr.model.Container)23 Workspace (com.structurizr.Workspace)22 Test (org.junit.Test)17 Person (com.structurizr.model.Person)9 Component (com.structurizr.model.Component)8 DynamicView (com.structurizr.view.DynamicView)8 ArrayList (java.util.ArrayList)8 Model (com.structurizr.model.Model)7 DeploymentView (com.structurizr.view.DeploymentView)6 SystemContextView (com.structurizr.view.SystemContextView)6 ViewSet (com.structurizr.view.ViewSet)5 Element (com.structurizr.model.Element)4 Relationship (com.structurizr.model.Relationship)4 ContainerView (com.structurizr.view.ContainerView)4 RelationshipView (com.structurizr.view.RelationshipView)4 DeploymentNode (com.structurizr.model.DeploymentNode)3 ComponentView (com.structurizr.view.ComponentView)3 EncryptedWorkspace (com.structurizr.encryption.EncryptedWorkspace)2