@Test public void test_copyLayoutInformationFrom_DoesNotDoAnythingIfThereIsNoDeploymentViewToCopyInformationFrom() { Workspace workspace1 = createWorkspace(); Workspace workspace2 = createWorkspace(); DeploymentNode deploymentNode2 = workspace2.getModel().getDeploymentNodeWithName("Deployment Node"); DeploymentView view2 = workspace2.getViews().createDeploymentView("key", "Description"); view2.add(deploymentNode2); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(0, view2.getElements().stream().filter(ev -> ev.getElement() instanceof ContainerInstance).findFirst().get().getX()); // default assertEquals(0, view2.getElements().stream().filter(ev -> ev.getElement() instanceof ContainerInstance).findFirst().get().getY()); // default assertNull(view2.getPaperSize()); // default }
@Test public void test_copyLayoutInformationFrom_WhenTheDeploymentViewKeysMatch() { Workspace workspace1 = createWorkspace(); DeploymentNode deploymentNode1 = workspace1.getModel().getDeploymentNodeWithName("Deployment Node"); DeploymentView view1 = workspace1.getViews().createDeploymentView("key", "Description"); view1.add(deploymentNode1); view1.getElements().stream().filter(ev -> ev.getElement() instanceof ContainerInstance).findFirst().get().setX(100); view1.getElements().stream().filter(ev -> ev.getElement() instanceof ContainerInstance).findFirst().get().setY(200); view1.setPaperSize(PaperSize.A3_Landscape); Workspace workspace2 = createWorkspace(); DeploymentNode deploymentNode2 = workspace2.getModel().getDeploymentNodeWithName("Deployment Node"); DeploymentView view2 = workspace2.getViews().createDeploymentView("key", "Description"); view2.add(deploymentNode2); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(100, view2.getElements().stream().filter(ev -> ev.getElement() instanceof ContainerInstance).findFirst().get().getX()); assertEquals(200, view2.getElements().stream().filter(ev -> ev.getElement() instanceof ContainerInstance).findFirst().get().getY()); assertEquals(PaperSize.A3_Landscape, view2.getPaperSize()); }
Workspace remoteWorkspace = getWorkspace(workspaceId); if (remoteWorkspace != null) { workspace.getViews().copyLayoutInformationFrom(remoteWorkspace.getViews()); workspace.getViews().getConfiguration().copyConfigurationFrom(remoteWorkspace.getViews().getConfiguration());
@Test public void test_copyLayoutInformationFrom_DoesNotDoAnythingIfThereIsNoSystemContextViewToCopyInformationFrom() { Workspace workspace1 = createWorkspace(); Workspace workspace2 = createWorkspace(); SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System"); SystemContextView view2 = workspace2.getViews().createSystemContextView(softwareSystem2, "context", "Description"); view2.addAllElements(); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(0, view2.getElements().iterator().next().getX()); // default assertNull(view2.getPaperSize()); // default }
@Test public void test_copyLayoutInformationFrom_DoesNotDoAnythingIfThereIsNoContainerViewToCopyInformationFrom() { Workspace workspace1 = createWorkspace(); Workspace workspace2 = createWorkspace(); SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System"); ContainerView view2 = workspace2.getViews().createContainerView(softwareSystem2, "containers", "Description"); view2.addAllElements(); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(0, view2.getElements().iterator().next().getX()); // default assertNull(view2.getPaperSize()); // default }
@Test public void test_copyLayoutInformationFrom_DoesNotDoAnythingIfThereIsNoSystemLandscapeViewToCopyInformationFrom() { Workspace workspace1 = createWorkspace(); Workspace workspace2 = createWorkspace(); SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System"); SystemLandscapeView view2 = workspace2.getViews().createSystemLandscapeView("landscape", "Description"); view2.addAllElements(); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(0, view2.getElements().iterator().next().getX()); // default assertNull(view2.getPaperSize()); // default }
@Test public void test_copyLayoutInformationFrom_DoesNotDoAnythingIfThereIsNoComponentViewToCopyInformationFrom() { Workspace workspace1 = createWorkspace(); Workspace workspace2 = createWorkspace(); Container container2 = workspace2.getModel().getSoftwareSystemWithName("Software System").getContainerWithName("Container"); ComponentView view2 = workspace2.getViews().createComponentView(container2, "components", "Description"); view2.addAllElements(); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(0, view2.getElements().iterator().next().getX()); // default assertNull(view2.getPaperSize()); // default }
@Test public void test_copyLayoutInformationFrom_DoesNotDoAnythingIfThereIsNoDynamicViewToCopyInformationFrom() { Workspace workspace1 = createWorkspace(); Workspace workspace2 = createWorkspace(); Person person2 = workspace2.getModel().getPersonWithName("Person"); SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System"); DynamicView view2 = workspace2.getViews().createDynamicView("context", "Description"); view2.add(person2, softwareSystem2); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(0, view2.getElements().iterator().next().getX()); // default assertNull(view2.getPaperSize()); // default }
@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()); }
@Test public void test_copyLayoutInformationFrom_WhenTheSystemContextViewKeysMatch() { Workspace workspace1 = createWorkspace(); SoftwareSystem softwareSystem1 = workspace1.getModel().getSoftwareSystemWithName("Software System"); SystemContextView view1 = workspace1.getViews().createSystemContextView(softwareSystem1, "context", "Description"); view1.addAllElements(); view1.getElements().iterator().next().setX(100); view1.setPaperSize(PaperSize.A3_Landscape); Workspace workspace2 = createWorkspace(); SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System"); SystemContextView view2 = workspace2.getViews().createSystemContextView(softwareSystem2, "context", "Description"); view2.addAllElements(); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(100, view2.getElements().iterator().next().getX()); assertEquals(PaperSize.A3_Landscape, view2.getPaperSize()); }
@Test public void test_copyLayoutInformationFrom_WhenTheContainerViewKeysMatch() { Workspace workspace1 = createWorkspace(); SoftwareSystem softwareSystem1 = workspace1.getModel().getSoftwareSystemWithName("Software System"); ContainerView view1 = workspace1.getViews().createContainerView(softwareSystem1, "containers", "Description"); view1.addAllElements(); view1.getElements().iterator().next().setX(100); view1.setPaperSize(PaperSize.A3_Landscape); Workspace workspace2 = createWorkspace(); SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System"); ContainerView view2 = workspace2.getViews().createContainerView(softwareSystem2, "containers", "Description"); view2.addAllElements(); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(100, view2.getElements().iterator().next().getX()); assertEquals(PaperSize.A3_Landscape, view2.getPaperSize()); }
@Test public void test_copyLayoutInformationFrom_WhenAViewKeyHasBeenIntroduced() { Workspace workspace1 = createWorkspace(); SoftwareSystem softwareSystem1 = workspace1.getModel().getSoftwareSystemWithName("Software System"); SystemContextView view1 = workspace1.getViews().createSystemContextView(softwareSystem1, "context", "Description"); view1.setKey(null); // this simulates views created by previous versions of the client library view1.addAllElements(); view1.getElements().iterator().next().setX(100); view1.setPaperSize(PaperSize.A3_Landscape); Workspace workspace2 = createWorkspace(); SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System"); SystemContextView view2 = workspace2.getViews().createSystemContextView(softwareSystem2, "context", "Description"); view2.addAllElements(); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(100, view2.getElements().iterator().next().getX()); assertEquals(PaperSize.A3_Landscape, view2.getPaperSize()); }
@Test public void test_copyLayoutInformationFrom_WhenTheComponentViewKeysMatch() { Workspace workspace1 = createWorkspace(); Container container1 = workspace1.getModel().getSoftwareSystemWithName("Software System").getContainerWithName("Container"); ComponentView view1 = workspace1.getViews().createComponentView(container1, "containers", "Description"); view1.addAllElements(); view1.getElements().iterator().next().setX(100); view1.setPaperSize(PaperSize.A3_Landscape); Workspace workspace2 = createWorkspace(); Container container2 = workspace2.getModel().getSoftwareSystemWithName("Software System").getContainerWithName("Container"); ComponentView view2 = workspace2.getViews().createComponentView(container2, "containers", "Description"); view2.addAllElements(); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(100, view2.getElements().iterator().next().getX()); assertEquals(PaperSize.A3_Landscape, view2.getPaperSize()); }
@Test public void test_copyLayoutInformationFrom_WhenAViewKeyIsNotSetButTheViewTitlesMatch() { Workspace workspace1 = createWorkspace(); SoftwareSystem softwareSystem1 = workspace1.getModel().getSoftwareSystemWithName("Software System"); SystemContextView view1 = workspace1.getViews().createSystemContextView(softwareSystem1, "context", "Description"); view1.setKey(null); // this simulates views created by previous versions of the client library view1.addAllElements(); view1.getElements().iterator().next().setX(100); view1.setPaperSize(PaperSize.A3_Landscape); Workspace workspace2 = createWorkspace(); SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System"); SystemContextView view2 = workspace2.getViews().createSystemContextView(softwareSystem2, "context", "Description"); view2.setKey(null); // this simulates views created by previous versions of the client library view2.addAllElements(); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(100, view2.getElements().iterator().next().getX()); assertEquals(PaperSize.A3_Landscape, view2.getPaperSize()); }
@Test public void test_copyLayoutInformationFrom_WhenTheDynamicViewKeysMatch() { Workspace workspace1 = createWorkspace(); Person person1 = workspace1.getModel().getPersonWithName("Person"); SoftwareSystem softwareSystem1 = workspace1.getModel().getSoftwareSystemWithName("Software System"); DynamicView view1 = workspace1.getViews().createDynamicView("context", "Description"); view1.add(person1, softwareSystem1); view1.getElements().iterator().next().setX(100); view1.setPaperSize(PaperSize.A3_Landscape); Workspace workspace2 = createWorkspace(); Person person2 = workspace2.getModel().getPersonWithName("Person"); SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System"); DynamicView view2 = workspace2.getViews().createDynamicView("context", "Description"); view2.add(person2, softwareSystem2); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(100, view2.getElements().iterator().next().getX()); assertEquals(PaperSize.A3_Landscape, view2.getPaperSize()); }
@Test public void test_copyLayoutInformationFrom_CopiesThePaperSize_WhenThePaperSizeIsNotSet() { Workspace workspace1 = createWorkspace(); SoftwareSystem softwareSystem1 = workspace1.getModel().getSoftwareSystemWithName("Software System"); SystemContextView view1 = workspace1.getViews().createSystemContextView(softwareSystem1, "context", "Description"); view1.setPaperSize(PaperSize.A3_Landscape); Workspace workspace2 = createWorkspace(); SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System"); SystemContextView view2 = workspace2.getViews().createSystemContextView(softwareSystem2, "context", "Description"); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(PaperSize.A3_Landscape, view2.getPaperSize()); }
@Test public void test_copyLayoutInformationFrom_IgnoresThePaperSize_WhenThePaperSizeIsSet() { Workspace workspace1 = createWorkspace(); SoftwareSystem softwareSystem1 = workspace1.getModel().getSoftwareSystemWithName("Software System"); SystemContextView view1 = workspace1.getViews().createSystemContextView(softwareSystem1, "context", "Description"); view1.setPaperSize(PaperSize.A3_Landscape); Workspace workspace2 = createWorkspace(); SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System"); SystemContextView view2 = workspace2.getViews().createSystemContextView(softwareSystem2, "context", "Description"); view2.setPaperSize(PaperSize.A5_Portrait); workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews()); assertEquals(PaperSize.A5_Portrait, view2.getPaperSize()); }