Search in sources :

Example 26 with SoftwareSystem

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

the class DefaultLayoutMergeStrategyTests method test_copyLayoutInformation_WhenAnElementNameHasChangedButTheDescriptionHasNotChanged.

@Test
public void test_copyLayoutInformation_WhenAnElementNameHasChangedButTheDescriptionHasNotChanged() {
    Workspace workspace1 = new Workspace("1", "");
    SoftwareSystem softwareSystem1 = workspace1.getModel().addSoftwareSystem("Software System");
    Container container1 = softwareSystem1.addContainer("Container", "Container description", "");
    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");
    Container container2 = softwareSystem2.addContainer("Container with a new name", "Container description", "");
    ContainerView view2 = workspace2.getViews().createContainerView(softwareSystem2, "key", "");
    view2.add(container2);
    DefaultLayoutMergeStrategy strategy = new DefaultLayoutMergeStrategy();
    strategy.copyLayoutInformation(view1, view2);
    assertEquals(123, view2.getElementView(container2).getX());
    assertEquals(456, 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 27 with SoftwareSystem

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

the class DefaultLayoutMergeStrategyTests method test_copyLayoutInformation_WhenAnElementNameAndDescriptionHaveChangedButTheIdHasNotChanged.

@Test
public void test_copyLayoutInformation_WhenAnElementNameAndDescriptionHaveChangedButTheIdHasNotChanged() {
    Workspace workspace1 = new Workspace("1", "");
    SoftwareSystem softwareSystem1 = workspace1.getModel().addSoftwareSystem("Software System");
    Container container1 = softwareSystem1.addContainer("Container", "Container description", "");
    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");
    Container container2 = softwareSystem2.addContainer("Container with a new name", "Container with a new description", "");
    ContainerView view2 = workspace2.getViews().createContainerView(softwareSystem2, "key", "");
    view2.add(container2);
    DefaultLayoutMergeStrategy strategy = new DefaultLayoutMergeStrategy();
    strategy.copyLayoutInformation(view1, view2);
    assertEquals(123, view2.getElementView(container2).getX());
    assertEquals(456, 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 28 with SoftwareSystem

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

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

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

the class StaticViewTests method test_addAnimationStep.

@Test
public void test_addAnimationStep() {
    SoftwareSystem element1 = model.addSoftwareSystem("Software System 1", "");
    SoftwareSystem element2 = model.addSoftwareSystem("Software System 2", "");
    SoftwareSystem element3 = model.addSoftwareSystem("Software System 3", "");
    Relationship relationship1_2 = element1.uses(element2, "uses");
    Relationship relationship2_3 = element2.uses(element3, "uses");
    SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "Description");
    view.addAllElements();
    view.addAnimation(element1);
    view.addAnimation(element2);
    view.addAnimation(element3);
    Animation step1 = view.getAnimations().stream().filter(step -> step.getOrder() == 1).findFirst().get();
    assertEquals(1, step1.getElements().size());
    assertTrue(step1.getElements().contains(element1.getId()));
    assertEquals(0, step1.getRelationships().size());
    Animation step2 = view.getAnimations().stream().filter(step -> step.getOrder() == 2).findFirst().get();
    assertEquals(1, step2.getElements().size());
    assertTrue(step2.getElements().contains(element2.getId()));
    assertEquals(1, step2.getRelationships().size());
    assertTrue(step2.getRelationships().contains(relationship1_2.getId()));
    Animation step3 = view.getAnimations().stream().filter(step -> step.getOrder() == 3).findFirst().get();
    assertEquals(1, step3.getElements().size());
    assertTrue(step3.getElements().contains(element3.getId()));
    assertEquals(1, step3.getRelationships().size());
    assertTrue(step3.getRelationships().contains(relationship2_3.getId()));
}
Also used : Relationship(com.structurizr.model.Relationship) 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