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());
}
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());
}
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());
}
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);
}
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()));
}
Aggregations