Java Code Examples for com.structurizr.Workspace

The following examples show how to use com.structurizr.Workspace. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void test_copyLayoutInformationFrom_WhenTheSystemContextViewKeysMatch() {
    Workspace workspace1 = createWorkspace();
    SoftwareSystem softwareSystem1 = workspace1.getModel().getSoftwareSystemWithName("Software System");
    SystemContextView view1 = workspace1.getViews().createSystemContextView(softwareSystem1, "context", "Description");
    view1.addAllElements();
    view1.getElements().iterator().next().setX(100);
    view1.setPaperSize(PaperSize.A3_Landscape);

    Workspace workspace2 = createWorkspace();
    SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System");
    SystemContextView view2 = workspace2.getViews().createSystemContextView(softwareSystem2, "context", "Description");
    view2.addAllElements();

    workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews());
    assertEquals(100, view2.getElements().iterator().next().getX());
    assertEquals(PaperSize.A3_Landscape, view2.getPaperSize());
}
 
Example 2
public static void main(String[] args) throws Exception {
    Workspace workspace = new Workspace("Documentation - Automatic", "An empty software architecture document using the Structurizr template.");
    Model model = workspace.getModel();
    ViewSet views = workspace.getViews();

    Person user = model.addPerson("User", "A user of my software system.");
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
    user.uses(softwareSystem, "Uses");

    SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
    contextView.addAllSoftwareSystems();
    contextView.addAllPeople();

    Styles styles = views.getConfiguration().getStyles();
    styles.addElementStyle(Tags.PERSON).shape(Shape.Person);

    // this directory includes a mix of Markdown and AsciiDoc files
    File documentationRoot = new File("./structurizr-examples/src/com/structurizr/example/documentation/automatic");

    AutomaticDocumentationTemplate template = new AutomaticDocumentationTemplate(workspace);
    template.addSections(softwareSystem, documentationRoot);

    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example 3
Source Project: java   Source File: Theme.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Workspace workspace = new Workspace("Theme", "This is a model of my software system.");
    Model model = workspace.getModel();

    Person user = model.addPerson("User", "A user of my software system.");
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
    user.uses(softwareSystem, "Uses");

    ViewSet views = workspace.getViews();
    SystemContextView contextView = views.createSystemContextView(softwareSystem, "SystemContext", "An example of a System Context diagram.");
    contextView.addAllSoftwareSystems();
    contextView.addAllPeople();

    // add a theme
    views.getConfiguration().setTheme("https://raw.githubusercontent.com/structurizr/java/master/structurizr-examples/src/com/structurizr/example/theme/theme.json");

    StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
    structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
}
 
Example 4
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example 5
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void test_copyLayoutInformationFrom_WhenTheDynamicViewKeysMatch() {
    Workspace workspace1 = createWorkspace();
    Person person1 = workspace1.getModel().getPersonWithName("Person");
    SoftwareSystem softwareSystem1 = workspace1.getModel().getSoftwareSystemWithName("Software System");
    DynamicView view1 = workspace1.getViews().createDynamicView("context", "Description");
    view1.add(person1, softwareSystem1);
    view1.getElements().iterator().next().setX(100);
    view1.setPaperSize(PaperSize.A3_Landscape);

    Workspace workspace2 = createWorkspace();
    Person person2 = workspace2.getModel().getPersonWithName("Person");
    SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System");
    DynamicView view2 = workspace2.getViews().createDynamicView("context", "Description");
    view2.add(person2, softwareSystem2);

    workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews());
    assertEquals(100, view2.getElements().iterator().next().getX());
    assertEquals(PaperSize.A3_Landscape, view2.getPaperSize());
}
 
Example 6
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void test_copyLayoutInformationFrom_WhenTheContainerViewKeysMatch() {
    Workspace workspace1 = createWorkspace();
    SoftwareSystem softwareSystem1 = workspace1.getModel().getSoftwareSystemWithName("Software System");
    ContainerView view1 = workspace1.getViews().createContainerView(softwareSystem1, "containers", "Description");
    view1.addAllElements();
    view1.getElements().iterator().next().setX(100);
    view1.setPaperSize(PaperSize.A3_Landscape);

    Workspace workspace2 = createWorkspace();
    SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System");
    ContainerView view2 = workspace2.getViews().createContainerView(softwareSystem2, "containers", "Description");
    view2.addAllElements();

    workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews());
    assertEquals(100, view2.getElements().iterator().next().getX());
    assertEquals(PaperSize.A3_Landscape, view2.getPaperSize());
}
 
Example 7
Source Project: java   Source File: MessageDigestIdGeneratorTests.java    License: Apache License 2.0 6 votes vote down vote up
private void createWorkspaceWithExpectedIds(MessageDigestIdGenerator ids, String webappId, String databaseId, String relationshipId) {
    final Workspace ws = createWorkspace(ids);

    final Element webapp = ws.getModel().getElement(webappId);
    final Element database = ws.getModel().getElement(databaseId);
    final Relationship relationship = ws.getModel().getRelationship(relationshipId);

    assertNotNull(webapp);
    assertNotNull(database);
    assertNotNull(relationship);
    assertEquals("Web Application", webapp.getName());
    assertEquals("Database", database.getName());
    assertEquals("Reads from and writes to", relationship.getDescription());
    assertSame(webapp, relationship.getSource());
    assertSame(database, relationship.getDestination());
}
 
Example 8
Source Project: java   Source File: StructurizrClientIntegrationTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void test_putAndGetWorkspace_WithoutEncryption() throws Exception {
    Workspace workspace = new Workspace("Structurizr client library tests - without encryption", "A test workspace for the Structurizr client library");
    SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description");
    Person person = workspace.getModel().addPerson("Person", "Description");
    person.uses(softwareSystem, "Uses");
    SystemContextView systemContextView = workspace.getViews().createSystemContextView(softwareSystem, "SystemContext", "Description");
    systemContextView.addAllElements();

    structurizrClient.putWorkspace(20081, workspace);

    workspace = structurizrClient.getWorkspace(20081);
    assertNotNull(workspace.getModel().getSoftwareSystemWithName("Software System"));
    assertNotNull(workspace.getModel().getPersonWithName("Person"));
    assertEquals(1, workspace.getModel().getRelationships().size());
    assertEquals(1, workspace.getViews().getSystemContextViews().size());

    // and check the archive version is readable
    Workspace archivedWorkspace = new JsonReader().read(new FileReader(getArchivedWorkspace()));
    assertEquals(20081, archivedWorkspace.getId());
    assertEquals("Structurizr client library tests - without encryption", archivedWorkspace.getName());
    assertEquals(1, archivedWorkspace.getModel().getSoftwareSystems().size());

    assertEquals(1, workspaceArchiveLocation.listFiles().length);
}
 
Example 9
Source Project: java   Source File: StructurizrClientIntegrationTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void test_putAndGetWorkspace_WithEncryption() throws Exception {
    structurizrClient.setEncryptionStrategy(new AesEncryptionStrategy("password"));
    Workspace workspace = new Workspace("Structurizr client library tests - with encryption", "A test workspace for the Structurizr client library");
    SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description");
    Person person = workspace.getModel().addPerson("Person", "Description");
    person.uses(softwareSystem, "Uses");
    SystemContextView systemContextView = workspace.getViews().createSystemContextView(softwareSystem, "SystemContext", "Description");
    systemContextView.addAllElements();

    structurizrClient.putWorkspace(20081, workspace);

    workspace = structurizrClient.getWorkspace(20081);
    assertNotNull(workspace.getModel().getSoftwareSystemWithName("Software System"));
    assertNotNull(workspace.getModel().getPersonWithName("Person"));
    assertEquals(1, workspace.getModel().getRelationships().size());
    assertEquals(1, workspace.getViews().getSystemContextViews().size());

    // and check the archive version is readable
    EncryptedWorkspace archivedWorkspace = new EncryptedJsonReader().read(new FileReader(getArchivedWorkspace()));
    assertEquals(20081, archivedWorkspace.getId());
    assertEquals("Structurizr client library tests - with encryption", archivedWorkspace.getName());
    assertTrue(archivedWorkspace.getEncryptionStrategy() instanceof AesEncryptionStrategy);

    assertEquals(1, workspaceArchiveLocation.listFiles().length);
}
 
Example 10
Source Project: tutorials   Source File: StructurizrSimple.java    License: MIT License 6 votes vote down vote up
private static void addComponents(Workspace workspace) {
    Model model = workspace.getModel();

    SoftwareSystem paymentTerminal = model.getSoftwareSystemWithName(PAYMENT_TERMINAL);
    Container jvm1 = paymentTerminal.getContainerWithName("JVM-1");

    Component jaxrs = jvm1.addComponent("jaxrs-jersey", "restful webservice implementation", "rest");
    Component gemfire = jvm1.addComponent("gemfire", "Clustered Cache Gemfire", "cache");
    Component hibernate = jvm1.addComponent("hibernate", "Data Access Layer", "jpa");

    jaxrs.uses(gemfire, "");
    gemfire.uses(hibernate, "");

    ComponentView componentView = workspace.getViews().createComponentView(jvm1, COMPONENT_VIEW, "JVM Components");
    componentView.addAllComponents();
}
 
Example 11
Source Project: java   Source File: JsonTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void test_backwardsCompatibilityOfRenamingEnterpriseContextViewsToSystemLandscapeViews() throws Exception {
    Workspace workspace = new Workspace("Name", "Description");
    workspace.getViews().createSystemLandscapeView("key", "description");

    JsonWriter jsonWriter = new JsonWriter(false);
    StringWriter stringWriter = new StringWriter();
    jsonWriter.write(workspace, stringWriter);
    String workspaceAsJson = stringWriter.toString();
    workspaceAsJson = workspaceAsJson.replaceAll("systemLandscapeViews", "enterpriseContextViews");

    JsonReader jsonReader = new JsonReader();
    StringReader stringReader = new StringReader(workspaceAsJson);
    workspace = jsonReader.read(stringReader);
    assertEquals(1, workspace.getViews().getSystemLandscapeViews().size());
}
 
Example 12
Source Project: java   Source File: EncryptedJsonTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void test_write_and_read() throws Exception {
    final Workspace workspace1 = new Workspace("Name", "Description");

    // output the model as JSON
    EncryptedJsonWriter jsonWriter = new EncryptedJsonWriter(true);
    AesEncryptionStrategy encryptionStrategy = new AesEncryptionStrategy("password");
    final EncryptedWorkspace encryptedWorkspace1 = new EncryptedWorkspace(workspace1, encryptionStrategy);
    StringWriter stringWriter = new StringWriter();
    jsonWriter.write(encryptedWorkspace1, stringWriter);

    // and read it back again
    EncryptedJsonReader jsonReader = new EncryptedJsonReader();
    StringReader stringReader = new StringReader(stringWriter.toString());
    final EncryptedWorkspace encryptedWorkspace2 = jsonReader.read(stringReader);
    assertEquals("Name", encryptedWorkspace2.getName());
    assertEquals("Description", encryptedWorkspace2.getDescription());

    encryptedWorkspace2.getEncryptionStrategy().setPassphrase(encryptionStrategy.getPassphrase());
    final Workspace workspace2 = encryptedWorkspace2.getWorkspace();
    assertEquals("Name", workspace2.getName());
    assertEquals("Description", workspace2.getDescription());
}
 
Example 13
Source Project: java   Source File: DynamicViewTests.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void test_normalSequence() {
    workspace = new Workspace("Name", "Description");
    model = workspace.getModel();

    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
    Container container1 = softwareSystem.addContainer("Container 1", "Description", "Technology");
    Container container2 = softwareSystem.addContainer("Container 2", "Description", "Technology");
    Container container3 = softwareSystem.addContainer("Container 3", "Description", "Technology");

    container1.uses(container2, "Uses");
    container1.uses(container3, "Uses");

    DynamicView view = workspace.getViews().createDynamicView(softwareSystem, "key", "Description");

    view.add(container1, container2);
    view.add(container1, container3);

    assertSame(container2, view.getRelationships().stream().filter(r -> r.getOrder().equals("1")).findFirst().get().getRelationship().getDestination());
    assertSame(container3, view.getRelationships().stream().filter(r -> r.getOrder().equals("2")).findFirst().get().getRelationship().getDestination());
}
 
Example 14
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test_copyLayoutInformationFrom_DoesNotDoAnythingIfThereIsNoDeploymentViewToCopyInformationFrom() {
    Workspace workspace1 = createWorkspace();

    Workspace workspace2 = createWorkspace();
    DeploymentNode deploymentNode2 = workspace2.getModel().getDeploymentNodeWithName("Deployment Node");
    DeploymentView view2 = workspace2.getViews().createDeploymentView("key", "Description");
    view2.add(deploymentNode2);

    workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews());
    assertEquals(0, view2.getElements().stream().filter(ev -> ev.getElement() instanceof ContainerInstance).findFirst().get().getX()); // default
    assertEquals(0, view2.getElements().stream().filter(ev -> ev.getElement() instanceof ContainerInstance).findFirst().get().getY()); // default
    assertNull(view2.getPaperSize()); // default
}
 
Example 15
Source Project: architecture-guild   Source File: Structurizr.java    License: Apache License 2.0 5 votes vote down vote up
private static void uploadWorkspaceToStructurizr(Workspace workspace) throws Exception {
    try(InputStream inputStream = Structurizr.class.getClassLoader()
            .getResourceAsStream("secret.properties")) {
        Properties prop = new Properties();
        prop.load(inputStream);
        long workspaceId = parseLong(prop.getProperty("workspace.id"));
        String apiKey = prop.getProperty("api.key");
        String apiSecret = prop.getProperty("api.secret");
        StructurizrClient structurizrClient = new StructurizrClient(apiKey, apiSecret);
        structurizrClient.putWorkspace(workspaceId, workspace);
    }
}
 
Example 16
Source Project: architecture-guild   Source File: CarShareContextDiagram.java    License: Apache License 2.0 5 votes vote down vote up
private static void setupContextView(Workspace workspace, SoftwareSystem eMobility) {
    Function<ViewSet, StaticView> contextViewCrator = views ->
            views.createSystemContextView(
                    eMobility,
                    "context diagram",
                    "context view");
    ViewCreator.setupView(workspace, contextViewCrator, PaperSize.A5_Landscape);
}
 
Example 17
Source Project: tutorials   Source File: StructurizrSimple.java    License: MIT License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Workspace workspace = getSoftwareSystem();

    addContainers(workspace);
    addComponents(workspace);
    addSpringComponents(workspace);
    exportToPlantUml(findViewWithKey(workspace.getViews(), SOFTWARE_SYSTEM_VIEW));
    exportToPlantUml(findViewWithKey(workspace.getViews(), CONTAINER_VIEW));
    exportToPlantUml(findViewWithKey(workspace.getViews(), COMPONENT_VIEW));

    exportToPlantUml(findViewWithKey(workspace.getViews(), JVM2_COMPONENT_VIEW));

    addStyles(workspace.getViews());
    //uploadToExternal(workspace);
}
 
Example 18
private static void setupContainerView(Workspace workspace, SoftwareSystem eMobility) {
    Function<ViewSet, StaticView> containerViewCreator = views ->
            views.createContainerView(eMobility,
                    "car share containers",
                    "car share container view");
    setupView(workspace, containerViewCreator);
}
 
Example 19
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test_createDynamicViewForAContainer_ThrowsAnException_WhenANullContainerIsSpecified() {
    try {
        new Workspace("", "").getViews().createDynamicView((Container)null, "key", "Description");
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("A container must be specified.", iae.getMessage());
    }
}
 
Example 20
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test_createSystemContextView_ThrowsAnException_WhenAnEmptyKeyIsSpecified() {
    try {
        Workspace workspace = new Workspace("Name", "Description");
        SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description");
        workspace.getViews().createSystemContextView(softwareSystem, " ", "Description");
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("A key must be specified.", iae.getMessage());
    }
}
 
Example 21
Source Project: structurizr-extensions   Source File: StyleProvider.java    License: Apache License 2.0 5 votes vote down vote up
public StyleProvider(Workspace workspace) {
    Styles styles = workspace.getViews().getConfiguration().getStyles();
    styles.addElementStyle(Tags.ELEMENT).width(500).height(350).color("#ffffff").fontSize(30).shape(Shape.RoundedBox);
    styles.addElementStyle(Tags.SOFTWARE_SYSTEM).background("#2A4E6E");
    styles.addElementStyle(Tags.CONTAINER).background("#007F0E");
    styles.addElementStyle(Tags.COMPONENT).background("#3059BA");
    styles.addElementStyle(Tags.PERSON).width(475).background("#728da5").shape(Shape.Person);
    styles.addRelationshipStyle(Tags.RELATIONSHIP).dashed(true).thickness(5).fontSize(40).width(400);
    styles.addRelationshipStyle(Tags.SYNCHRONOUS).dashed(false);
    styles.addRelationshipStyle(Tags.ASYNCHRONOUS).dashed(true);
}
 
Example 22
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test_createDeploymentViewForASoftwareSystem_ThrowsAnException_WhenANullKeyIsSpecified() {
    try {
        Workspace workspace = new Workspace("Name", "Description");
        SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description");
        workspace.getViews().createDeploymentView(softwareSystem, null, "Description");
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("A key must be specified.", iae.getMessage());
    }
}
 
Example 23
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test_createContainerView_ThrowsAnException_WhenADuplicateKeyIsSpecified() {
    try {
        Workspace workspace = new Workspace("Name", "Description");
        SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description");
        workspace.getViews().createContainerView(softwareSystem, "key", "Description");
        workspace.getViews().createContainerView(softwareSystem, "key", "Description");
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("A view with the key key already exists.", iae.getMessage());
    }
}
 
Example 24
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 5 votes vote down vote up
@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());
    }
}
 
Example 25
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test_createDynamicView_ThrowsAnException_WhenANullKeyIsSpecified() {
    try {
        Workspace workspace = new Workspace("Name", "Description");
        workspace.getViews().createDynamicView(null, "Description");
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("A key must be specified.", iae.getMessage());
    }
}
 
Example 26
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test_createSystemContextView_ThrowsAnException_WhenANullKeyIsSpecified() {
    try {
        Workspace workspace = new Workspace("Name", "Description");
        SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description");
        workspace.getViews().createSystemContextView(softwareSystem, null, "Description");
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("A key must be specified.", iae.getMessage());
    }
}
 
Example 27
Source Project: java   Source File: StylingElements.java    License: Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
        Workspace workspace = new Workspace("Styling Elements", "This is a model of my software system.");
        Model model = workspace.getModel();

        Person user = model.addPerson("User", "A user of my software system.");
        SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "My software system.");
        Container webApplication = softwareSystem.addContainer("Web Application", "My web application.", "Java and Spring MVC");
        Container database = softwareSystem.addContainer("Database", "My database.", "Relational database schema");
        user.uses(webApplication, "Uses", "HTTPS");
        webApplication.uses(database, "Reads from and writes to", "JDBC");

        ViewSet views = workspace.getViews();
        ContainerView containerView = views.createContainerView(softwareSystem, "containers", "An example of a container diagram.");
        containerView.addAllElements();

        Styles styles = workspace.getViews().getConfiguration().getStyles();

        // example 1
//        styles.addElementStyle(Tags.ELEMENT).background("#438dd5").color("#ffffff");

        // example 2
//        styles.addElementStyle(Tags.ELEMENT).color("#ffffff");
//        styles.addElementStyle(Tags.PERSON).background("#08427b");
//        styles.addElementStyle(Tags.CONTAINER).background("#438dd5");

        // example 3
//        styles.addElementStyle(Tags.ELEMENT).color("#ffffff");
//        styles.addElementStyle(Tags.PERSON).background("#08427b").shape(Shape.Person);
//        styles.addElementStyle(Tags.CONTAINER).background("#438dd5");
//        database.addTags("Database");
//        styles.addElementStyle("Database").shape(Shape.Cylinder);

        StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
        structurizrClient.putWorkspace(WORKSPACE_ID, workspace);
    }
 
Example 28
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test_copyLayoutInformationFrom_IgnoresThePaperSize_WhenThePaperSizeIsSet() {
    Workspace workspace1 = createWorkspace();
    SoftwareSystem softwareSystem1 = workspace1.getModel().getSoftwareSystemWithName("Software System");
    SystemContextView view1 = workspace1.getViews().createSystemContextView(softwareSystem1, "context", "Description");
    view1.setPaperSize(PaperSize.A3_Landscape);

    Workspace workspace2 = createWorkspace();
    SoftwareSystem softwareSystem2 = workspace2.getModel().getSoftwareSystemWithName("Software System");
    SystemContextView view2 = workspace2.getViews().createSystemContextView(softwareSystem2, "context", "Description");
    view2.setPaperSize(PaperSize.A5_Portrait);

    workspace2.getViews().copyLayoutInformationFrom(workspace1.getViews());
    assertEquals(PaperSize.A5_Portrait, view2.getPaperSize());
}
 
Example 29
Source Project: java   Source File: ViewSetTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test_createDynamicViewForSoftwareSystem() {
    Workspace workspace = new Workspace("Name", "Description");
    SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Name", "Description");

    DynamicView dynamicView = workspace.getViews().createDynamicView(softwareSystem, "key", "Description");
    assertEquals("key", dynamicView.getKey());
    assertEquals("Description", dynamicView.getDescription());
    assertSame(softwareSystem, dynamicView.getSoftwareSystem());
    assertSame(softwareSystem, dynamicView.getElement());
}
 
Example 30
Source Project: java   Source File: ViewTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test_addElement_ThrowsAnException_WhenTheSpecifiedElementDoesNotExistInTheModel() {
    try {
        Workspace workspace = new Workspace("1", "");
        SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Software System", "Description");

        SystemLandscapeView view = new Workspace("", "").getViews().createSystemLandscapeView("key", "Description");
        view.add(softwareSystem);
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("The element named Software System does not exist in the model associated with this view.", iae.getMessage());
    }
}