@Test public void test_createComponentView_ThrowsAnException_WhenASoftwareSystemIsSpecified() { try { new Workspace("", "").getViews().createComponentView(null, null, "Description"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A container must be specified.", iae.getMessage()); } }
@Test public void test_createComponentView_ThrowsAnException_WhenADuplicateKeyIsSpecified() { try { Workspace workspace = new Workspace("Name", "Description"); SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description"); Container container = softwareSystem.addContainer("Container", "Description", "Technology"); workspace.getViews().createComponentView(container, "key", "Description"); workspace.getViews().createComponentView(container, "key", "Description"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A view with the key key already exists.", iae.getMessage()); } }
containerView.addAllContainers(); ComponentView componentView = views.createComponentView(webApplication, "components", "The Components diagram for the Spring PetClinic web application."); componentView.addAllComponents(); componentView.addAllPeople();
@Test public void test_createComponentView_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().createComponentView(container, null, "Description"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A key must be specified.", iae.getMessage()); } }
@Test public void test_createComponentView_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().createComponentView(container, " ", "Description"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A key must be specified.", iae.getMessage()); } }
@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 }
containerView.addAllContainers(); ComponentView componentView = views.createComponentView(webApplication, "components", "The Component diagram for the Spring PetClinic web application."); componentView.addAllComponents(); componentView.addAllPeople();
@Test public void test_createComponentView() { Workspace workspace = new Workspace("Name", "Description"); SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description"); Container container = softwareSystem.addContainer("Container", "Description", "Technology"); ComponentView componentView = workspace.getViews().createComponentView(container, "key", "Description"); assertEquals("key", componentView.getKey()); assertEquals("Description", componentView.getDescription()); assertSame(softwareSystem, componentView.getSoftwareSystem()); assertSame(container, componentView.getContainer()); }
/** * Writes the PlantUML component diagram for the given {@link Module} with the given rendering {@link Options}. * * @param module must not be {@literal null}. * @param options must not be {@literal null}. */ public void writeModuleAsPlantUml(Module module, Options options) { Assert.notNull(module, "Module must not be null!"); Assert.notNull(options, "Options must not be null!"); ComponentView view = workspace.getViews().createComponentView(container, module.getName(), ""); view.setTitle(module.getDisplayName()); addComponentsToView(module, view, options); String fileNamePattern = options.getTargetFileName().orElse("module-%s.uml"); Assert.isTrue(fileNamePattern.contains("%s"), () -> String.format(INVALID_FILE_NAME_PATTERN, fileNamePattern)); writeViewAsPlantUml(view, String.format(fileNamePattern, module.getName())); }
containerView.addAllElements(); ComponentView componentView = views.createComponentView(webApplication, "Components", "The component diagram for the web application."); componentView.addAllElements();
private <T extends Writer> T createPlantUml(T writer, Options options) throws IOException { ComponentView componentView = workspace.getViews() // .createComponentView(container, "modules-" + options.toString(), ""); componentView.setTitle(modules.getSystemName().orElse("Modules")); addComponentsToView(() -> modules.stream(), componentView, options, it -> {}); new PlantUMLWriter().write(componentView, writer); return writer; }
containerView.setPaperSize(PaperSize.A5_Landscape); ComponentView componentView = views.createComponentView(apiApplication, "Components", "The component diagram for the API Application."); componentView.add(mobileApp); componentView.add(singlePageApplication);
containerView.addAllContainers(); ComponentView componentView = views.createComponentView(webApplication, "components", "Description"); componentView.addAllSoftwareSystems(); componentView.addAllPeople();
containerView.addAllElements(); ComponentView componentView = workspace.getViews().createComponentView(webApplication, "components", ""); componentView.setPaperSize(PaperSize.A6_Portrait); componentView.addAllElements();