Search in sources :

Example 36 with Container

use of com.structurizr.model.Container in project agile-architecture-documentation-system by Riduidel.

the class SequenceDiagramVisitor method startVisit.

@Override
public boolean startVisit(Container container) {
    if (allowSequenceGeneration(container)) {
        if (container.getProperties().containsKey(ModelElementKeys.JAVA_SOURCES)) {
            ProjectRoot projectRoot = createProjectRootFor(container);
            Map<String, CompilationUnit> sources = parseAllSources(projectRoot);
            callGraphModel = new CallGraphModel(codeToComponents, sources);
            // Now we have all compilation units parsed, let's try to analyze that a little by, say,
            // mapping class names to their associated compilation units
            callGraphModel.analyzeCalls(getComponentsToScanFor(container).stream().flatMap(component -> component.getCode().stream()).map(code -> code.getType()).collect(Collectors.toList()));
            return true;
        } else {
            logger.log(Level.SEVERE, String.format("Unable to generate sequence diagrams since container %s has no associated sources", StructurizrUtils.getCanonicalPath(container)));
        }
    }
    // In any missing info case, return false
    return false;
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) SequenceGenerator(org.ndx.agile.architecture.sequence.generator.SequenceGenerator) ParseResult(com.github.javaparser.ParseResult) OutputBuilder(org.ndx.agile.architecture.base.OutputBuilder) ModelElementAdapter(org.ndx.agile.architecture.base.enhancers.ModelElementAdapter) Function(java.util.function.Function) Component(com.structurizr.model.Component) ConfigProperty(org.apache.deltaspike.core.api.config.ConfigProperty) ModelElementKeys(org.ndx.agile.architecture.base.enhancers.ModelElementKeys) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Inject(javax.inject.Inject) CodeElement(com.structurizr.model.CodeElement) StructurizrUtils(org.ndx.agile.architecture.base.utils.StructurizrUtils) Map(java.util.Map) CompilationUnit(com.github.javaparser.ast.CompilationUnit) LinkedList(java.util.LinkedList) ProjectRoot(com.github.javaparser.utils.ProjectRoot) Method(java.lang.reflect.Method) Path(java.nio.file.Path) Model(com.structurizr.model.Model) SourceRoot(com.github.javaparser.utils.SourceRoot) Container(com.structurizr.model.Container) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) CallGraphModel(org.ndx.agile.architecture.sequence.generator.javaparser.adapter.CallGraphModel) File(java.io.File) List(java.util.List) Stream(java.util.stream.Stream) TreeMap(java.util.TreeMap) Modifier(java.lang.reflect.Modifier) CallGraphModel(org.ndx.agile.architecture.sequence.generator.javaparser.adapter.CallGraphModel) ProjectRoot(com.github.javaparser.utils.ProjectRoot)

Example 37 with Container

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

the class ContainerParserTests method test_parse_CreatesAContainer.

@Test
void test_parse_CreatesAContainer() {
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
    SoftwareSystemDslContext context = new SoftwareSystemDslContext(softwareSystem);
    parser.parse(context, tokens("container", "Name"));
    assertEquals(2, model.getElements().size());
    Container container = softwareSystem.getContainerWithName("Name");
    assertNotNull(container);
    assertEquals("", container.getDescription());
    assertEquals("", container.getTechnology());
    assertEquals("Element,Container", container.getTags());
}
Also used : Container(com.structurizr.model.Container) SoftwareSystem(com.structurizr.model.SoftwareSystem) Test(org.junit.jupiter.api.Test)

Example 38 with Container

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

the class ContainerParserTests method test_parse_CreatesAContainerWithADescriptionAndTechnology.

@Test
void test_parse_CreatesAContainerWithADescriptionAndTechnology() {
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
    SoftwareSystemDslContext context = new SoftwareSystemDslContext(softwareSystem);
    parser.parse(context, tokens("container", "Name", "Description", "Technology"));
    assertEquals(2, model.getElements().size());
    Container container = softwareSystem.getContainerWithName("Name");
    assertNotNull(container);
    assertEquals("Description", container.getDescription());
    assertEquals("Technology", container.getTechnology());
    assertEquals("Element,Container", container.getTags());
}
Also used : Container(com.structurizr.model.Container) SoftwareSystem(com.structurizr.model.SoftwareSystem) Test(org.junit.jupiter.api.Test)

Example 39 with Container

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

the class ContainerParserTests method test_parse_CreatesAContainerWithADescriptionAndTechnologyAndTags.

@Test
void test_parse_CreatesAContainerWithADescriptionAndTechnologyAndTags() {
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
    SoftwareSystemDslContext context = new SoftwareSystemDslContext(softwareSystem);
    parser.parse(context, tokens("container", "Name", "Description", "Technology", "Tag 1, Tag 2"));
    assertEquals(2, model.getElements().size());
    Container container = softwareSystem.getContainerWithName("Name");
    assertNotNull(container);
    assertEquals("Description", container.getDescription());
    assertEquals("Technology", container.getTechnology());
    assertEquals("Element,Container,Tag 1,Tag 2", container.getTags());
}
Also used : Container(com.structurizr.model.Container) SoftwareSystem(com.structurizr.model.SoftwareSystem) Test(org.junit.jupiter.api.Test)

Example 40 with Container

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

the class ComponentParserTests method test_parse_CreatesAComponentWithADescriptionAndTechnology.

@Test
void test_parse_CreatesAComponentWithADescriptionAndTechnology() {
    SoftwareSystem softwareSystem = model.addSoftwareSystem("Software System", "Description");
    Container container = softwareSystem.addContainer("Container", "Description", "Technology");
    ContainerDslContext context = new ContainerDslContext(container);
    parser.parse(context, tokens("component", "Name", "Description", "Technology"));
    assertEquals(3, model.getElements().size());
    Component component = container.getComponentWithName("Name");
    assertNotNull(component);
    assertEquals("Description", component.getDescription());
    assertEquals("Technology", component.getTechnology());
    assertEquals("Element,Component", component.getTags());
}
Also used : Container(com.structurizr.model.Container) SoftwareSystem(com.structurizr.model.SoftwareSystem) Component(com.structurizr.model.Component) Test(org.junit.jupiter.api.Test)

Aggregations

Container (com.structurizr.model.Container)44 Test (org.junit.jupiter.api.Test)25 SoftwareSystem (com.structurizr.model.SoftwareSystem)23 Workspace (com.structurizr.Workspace)22 Component (com.structurizr.model.Component)21 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)10 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)10 Application (org.archifacts.core.model.Application)10 ArtifactContainer (org.archifacts.core.model.ArtifactContainer)10 Model (com.structurizr.model.Model)8 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)5 Set (java.util.Set)5 Stream (java.util.stream.Stream)5 DynamicView (com.structurizr.view.DynamicView)4 Relationship (com.structurizr.model.Relationship)3 ComponentView (com.structurizr.view.ComponentView)3 JavaClass (com.tngtech.archunit.core.domain.JavaClass)3 JavaField (com.tngtech.archunit.core.domain.JavaField)3 File (java.io.File)3