@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_createFilteredView_ThrowsAnException_WhenANullViewIsSpecified() { try { Workspace workspace = new Workspace("Name", "Description"); workspace.getViews().createFilteredView(null, "key", "Description", FilterMode.Include, "tag1", "tag2"); fail(); } catch (IllegalArgumentException iae) { assertEquals("A view 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_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() { 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")); }
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); }
@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")); }