Search in sources :

Example 1 with SimpleOutputBuilder

use of org.ndx.agile.architecture.base.utils.SimpleOutputBuilder in project agile-architecture-documentation-system by Riduidel.

the class SequenceDiagramVisitorTest method can_read_a_model.

@Test
@Disabled
void can_read_a_model() {
    // Given all those elements
    Workspace workspace = new Workspace("test workspace", "test workspace");
    Model model = workspace.getModel();
    SoftwareSystem system = model.addSoftwareSystem("agile-architecture-documentation-system");
    Container sequenceGenerator = system.addContainer("sequence-generator", "generator", "Java/Maven");
    sequenceGenerator.addProperty(SequenceGenerator.GENERATES_WITH, StructurizrUtils.getCanonicalPath(sequenceGenerator));
    sequenceGenerator.addProperty(ModelElementKeys.JAVA_SOURCES, new File("src/main/java").toURI().toString());
    Component visitor = sequenceGenerator.addComponent(SequenceDiagramVisitor.class.getSimpleName(), "visitor building the sequence");
    visitor.addSupportingType(SequenceDiagramVisitor.class.getName());
    Component callGraphModel = sequenceGenerator.addComponent(CallGraphModel.class.getSimpleName(), "navigator accumulating data");
    callGraphModel.addSupportingType(CallGraphModel.class.getName());
    Component generator = sequenceGenerator.addComponent(SequenceDiagramGenerator.class.getSimpleName(), "Component producing the sequence diagram");
    generator.addSupportingType(SequenceDiagramGenerator.class.getName());
    // Let's build a sequence diagram visitor
    SequenceDiagramVisitor tested = new SequenceDiagramVisitor();
    tested.logger = Logger.getLogger(getClass().getName());
    tested.destination = new File("target/tests/" + getClass().getSimpleName());
    // Emulate the standard visit
    tested.startVisit(model);
    tested.startVisit(system);
    assertThat(tested.allContainers).hasSize(1);
    assertThat(tested.codeToComponents).hasSize(3);
    assertThat(tested.callGraphModel).isNull();
    // And finally, visit the container and parse source code
    tested.startVisit(sequenceGenerator);
    assertThat(tested.callGraphModel).isNotNull();
    // And visit components to see what happens
    assertThat(tested.startVisit(visitor)).isTrue();
    // And that something is generated
    tested.endVisit(visitor, new SimpleOutputBuilder(tested.destination));
    assertThat(tested.destination).isDirectoryContaining(file -> file.getName().equals(system.getName()));
}
Also used : Container(com.structurizr.model.Container) CallGraphModel(org.ndx.agile.architecture.sequence.generator.javaparser.adapter.CallGraphModel) SequenceDiagramGenerator(org.ndx.agile.architecture.sequence.generator.javaparser.generator.SequenceDiagramGenerator) CallGraphModel(org.ndx.agile.architecture.sequence.generator.javaparser.adapter.CallGraphModel) Model(com.structurizr.model.Model) SoftwareSystem(com.structurizr.model.SoftwareSystem) Component(com.structurizr.model.Component) File(java.io.File) Workspace(com.structurizr.Workspace) SimpleOutputBuilder(org.ndx.agile.architecture.base.utils.SimpleOutputBuilder) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

Workspace (com.structurizr.Workspace)1 Component (com.structurizr.model.Component)1 Container (com.structurizr.model.Container)1 Model (com.structurizr.model.Model)1 SoftwareSystem (com.structurizr.model.SoftwareSystem)1 File (java.io.File)1 Disabled (org.junit.jupiter.api.Disabled)1 Test (org.junit.jupiter.api.Test)1 SimpleOutputBuilder (org.ndx.agile.architecture.base.utils.SimpleOutputBuilder)1 CallGraphModel (org.ndx.agile.architecture.sequence.generator.javaparser.adapter.CallGraphModel)1 SequenceDiagramGenerator (org.ndx.agile.architecture.sequence.generator.javaparser.generator.SequenceDiagramGenerator)1