void copyLayoutInformationFrom(ElementView source) { if (source != null) { setX(source.getX()); setY(source.getY()); } }
@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()); }
@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_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_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_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_CopiesXAndY_WhenANonNullElementViewIsPassed() { Element element = model.addSoftwareSystem(Location.External, "SystemA", ""); ElementView elementView1 = new ElementView(element); assertEquals(0, elementView1.getX()); assertEquals(0, elementView1.getY()); ElementView elementView2 = new ElementView(element); elementView2.setX(123); elementView2.setY(456); elementView1.copyLayoutInformationFrom(elementView2); assertEquals(123, elementView1.getX()); assertEquals(456, elementView1.getY()); }
view1.getElementView(softwareSystem1B).setX(123); view1.getElementView(softwareSystem1B).setY(321); view1.add(person1); view1.getElementView(person1).setX(456); view1.getElementView(person1).setY(654); view1.getRelationshipView(personUsesSoftwareSystem1).setVertices(Arrays.asList(new Vertex(123, 456)));