@Test public void test_addAllElements_DoesNothing_WhenThereAreNoSoftwareSystemsOrPeople() { view.addAllElements(); assertEquals(0, view.getElements().size()); }
@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()); }
@Test public void test_addAllElements_AddsAllSoftwareSystemsAndPeople_WhenThereAreSomeSoftwareSystemsAndPeopleInTheModel() { SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description"); Person person = model.addPerson("Person", "Description"); view.addAllElements(); assertEquals(2, view.getElements().size()); assertTrue(view.getElements().contains(new ElementView(softwareSystem))); assertTrue(view.getElements().contains(new ElementView(person))); }
@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_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();
@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 }
public static void main(String[] args) throws Exception { Workspace workspace = new Workspace("Filtered Views", "An example of using filtered views."); Model model = workspace.getModel(); Person user = model.addPerson("User", "A description of the user."); SoftwareSystem softwareSystemA = model.addSoftwareSystem("Software System A", "A description of software system A."); SoftwareSystem softwareSystemB = model.addSoftwareSystem("Software System B", "A description of software system B."); softwareSystemB.addTags(FUTURE_STATE); user.uses(softwareSystemA, "Uses for tasks 1 and 2").addTags(CURRENT_STATE); user.uses(softwareSystemA, "Uses for task 1").addTags(FUTURE_STATE); user.uses(softwareSystemB, "Uses for task 2").addTags(FUTURE_STATE); ViewSet views = workspace.getViews(); SystemLandscapeView systemLandscapeView = views.createSystemLandscapeView("SystemLandscape", "An example System Landscape diagram."); systemLandscapeView.addAllElements(); views.createFilteredView(systemLandscapeView, "CurrentState", "The current system landscape.", FilterMode.Exclude, FUTURE_STATE); views.createFilteredView(systemLandscapeView, "FutureState", "The future state system landscape after Software System B is live.", FilterMode.Exclude, CURRENT_STATE); Styles styles = views.getConfiguration().getStyles(); styles.addElementStyle(Tags.ELEMENT).color("#ffffff"); styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#91a437").shape(Shape.RoundedBox); styles.addElementStyle(Tags.PERSON).background("#6a7b15").shape(Shape.Person); StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET); structurizrClient.putWorkspace(WORKSPACE_ID, workspace); }
systemLandscapeView.addAllElements(); systemLandscapeView.setPaperSize(PaperSize.A5_Landscape);
view.addAllElements(); view.setPaperSize(PaperSize.A5_Landscape);
systemLandscapeView.addAllElements();