@Test public void test_createSystemLandscapeView_DoesNotThrowAnException_WhenUniqueKeysAreSpecified() { Workspace workspace = new Workspace("Name", "Description"); workspace.getViews().createSystemLandscapeView("key1", "Description"); workspace.getViews().createSystemLandscapeView("key2", "Description"); }
@Test public void test_createSystemLandscapeView_ThrowsAnException_WhenADuplicateKeyIsSpecified() { try { Workspace workspace = new Workspace("Name", "Description"); workspace.getViews().createSystemLandscapeView("key", "Description"); workspace.getViews().createSystemLandscapeView("key", "Description"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A view with the key key already exists.", iae.getMessage()); } }
@Test public void test_setEnterpriseContextViews_IsSupportedForOlderWorkspaces() { ViewSet views = new Workspace("", "").getViews(); SystemLandscapeView systemLandscapeView = views.createSystemLandscapeView("key", "Description"); views.setEnterpriseContextViews(Collections.singleton(systemLandscapeView)); assertEquals(1, views.getSystemLandscapeViews().size()); assertSame(systemLandscapeView, views.getSystemLandscapeViews().iterator().next()); }
@Test public void test_createSystemLandscapeView_ThrowsAnException_WhenANullKeyIsSpecified() { try { new Workspace("", "").getViews().createSystemLandscapeView(null, "Description"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A key must be specified.", iae.getMessage()); } }
@Test public void test_createSystemLandscapeView_ThrowsAnException_WhenAnEmptyKeyIsSpecified() { try { new Workspace("", "").getViews().createSystemLandscapeView(" ", "Description"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A key must be specified.", iae.getMessage()); } }
@Test public void test_addAnimationStep_ThrowsAnException_WhenNoElementsAreSpecified() { try { SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "Description"); view.addAnimation(); fail(); } catch (IllegalArgumentException iae) { assertEquals("One or more elements must be specified.", iae.getMessage()); } }
@Test public void test_addAnimationStep_IgnoresElementsThatDoNotExistInTheView() { SoftwareSystem element1 = model.addSoftwareSystem("Software System 1", ""); SoftwareSystem element2 = model.addSoftwareSystem("Software System 2", ""); SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "Description"); view.add(element1); view.addAnimation(element1, element2); Animation step1 = view.getAnimations().stream().filter(step -> step.getOrder() == 1).findFirst().get(); assertEquals(1, step1.getElements().size()); assertTrue(step1.getElements().contains(element1.getId())); }
@Test public void test_backwardsCompatibilityOfRenamingEnterpriseContextViewsToSystemLandscapeViews() throws Exception { Workspace workspace = new Workspace("Name", "Description"); workspace.getViews().createSystemLandscapeView("key", "description"); JsonWriter jsonWriter = new JsonWriter(false); StringWriter stringWriter = new StringWriter(); jsonWriter.write(workspace, stringWriter); String workspaceAsJson = stringWriter.toString(); workspaceAsJson = workspaceAsJson.replaceAll("systemLandscapeViews", "enterpriseContextViews"); JsonReader jsonReader = new JsonReader(); StringReader stringReader = new StringReader(workspaceAsJson); workspace = jsonReader.read(stringReader); assertEquals(1, workspace.getViews().getSystemLandscapeViews().size()); }
@Test public void test_addAnimationStep_ThrowsAnException_WhenElementsAreSpecifiedButNoneOfThemExistInTheView() { try { SoftwareSystem element1 = model.addSoftwareSystem("Software System 1", ""); SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "Description"); view.addAnimation(element1); fail(); } catch (IllegalArgumentException iae) { assertEquals("None of the specified elements exist in this view.", iae.getMessage()); } }
@Test public void test_createFilteredView_ThrowsAnException_WhenAnEmptyKeyIsSpecified() { try { Workspace workspace = new Workspace("Name", "Description"); SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("systemLandscape", "Description"); workspace.getViews().createFilteredView(view, " ", "Description", FilterMode.Include, "tag1", "tag2"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A key must be specified.", iae.getMessage()); } }
@Test public void test_createFilteredView_ThrowsAnException_WhenANullKeyIsSpecified() { try { Workspace workspace = new Workspace("Name", "Description"); SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("systemLandscape", "Description"); workspace.getViews().createFilteredView(view, null, "Description", FilterMode.Include, "tag1", "tag2"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A key must be specified.", iae.getMessage()); } }
@Test public void test_isEmpty_ReturnsFalse_WhenThereAreViews() { workspace = new Workspace("Name", "Description"); workspace.getViews().createSystemLandscapeView("key", "Description"); assertFalse(workspace.isEmpty()); }
@Test public void test_defaultView() { SystemLandscapeView view = views.createSystemLandscapeView("key", "Description"); Configuration configuration = new Configuration(); configuration.setDefaultView(view); assertEquals("key", configuration.getDefaultView()); }
@Test public void test_removeElementsWithNoRelationships_RemovesAllElements_WhenTheViewHasNoRelationshipsBetweenElements() { SoftwareSystem softwareSystem = model.addSoftwareSystem(Location.Internal, "Software System", "Description"); Person person = model.addPerson(Location.Unspecified, "Person", "Description"); StaticView view = views.createSystemLandscapeView("context", "Description"); view.addAllSoftwareSystems(); view.addAllPeople(); view.removeElementsWithNoRelationships(); assertEquals(0, view.getElements().size()); }
@Test public void test_createFilteredView_ThrowsAnException_WhenADuplicateKeyIsUsed() { Workspace workspace = new Workspace("Name", "Description"); SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("systemLandscape", "Description"); workspace.getViews().createFilteredView(view, "filtered", "Description", FilterMode.Include, "tag1", "tag2"); try { workspace.getViews().createFilteredView(view, "filtered", "Description", FilterMode.Include, "tag1", "tag2"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A view with the key filtered already exists.", iae.getMessage()); } }
@Test public void test_addElement_ThrowsAnException_WhenTheSpecifiedElementDoesNotExistInTheModel() { try { Workspace workspace = new Workspace("1", ""); SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description"); SystemLandscapeView view = new Workspace("", "").getViews().createSystemLandscapeView("key", "Description"); view.add(softwareSystem); fail(); } catch (IllegalArgumentException iae) { assertEquals("The element named Software System does not exist in the model associated with this view.", iae.getMessage()); } }
@Test public void test_createSystemLandscapeView() { Workspace workspace = new Workspace("Name", "Description"); SystemLandscapeView systemLandscapeView = workspace.getViews().createSystemLandscapeView("key", "Description"); assertEquals("key", systemLandscapeView.getKey()); assertEquals("Description", systemLandscapeView.getDescription()); }
@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_createFilteredView() { Workspace workspace = new Workspace("Name", "Description"); SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("systemLandscape", "Description"); FilteredView filteredView = workspace.getViews().createFilteredView(view, "key", "Description", FilterMode.Include, "tag1", "tag2"); assertEquals("key", filteredView.getKey()); assertEquals("Description", filteredView.getDescription()); assertEquals(FilterMode.Include, filteredView.getMode()); assertEquals(2, filteredView.getTags().size()); assertTrue(filteredView.getTags().contains("tag1")); assertTrue(filteredView.getTags().contains("tag2")); }
@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 }