/** * Creates a FilteredView on top of an existing static view. * * @param view the static view to base the FilteredView upon * @param key the key for the filtered view (must be unique) * @param description a description * @param mode whether to Include or Exclude elements/relationships based upon their tag * @param tags the tags to include or exclude * @return a FilteredView object */ public FilteredView createFilteredView(StaticView view, String key, String description, FilterMode mode, String... tags) { assertThatTheViewIsNotNull(view); assertThatTheViewKeyIsSpecifiedAndUnique(key); FilteredView filteredView = new FilteredView(view, key, description, mode, tags); filteredViews.add(filteredView); return filteredView; }
/** * Finds the filtered view with the specified key, or null if the view does not exist. * * @param key the key * @return a FilteredView object, or null if a view with the specified key could not be found */ FilteredView getFilteredViewWithKey(String key) { if (key == null) { throw new IllegalArgumentException("A key must be specified."); } return filteredViews.stream().filter(v -> key.equals(v.getKey())).findFirst().orElse(null); }
@Test public void test_construction() { SoftwareSystem softwareSystem = model.addSoftwareSystem("Name", "Description"); SystemContextView systemContextView = views.createSystemContextView(softwareSystem, "SystemContext", "Description"); FilteredView filteredView = views.createFilteredView( systemContextView, "CurrentStateSystemContext", "The system context as-is.", FilterMode.Exclude, "v2", "v3" ); assertEquals("CurrentStateSystemContext", filteredView.getKey()); assertEquals("SystemContext", filteredView.getBaseViewKey()); assertSame(systemContextView, filteredView.getView()); assertEquals("The system context as-is.", filteredView.getDescription()); assertEquals(FilterMode.Exclude, filteredView.getMode()); assertEquals(2, filteredView.getTags().size()); assertTrue(filteredView.getTags().contains("v2")); assertTrue(filteredView.getTags().contains("v3")); }
@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")); }
views.setDeploymentViews(Collections.singleton(deploymentView)); FilteredView filteredView = new FilteredView(); filteredView.setBaseViewKey(systemLandscapeView.getKey()); views.setFilteredViews(Collections.singleton(filteredView)); assertSame(containerInstance, deploymentView.getElementView(containerInstance).getElement()); assertSame(systemLandscapeView, filteredView.getView());
filteredView.setView(getViewWithKey(filteredView.getBaseViewKey()));