@Test public void test_addAllElements_DoesNothing_WhenThereAreNoSoftwareSystemsOrPeople() { view.addAllElements(); assertEquals(0, view.getElements().size()); }
/** * Creates a system landscape view. * * @param key the key for the view (must be unique) * @param description a description of the view * @return an SystemLandscapeView object * @throws IllegalArgumentException if the key is not unique */ public SystemLandscapeView createSystemLandscapeView(String key, String description) { assertThatTheViewKeyIsSpecifiedAndUnique(key); SystemLandscapeView view = new SystemLandscapeView(model, key, description); view.setViewSet(this); systemLandscapeViews.add(view); return view; }
@Test public void test_addAllPeople_DoesNothing_WhenThereAreNoPeople() { view.addAllPeople(); assertEquals(0, view.getElements().size()); }
/** * Adds all software systems and all people to this view. */ @Override public void addAllElements() { addAllSoftwareSystems(); addAllPeople(); }
@Test public void test_addAllSoftwareSystems_DoesNothing_WhenThereAreNoOtherSoftwareSystems() { view.addAllSoftwareSystems(); assertEquals(0, view.getElements().size()); }
ContainerInstance containerInstance = deploymentNode.add(container); SystemLandscapeView systemLandscapeView = new SystemLandscapeView(); systemLandscapeView.setKey("systemLandscape"); // this is used for the filtered view below systemLandscapeView.setElements(elementViewsFor(person, softwareSystem)); systemLandscapeView.setRelationships(relationshipViewsFor(personUsesSoftwareSystemRelationship)); views.setSystemLandscapeViews(Collections.singleton(systemLandscapeView)); filteredView.setBaseViewKey(systemLandscapeView.getKey()); views.setFilteredViews(Collections.singleton(filteredView)); assertSame(model, systemLandscapeView.getModel()); assertSame(views, systemLandscapeView.getViewSet()); assertSame(person, systemLandscapeView.getElementView(person).getElement()); assertSame(softwareSystem, systemLandscapeView.getElementView(softwareSystem).getElement()); assertSame(personUsesSoftwareSystemRelationship, systemLandscapeView.getRelationshipView(personUsesSoftwareSystemRelationship).getRelationship());
@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()); }
systemLandscapeView.addAllElements(); systemLandscapeView.setPaperSize(PaperSize.A5_Landscape); componentView.setPaperSize(PaperSize.A5_Landscape); systemLandscapeView.addAnimation(internetBankingSystem, customer, mainframeBankingSystem, emailSystem); systemLandscapeView.addAnimation(atm); systemLandscapeView.addAnimation(customerServiceStaff, backOfficeStaff);
@Test public void test_construction() { assertEquals("System Landscape", view.getName()); assertEquals(0, view.getElements().size()); assertSame(model, view.getModel()); }
@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_addAnimationStep() { SoftwareSystem element1 = model.addSoftwareSystem("Software System 1", ""); SoftwareSystem element2 = model.addSoftwareSystem("Software System 2", ""); SoftwareSystem element3 = model.addSoftwareSystem("Software System 3", ""); Relationship relationship1_2 = element1.uses(element2, "uses"); Relationship relationship2_3 = element2.uses(element3, "uses"); SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "Description"); view.addAllElements(); view.addAnimation(element1); view.addAnimation(element2); view.addAnimation(element3); Animation step1 = view.getAnimations().stream().filter(step -> step.getOrder() == 1).findFirst().get(); assertEquals(1, step1.getElements().size()); assertTrue(step1.getElements().contains(element1.getId())); assertEquals(0, step1.getRelationships().size()); Animation step2 = view.getAnimations().stream().filter(step -> step.getOrder() == 2).findFirst().get(); assertEquals(1, step2.getElements().size()); assertTrue(step2.getElements().contains(element2.getId())); assertEquals(1, step2.getRelationships().size()); assertTrue(step2.getRelationships().contains(relationship1_2.getId())); Animation step3 = view.getAnimations().stream().filter(step -> step.getOrder() == 3).findFirst().get(); assertEquals(1, step3.getElements().size()); assertTrue(step3.getElements().contains(element3.getId())); assertEquals(1, step3.getRelationships().size()); assertTrue(step3.getRelationships().contains(relationship2_3.getId())); }
@Test public void test_writeView_IncludesSkinParams_WhenSkinParamsAreAdded() throws Exception { workspace = new Workspace("", ""); workspace.getModel().addSoftwareSystem("My software system", "").setLocation(Location.Internal); workspace.getViews().createSystemLandscapeView("thekey", "").addAllElements(); plantUMLWriter.addSkinParam("handwritten", "true"); plantUMLWriter.write(workspace, stringWriter); assertEquals("@startuml(id=thekey)" + System.lineSeparator() + "scale max 1999x1999" + System.lineSeparator() + "title System Landscape" + System.lineSeparator() + "" + System.lineSeparator() + "skinparam {" + System.lineSeparator() + " shadowing false" + System.lineSeparator() + " arrowColor #707070" + System.lineSeparator() + " actorBorderColor #707070" + System.lineSeparator() + " componentBorderColor #707070" + System.lineSeparator() + " rectangleBorderColor #707070" + System.lineSeparator() + " noteBackgroundColor #ffffff" + System.lineSeparator() + " noteBorderColor #707070" + System.lineSeparator() + " handwritten true" + System.lineSeparator() + "}" + System.lineSeparator() + "package \"Enterprise\" {" + System.lineSeparator() + " rectangle \"My software system\" <<Software System>> as 1 #dddddd" + System.lineSeparator() + "}" + System.lineSeparator() + "@enduml" + System.lineSeparator(), stringWriter.toString()); }
view.addAllElements(); view.setPaperSize(PaperSize.A5_Landscape);
writeHeader(view, writer); view.getElements().stream() .map(ElementView::getElement) .filter(e -> e instanceof Person && ((Person)e).getLocation() == Location.External) .forEach(e -> write(view, e, writer, false)); view.getElements().stream() .map(ElementView::getElement) .filter(e -> e instanceof SoftwareSystem && ((SoftwareSystem)e).getLocation() == Location.External) .forEach(e -> write(view, e, writer, false)); String name = view.getModel().getEnterprise() != null ? view.getModel().getEnterprise().getName() : "Enterprise"; writer.write("package \"" + name + "\" {"); writer.write(System.lineSeparator()); view.getElements().stream() .map(ElementView::getElement) .filter(e -> e instanceof Person && ((Person)e).getLocation() == Location.Internal) .forEach(e -> write(view, e, writer, true)); view.getElements().stream() .map(ElementView::getElement) .filter(e -> e instanceof SoftwareSystem && ((SoftwareSystem)e).getLocation() == Location.Internal)
@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_addNearestNeighbours_DoesNothing_WhenThereAreNoNeighbours() { SoftwareSystem softwareSystem = model.addSoftwareSystem("The System", "Description"); view.addNearestNeighbours(softwareSystem); assertEquals(1, view.getElements().size()); }
@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()); }
SystemLandscapeView sourceView = findView(source.getSystemLandscapeViews(), view); if (sourceView != null) { view.copyLayoutInformationFrom(sourceView); } else { log.warn("Could not find a matching view for \"" + view.getName() + "\" ... diagram layout information may be lost.");
@Test public void test_getName_WhenNoEnterpriseIsSpecified() { assertEquals("System Landscape", view.getName()); }