Search in sources :

Example 41 with Workspace

use of com.structurizr.Workspace in project java by structurizr.

the class ViewSetTests method test_copyLayoutInformationFrom_WhenTheSystemLandscapeViewKeysMatch.

@Test
public void test_copyLayoutInformationFrom_WhenTheSystemLandscapeViewKeysMatch() {
    Workspace workspace1 = createWorkspace();
    SoftwareSystem softwareSystem1 = workspace1.getModel().getSoftwareSystemWithName("Software System");
    SystemLandscapeView view1 = workspace1.getViews().createSystemLandscapeView("landscape", "Description");
    view1.addAllElements();
    view1.getElements().iterator().next().setX(100);
    view1.setPaperSize(PaperSize.A3_Landscape);
    Workspace workspace2 = createWorkspace();
    SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System");
    SystemLandscapeView view2 = workspace2.getViews().createSystemLandscapeView("context", "Description");
    view2.addAllElements();
    workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews());
    assertEquals(100, view2.getElements().iterator().next().getX());
    assertEquals(PaperSize.A3_Landscape, view2.getPaperSize());
}
Also used : Workspace(com.structurizr.Workspace) Test(org.junit.Test)

Example 42 with Workspace

use of com.structurizr.Workspace in project java by structurizr.

the class ViewSetTests method test_createDynamicViewForSoftwareSystem.

@Test
public void test_createDynamicViewForSoftwareSystem() {
    Workspace workspace = new Workspace("Name", "Description");
    SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Name", "Description");
    DynamicView dynamicView = workspace.getViews().createDynamicView(softwareSystem, "key", "Description");
    assertEquals("key", dynamicView.getKey());
    assertEquals("Description", dynamicView.getDescription());
    assertSame(softwareSystem, dynamicView.getSoftwareSystem());
    assertSame(softwareSystem, dynamicView.getElement());
}
Also used : Workspace(com.structurizr.Workspace) Test(org.junit.Test)

Example 43 with Workspace

use of com.structurizr.Workspace in project java by structurizr.

the class ViewSetTests method test_createContainerView_ThrowsAnException_WhenADuplicateKeyIsSpecified.

@Test
public void test_createContainerView_ThrowsAnException_WhenADuplicateKeyIsSpecified() {
    try {
        Workspace workspace = new Workspace("Name", "Description");
        SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description");
        workspace.getViews().createContainerView(softwareSystem, "key", "Description");
        workspace.getViews().createContainerView(softwareSystem, "key", "Description");
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("A view with the key key already exists.", iae.getMessage());
    }
}
Also used : Workspace(com.structurizr.Workspace) Test(org.junit.Test)

Example 44 with Workspace

use of com.structurizr.Workspace in project java by structurizr.

the class ViewSetTests method test_createSystemContextView.

@Test
public void test_createSystemContextView() {
    Workspace workspace = new Workspace("Name", "Description");
    SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description");
    SystemContextView systemContextView = workspace.getViews().createSystemContextView(softwareSystem, "key", "Description");
    assertEquals("key", systemContextView.getKey());
    assertEquals("Description", systemContextView.getDescription());
    assertSame(softwareSystem, systemContextView.getSoftwareSystem());
}
Also used : Workspace(com.structurizr.Workspace) Test(org.junit.Test)

Example 45 with Workspace

use of com.structurizr.Workspace in project java by structurizr.

the class ViewSetTests method createWorkspace.

private Workspace createWorkspace() {
    Workspace workspace = new Workspace("Name", "Description");
    Model model = workspace.getModel();
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
    Person person = model.addPerson("Person", "Description");
    person.uses(softwareSystem, "Uses");
    Container container = softwareSystem.addContainer("Container", "Description", "Technology");
    Component component = container.addComponent("Component", "Description", "Technology");
    DeploymentNode deploymentNode = model.addDeploymentNode("Deployment Node", "Description", "Technology");
    ContainerInstance containerInstance = deploymentNode.add(container);
    return workspace;
}
Also used : Workspace(com.structurizr.Workspace)

Aggregations

Workspace (com.structurizr.Workspace)155 Test (org.junit.Test)98 Test (org.junit.jupiter.api.Test)36 File (java.io.File)23 Container (com.structurizr.model.Container)22 SoftwareSystem (com.structurizr.model.SoftwareSystem)22 Component (com.structurizr.model.Component)12 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)12 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)12 Application (org.archifacts.core.model.Application)12 ArtifactContainer (org.archifacts.core.model.ArtifactContainer)10 ArrayList (java.util.ArrayList)6 EncryptedWorkspace (com.structurizr.encryption.EncryptedWorkspace)5 Element (com.structurizr.model.Element)5 Model (com.structurizr.model.Model)5 Artifact (org.archifacts.core.model.Artifact)5 MiscArtifact (org.archifacts.core.model.MiscArtifact)5 Person (com.structurizr.model.Person)4 Relationship (com.structurizr.model.Relationship)4 SystemContextView (com.structurizr.view.SystemContextView)4