@Test public void test_addAllElements_DoesNothing_WhenThereAreNoSoftwareSystemsOrPeople() { assertEquals(0, view.getElements().size()); view.addAllElements(); assertEquals(0, view.getElements().size()); }
@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_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_addAllElements_AddsAllSoftwareSystemsAndPeopleAndContainersAndComponents_WhenThereAreSomeSoftwareSystemsAndPeopleAndContainersAndComponentsInTheModel() { SoftwareSystem softwareSystemA = model.addSoftwareSystem(Location.External, "System A", "Description"); SoftwareSystem softwareSystemB = model.addSoftwareSystem(Location.External, "System B", "Description"); Person userA = model.addPerson(Location.External, "User A", "Description"); Person userB = model.addPerson(Location.External, "User B", "Description"); Container database = softwareSystem.addContainer("Database", "Does something", "MySQL"); Component componentA = webApplication.addComponent("Component A", "Does something", "Java"); Component componentB = webApplication.addComponent("Component B", "Does something", "Java"); view.addAllElements(); assertEquals(7, view.getElements().size()); assertTrue(view.getElements().contains(new ElementView(softwareSystemA))); assertTrue(view.getElements().contains(new ElementView(softwareSystemB))); assertTrue(view.getElements().contains(new ElementView(userA))); assertTrue(view.getElements().contains(new ElementView(userB))); assertTrue(view.getElements().contains(new ElementView(database))); assertTrue(view.getElements().contains(new ElementView(componentA))); assertTrue(view.getElements().contains(new ElementView(componentB))); }
componentView.addAllElements();
componentView.addAllElements();