Search in sources :

Example 61 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem in project dsl by structurizr.

the class SoftwareSystemParserTests method test_parse_CreatesAnInternalSoftwareSystem.

@Test
void test_parse_CreatesAnInternalSoftwareSystem() {
    EnterpriseDslContext context = new EnterpriseDslContext();
    context.setWorkspace(workspace);
    parser.parse(context, tokens("softwareSystem", "Name"));
    assertEquals(1, model.getElements().size());
    SoftwareSystem softwareSystem = model.getSoftwareSystemWithName("Name");
    assertNotNull(softwareSystem);
    assertEquals("", softwareSystem.getDescription());
    assertEquals(Location.Internal, softwareSystem.getLocation());
    assertEquals("Element,Software System", softwareSystem.getTags());
}
Also used : SoftwareSystem(com.structurizr.model.SoftwareSystem) Test(org.junit.jupiter.api.Test)

Example 62 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem in project java by structurizr.

the class ThemeUtilsTests method test_findElementStyle_WithThemes.

@Test
public void test_findElementStyle_WithThemes() {
    Workspace workspace = new Workspace("Name", "Description");
    SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Name");
    workspace.getViews().getConfiguration().getStyles().addElementStyle("Element").shape(Shape.RoundedBox);
    // theme 1
    Collection<ElementStyle> elementStyles = new ArrayList<>();
    Collection<RelationshipStyle> relationshipStyles = new ArrayList<>();
    elementStyles.add(new ElementStyle("Element").shape(Shape.Box).background("#000000").color("#ffffff"));
    workspace.getViews().getConfiguration().getStyles().addStylesFromTheme("url1", elementStyles, relationshipStyles);
    // theme 2
    elementStyles = new ArrayList<>();
    relationshipStyles = new ArrayList<>();
    elementStyles.add(new ElementStyle("Element").background("#ff0000"));
    workspace.getViews().getConfiguration().getStyles().addStylesFromTheme("url2", elementStyles, relationshipStyles);
    ElementStyle style = workspace.getViews().getConfiguration().getStyles().findElementStyle(softwareSystem);
    assertEquals(new Integer(450), style.getWidth());
    assertEquals(new Integer(300), style.getHeight());
    // from theme 2
    assertEquals("#ff0000", style.getBackground());
    // from theme 1
    assertEquals("#ffffff", style.getColor());
    assertEquals(new Integer(24), style.getFontSize());
    // from workspace
    assertEquals(Shape.RoundedBox, style.getShape());
    assertNull(style.getIcon());
    assertEquals(Border.Solid, style.getBorder());
    assertEquals("#b20000", style.getStroke());
    assertEquals(new Integer(100), style.getOpacity());
    assertEquals(true, style.getMetadata());
    assertEquals(true, style.getDescription());
}
Also used : ArrayList(java.util.ArrayList) SoftwareSystem(com.structurizr.model.SoftwareSystem) Workspace(com.structurizr.Workspace) Test(org.junit.Test)

Example 63 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem in project java by structurizr.

the class ThemeUtilsTests method test_loadThemes_LoadsThemesWhenThemesAreDefined.

@Test
public void test_loadThemes_LoadsThemesWhenThemesAreDefined() throws Exception {
    Workspace workspace = new Workspace("Name", "Description");
    SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Name");
    softwareSystem.addTags("Amazon Web Services - Alexa For Business");
    workspace.getViews().getConfiguration().setThemes("https://static.structurizr.com/themes/amazon-web-services-2020.04.30/theme.json");
    ThemeUtils.loadThemes(workspace);
    // there should still be zero styles in the workspace
    assertEquals(0, workspace.getViews().getConfiguration().getStyles().getElements().size());
    // but we should be able to find a style included in the theme
    ElementStyle style = workspace.getViews().getConfiguration().getStyles().findElementStyle(softwareSystem);
    assertNotNull(style);
    assertEquals("#d6242d", style.getStroke());
    assertEquals("#d6242d", style.getColor());
    assertNotNull(style.getIcon());
}
Also used : SoftwareSystem(com.structurizr.model.SoftwareSystem) Workspace(com.structurizr.Workspace) Test(org.junit.Test)

Example 64 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem in project java by structurizr.

the class FilteredViewTests method test_construction.

@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"));
}
Also used : SoftwareSystem(com.structurizr.model.SoftwareSystem) Test(org.junit.Test)

Example 65 with SoftwareSystem

use of com.structurizr.model.SoftwareSystem in project java by structurizr.

the class DefaultLayoutMergeStrategyTests method test_copyLayoutInformation_WhenAParentElementNameHasChanged.

@Test
public void test_copyLayoutInformation_WhenAParentElementNameHasChanged() {
    Workspace workspace1 = new Workspace("1", "");
    SoftwareSystem softwareSystem1 = workspace1.getModel().addSoftwareSystem("Software System");
    Container container1 = softwareSystem1.addContainer("Container", "", "");
    ContainerView view1 = workspace1.getViews().createContainerView(softwareSystem1, "key", "");
    view1.add(container1);
    view1.getElementView(container1).setX(123);
    view1.getElementView(container1).setY(456);
    Workspace workspace2 = new Workspace("2", "");
    SoftwareSystem softwareSystem2 = workspace2.getModel().addSoftwareSystem("Software System with a new name");
    Container container2 = softwareSystem2.addContainer("Container", "", "");
    ContainerView view2 = workspace2.getViews().createContainerView(softwareSystem2, "key", "");
    view2.add(container2);
    DefaultLayoutMergeStrategy strategy = new DefaultLayoutMergeStrategy();
    strategy.copyLayoutInformation(view1, view2);
    assertEquals(123, view2.getElementView(container2).getX());
    assertEquals(456, view2.getElementView(container2).getY());
}
Also used : Container(com.structurizr.model.Container) SoftwareSystem(com.structurizr.model.SoftwareSystem) Workspace(com.structurizr.Workspace) Test(org.junit.Test)

Aggregations

SoftwareSystem (com.structurizr.model.SoftwareSystem)69 Test (org.junit.jupiter.api.Test)38 Container (com.structurizr.model.Container)23 Workspace (com.structurizr.Workspace)22 Test (org.junit.Test)17 Person (com.structurizr.model.Person)9 Component (com.structurizr.model.Component)8 DynamicView (com.structurizr.view.DynamicView)8 ArrayList (java.util.ArrayList)8 Model (com.structurizr.model.Model)7 DeploymentView (com.structurizr.view.DeploymentView)6 SystemContextView (com.structurizr.view.SystemContextView)6 ViewSet (com.structurizr.view.ViewSet)5 Element (com.structurizr.model.Element)4 Relationship (com.structurizr.model.Relationship)4 ContainerView (com.structurizr.view.ContainerView)4 RelationshipView (com.structurizr.view.RelationshipView)4 DeploymentNode (com.structurizr.model.DeploymentNode)3 ComponentView (com.structurizr.view.ComponentView)3 EncryptedWorkspace (com.structurizr.encryption.EncryptedWorkspace)2