@Test public void test_add_ThrowsAnException_WhenTheScopeOfTheDynamicViewIsASoftwareSystemAndTheSameSoftwareSystemIsAdded() { try { DynamicView dynamicView = workspace.getViews().createDynamicView(softwareSystemA, "key", "Description"); dynamicView.add(softwareSystemA, containerA1); fail(); } catch (Exception e) { assertEquals("Software System A is already the scope of this view and cannot be added to it.", e.getMessage()); } }
@Test public void test_add_ThrowsAnException_WhenTheScopeOfTheDynamicViewIsASoftwareSystemButAComponentIsAdded() { try { DynamicView dynamicView = workspace.getViews().createDynamicView(softwareSystemA, "key", "Description"); dynamicView.add(componentA1, containerA1); fail(); } catch (Exception e) { assertEquals("Components can't be added to a dynamic view when the scope is a software system.", e.getMessage()); } }
@Test public void test_createDynamicView_ThrowsAnException_WhenANullKeyIsSpecified() { try { Workspace workspace = new Workspace("Name", "Description"); workspace.getViews().createDynamicView(null, "Description"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A key must be specified.", iae.getMessage()); } }
@Test public void test_createDynamicView_ThrowsAnException_WhenAnEmptyKeyIsSpecified() { try { Workspace workspace = new Workspace("Name", "Description"); workspace.getViews().createDynamicView(" ", "Description"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A key must be specified.", iae.getMessage()); } }
@Test public void test_createDynamicViewForAContainer_ThrowsAnException_WhenANullContainerIsSpecified() { try { new Workspace("", "").getViews().createDynamicView((Container)null, "key", "Description"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A container must be specified.", iae.getMessage()); } }
@Test public void test_add_ThrowsAnException_WhenPassedANullDestinationElement() { try { DynamicView dynamicView = workspace.getViews().createDynamicView("key", "Description"); dynamicView.add(person, null); fail(); } catch (IllegalArgumentException iae) { assertEquals("A destination element must be specified.", iae.getMessage()); } }
@Test public void test_add_ThrowsAnException_WhenTheScopeOfTheDynamicViewIsASoftwareSystemButAContainerInAnotherSoftwareSystemIsAdded() { try { DynamicView dynamicView = workspace.getViews().createDynamicView(softwareSystemA, "key", "Description"); dynamicView.add(containerB1, containerA1); fail(); } catch (Exception e) { assertEquals("Only containers that reside inside Software System A can be added to this view.", e.getMessage()); } }
@Test public void test_add_ThrowsAnException_WhenPassedANullSouceElement() { try { DynamicView dynamicView = workspace.getViews().createDynamicView("key", "Description"); dynamicView.add(null, softwareSystemA); fail(); } catch (IllegalArgumentException iae) { assertEquals("A source element must be specified.", iae.getMessage()); } }
@Test public void test_add_ThrowsAnException_WhenTheScopeOfTheDynamicViewIsAContainerAndTheParentSoftwareSystemIsAdded() { try { DynamicView dynamicView = workspace.getViews().createDynamicView(containerA1, "key", "Description"); dynamicView.add(softwareSystemA, containerA2); fail(); } catch (Exception e) { assertEquals("Software System A is already the scope of this view and cannot be added to it.", e.getMessage()); } }
@Test public void test_add_ThrowsAnException_WhenTheScopeOfTheDynamicViewIsAContainerAndAContainerInAnotherSoftwareSystemIsAdded() { try { DynamicView dynamicView = workspace.getViews().createDynamicView(containerA1, "key", "Description"); dynamicView.add(containerB1, containerA2); fail(); } catch (Exception e) { assertEquals("Only containers that reside inside Software System A can be added to this view.", e.getMessage()); } }
@Test public void test_add_AddsTheSourceAndDestinationElements_WhenARelationshipBetweenThemExistsAndTheDestinationIsAnExternalSoftwareSystem() { DynamicView dynamicView = workspace.getViews().createDynamicView(softwareSystemA, "key", "Description"); containerA2.uses(softwareSystemB, "", ""); dynamicView.add(containerA2, softwareSystemB); assertEquals(2, dynamicView.getElements().size()); }
@Test public void test_add_ThrowsAnException_WhenTheScopeOfTheDynamicViewIsNotSpecifiedButAComponentIsAdded() { try { DynamicView dynamicView = workspace.getViews().createDynamicView("key", "Description"); DeploymentNode deploymentNode = workspace.getModel().addDeploymentNode("Deployment node", "Description", "Technology"); dynamicView.add(componentA1, componentA1); fail(); } catch (IllegalArgumentException iae) { assertEquals("Only people and software systems can be added to this dynamic view.", iae.getMessage()); } }
@Test public void test_add_ThrowsAnException_WhenADeploymentNodeIsAdded() { try { DynamicView dynamicView = workspace.getViews().createDynamicView("key", "Description"); DeploymentNode deploymentNode = workspace.getModel().addDeploymentNode("Deployment node", "Description", "Technology"); dynamicView.add(deploymentNode, softwareSystemA); fail(); } catch (IllegalArgumentException iae) { assertEquals("Only people, software systems, containers and components can be added to dynamic views.", iae.getMessage()); } }
@Test public void test_add_ThrowsAnException_WhenTheScopeOfTheDynamicViewIsNotSpecifiedButAContainerIsAdded() { try { DynamicView dynamicView = workspace.getViews().createDynamicView("key", "Description"); DeploymentNode deploymentNode = workspace.getModel().addDeploymentNode("Deployment node", "Description", "Technology"); dynamicView.add(containerA1, containerA1); fail(); } catch (IllegalArgumentException iae) { assertEquals("Only people and software systems can be added to this dynamic view.", iae.getMessage()); } }
@Test public void test_createDynamicViewForAContainer_ThrowsAnException_WhenANullKeyIsSpecified() { try { Workspace workspace = new Workspace("Name", "Description"); SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description"); Container container = softwareSystem.addContainer("Container", "Description", "Technology"); workspace.getViews().createDynamicView(container, null, "Description"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A key must be specified.", iae.getMessage()); } }
@Test public void test_createDynamicViewForAContainer_ThrowsAnException_WhenAnEmptyKeyIsSpecified() { try { Workspace workspace = new Workspace("Name", "Description"); SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description"); Container container = softwareSystem.addContainer("Container", "Description", "Technology"); workspace.getViews().createDynamicView(container, " ", "Description"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A key must be specified.", iae.getMessage()); } }
@Test public void test_add_ThrowsAnException_WhenARelationshipBetweenTheSourceAndDestinationElementsDoesNotExist() { try { DynamicView dynamicView = workspace.getViews().createDynamicView("key", "Description"); SoftwareSystem ss1 = workspace.getModel().addSoftwareSystem("Software System 1", ""); SoftwareSystem ss2 = workspace.getModel().addSoftwareSystem("Software System 2", ""); dynamicView.add(ss1, ss2); fail(); } catch (Exception e) { assertEquals("A relationship between Software System 1 and Software System 2 does not exist in model.", e.getMessage()); } }
@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_createDynamicView() { Workspace workspace = new Workspace("Name", "Description"); DynamicView dynamicView = workspace.getViews().createDynamicView("key", "Description"); assertEquals("key", dynamicView.getKey()); assertEquals("Description", dynamicView.getDescription()); assertNull(dynamicView.getSoftwareSystem()); assertNull(dynamicView.getElement()); }
@Test public void test_createDynamicViewForContainer() { Workspace workspace = new Workspace("Name", "Description"); SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Name", "Description"); Container container = softwareSystem.addContainer("Container", "Description", "Technology"); DynamicView dynamicView = workspace.getViews().createDynamicView(container, "key", "Description"); assertEquals("key", dynamicView.getKey()); assertEquals("Description", dynamicView.getDescription()); assertSame(softwareSystem, dynamicView.getSoftwareSystem()); assertSame(container, dynamicView.getElement()); }