Search in sources :

Example 31 with Workspace

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

the class DefaultLayoutMergeStrategyTests method test_copyLayoutInformation_WhenAnElementNameAndDescriptionAndIdHaveChangedAndDescriptionWasNull.

@Test
public void test_copyLayoutInformation_WhenAnElementNameAndDescriptionAndIdHaveChangedAndDescriptionWasNull() {
    Workspace workspace1 = new Workspace("1", "");
    SoftwareSystem softwareSystem1 = workspace1.getModel().addSoftwareSystem("Software System");
    Container container1 = softwareSystem1.addContainer("Container");
    container1.setDescription(null);
    ContainerView view1 = workspace1.getViews().createContainerView(softwareSystem1, "key", "");
    view1.add(container1);
    view1.getElementView(container1).setX(123);
    view1.getElementView(container1).setY(456);
    Workspace workspace2 = new Workspace("2", "");
    SoftwareSystem softwareSystem2 = workspace2.getModel().addSoftwareSystem("Software System");
    // this element has ID 2
    softwareSystem2.addContainer("Web Application", "Description", "");
    Container container2 = softwareSystem2.addContainer("Database", "Description", "");
    ContainerView view2 = workspace2.getViews().createContainerView(softwareSystem2, "key", "");
    view2.add(container2);
    DefaultLayoutMergeStrategy strategy = new DefaultLayoutMergeStrategy();
    strategy.copyLayoutInformation(view1, view2);
    assertEquals(0, view2.getElementView(container2).getX());
    assertEquals(0, view2.getElementView(container2).getY());
}
Also used : Container(com.structurizr.model.Container) SoftwareSystem(com.structurizr.model.SoftwareSystem) Workspace(com.structurizr.Workspace) Test(org.junit.Test)

Example 32 with Workspace

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

the class DefaultLayoutMergeStrategyTests method test_copyLayoutInformation_DoesNotThrowAnExceptionWhenAddingAnElementToAView.

@Test
public void test_copyLayoutInformation_DoesNotThrowAnExceptionWhenAddingAnElementToAView() {
    Workspace workspace1 = new Workspace("1", "");
    SoftwareSystem softwareSystem1A = workspace1.getModel().addSoftwareSystem("Software System A");
    SoftwareSystem softwareSystem1B = workspace1.getModel().addSoftwareSystem("Software System B");
    softwareSystem1A.uses(softwareSystem1B, "Uses");
    SystemLandscapeView view1 = workspace1.getViews().createSystemLandscapeView("key", "description");
    view1.add(softwareSystem1A);
    Workspace workspace2 = new Workspace("2", "");
    SoftwareSystem softwareSystem2A = workspace2.getModel().addSoftwareSystem("Software System A");
    SoftwareSystem softwareSystem2B = workspace2.getModel().addSoftwareSystem("Software System B");
    softwareSystem2A.uses(softwareSystem2B, "Uses");
    SystemLandscapeView view2 = workspace2.getViews().createSystemLandscapeView("key", "description");
    view2.add(softwareSystem2A);
    view2.add(softwareSystem2B);
    DefaultLayoutMergeStrategy strategy = new DefaultLayoutMergeStrategy();
    strategy.copyLayoutInformation(view1, view2);
}
Also used : SoftwareSystem(com.structurizr.model.SoftwareSystem) Workspace(com.structurizr.Workspace) Test(org.junit.Test)

Example 33 with Workspace

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

the class StructurizrClientTests method test_putWorkspace_ThrowsAnException_WhenTheWorkspaceIdIsNotValid.

@Test
public void test_putWorkspace_ThrowsAnException_WhenTheWorkspaceIdIsNotValid() throws Exception {
    try {
        structurizrClient = new StructurizrClient("key", "secret");
        structurizrClient.putWorkspace(0, new Workspace("Name", "Description"));
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("The workspace ID must be a positive integer.", iae.getMessage());
    }
}
Also used : Workspace(com.structurizr.Workspace) Test(org.junit.Test)

Example 34 with Workspace

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

the class ViewSetTests method test_createDynamicView.

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

Example 35 with Workspace

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

the class ViewSetTests method test_createSystemLandscapeView.

@Test
public void test_createSystemLandscapeView() {
    Workspace workspace = new Workspace("Name", "Description");
    SystemLandscapeView systemLandscapeView = workspace.getViews().createSystemLandscapeView("key", "Description");
    assertEquals("key", systemLandscapeView.getKey());
    assertEquals("Description", systemLandscapeView.getDescription());
}
Also used : Workspace(com.structurizr.Workspace) Test(org.junit.Test)

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