Search in sources :

Example 16 with Person

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

the class PersonParserTests method test_parse_CreatesAPersonWithADescription.

@Test
void test_parse_CreatesAPersonWithADescription() {
    parser.parse(context(), tokens("person", "User", "Description"));
    assertEquals(1, model.getElements().size());
    Person user = model.getPersonWithName("User");
    assertNotNull(user);
    assertEquals("Description", user.getDescription());
    assertEquals(Location.Unspecified, user.getLocation());
    assertEquals("Element,Person", user.getTags());
}
Also used : Person(com.structurizr.model.Person) Test(org.junit.jupiter.api.Test)

Example 17 with Person

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

the class RefParserTests method test_parse_FindsAnElementByIdentifier.

@Test
void test_parse_FindsAnElementByIdentifier() {
    Person user = workspace.getModel().addPerson("User");
    ModelDslContext context = context();
    IdentifiersRegister register = new IdentifiersRegister();
    register.register("user", user);
    context.setIdentifierRegister(register);
    ModelItem modelItem = parser.parse(context, tokens("ref", "user"));
    assertSame(modelItem, user);
}
Also used : ModelItem(com.structurizr.model.ModelItem) Person(com.structurizr.model.Person) Test(org.junit.jupiter.api.Test)

Example 18 with Person

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

the class StructurizrClientIntegrationTests method test_putAndGetWorkspace_WithoutEncryption.

@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);
}
Also used : SystemContextView(com.structurizr.view.SystemContextView) SoftwareSystem(com.structurizr.model.SoftwareSystem) JsonReader(com.structurizr.io.json.JsonReader) EncryptedJsonReader(com.structurizr.io.json.EncryptedJsonReader) FileReader(java.io.FileReader) Person(com.structurizr.model.Person) Workspace(com.structurizr.Workspace) EncryptedWorkspace(com.structurizr.encryption.EncryptedWorkspace) Test(org.junit.Test)

Example 19 with Person

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

the class StructurizrClientIntegrationTests method test_putAndGetWorkspace_WithEncryption.

@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);
}
Also used : AesEncryptionStrategy(com.structurizr.encryption.AesEncryptionStrategy) EncryptedJsonReader(com.structurizr.io.json.EncryptedJsonReader) SystemContextView(com.structurizr.view.SystemContextView) SoftwareSystem(com.structurizr.model.SoftwareSystem) EncryptedWorkspace(com.structurizr.encryption.EncryptedWorkspace) FileReader(java.io.FileReader) Person(com.structurizr.model.Person) Workspace(com.structurizr.Workspace) EncryptedWorkspace(com.structurizr.encryption.EncryptedWorkspace) Test(org.junit.Test)

Aggregations

Person (com.structurizr.model.Person)19 Test (org.junit.jupiter.api.Test)13 SoftwareSystem (com.structurizr.model.SoftwareSystem)9 Workspace (com.structurizr.Workspace)5 DynamicView (com.structurizr.view.DynamicView)4 RelationshipView (com.structurizr.view.RelationshipView)4 SystemContextView (com.structurizr.view.SystemContextView)4 Model (com.structurizr.model.Model)3 ModelItem (com.structurizr.model.ModelItem)3 Relationship (com.structurizr.model.Relationship)3 ViewSet (com.structurizr.view.ViewSet)3 EncryptedWorkspace (com.structurizr.encryption.EncryptedWorkspace)2 EncryptedJsonReader (com.structurizr.io.json.EncryptedJsonReader)2 Container (com.structurizr.model.Container)2 Enterprise (com.structurizr.model.Enterprise)2 FileReader (java.io.FileReader)2 Test (org.junit.Test)2 ComponentFinder (com.structurizr.analysis.ComponentFinder)1 StructurizrAnnotationsComponentFinderStrategy (com.structurizr.analysis.StructurizrAnnotationsComponentFinderStrategy)1 AesEncryptionStrategy (com.structurizr.encryption.AesEncryptionStrategy)1