-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ap-publish-v3.23.2
Signed-off-by: Jamie Shorten <[email protected]>
- Loading branch information
Showing
4 changed files
with
150 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,7 +185,7 @@ class ConcertoGraphVisitor extends DiagramVisitor { | |
if (classDeclaration.getSuperType()){ | ||
parameters.graph.addEdge(classDeclaration.getFullyQualifiedName(), classDeclaration.getSuperType()); | ||
// this "if" block adds the types that extend the Super type | ||
if(classDeclaration.getSuperType() !== '[email protected]') { | ||
if(!parameters.createDependencyGraph && classDeclaration.getSuperType() !== '[email protected]') { | ||
parameters.graph.addVertex(classDeclaration.getSuperType()); | ||
parameters.graph.addEdge(classDeclaration.getSuperType(), classDeclaration.getFullyQualifiedName()); | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,10 @@ | |
|
||
'use strict'; | ||
|
||
const { DirectedGraph, ConcertoGraphVisitor } = require('../../lib/common/common.js'); | ||
const { | ||
DirectedGraph, | ||
ConcertoGraphVisitor, | ||
} = require('../../lib/common/common.js'); | ||
const { ModelManager } = require('@accordproject/concerto-core'); | ||
const fs = require('fs'); | ||
const { expect } = require('expect'); | ||
|
@@ -26,7 +29,7 @@ chai.should(); | |
chai.use(require('chai-as-promised')); | ||
chai.use(require('chai-things')); | ||
|
||
describe('graph', function () { | ||
describe('graph', function() { | ||
let modelManager = null; | ||
|
||
before(function() { | ||
|
@@ -35,15 +38,20 @@ describe('graph', function () { | |
|
||
beforeEach(function() { | ||
modelManager = new ModelManager(); | ||
const hrBase = fs.readFileSync('./test/codegen/fromcto/data/model/hr_base.cto', 'utf-8'); | ||
const hrBase = fs.readFileSync( | ||
'./test/codegen/fromcto/data/model/hr_base.cto', | ||
'utf-8' | ||
); | ||
modelManager.addCTOModel(hrBase, 'hr_base.cto'); | ||
const hr = fs.readFileSync('./test/codegen/fromcto/data/model/hr.cto', 'utf-8'); | ||
const hr = fs.readFileSync( | ||
'./test/codegen/fromcto/data/model/hr.cto', | ||
'utf-8' | ||
); | ||
modelManager.addCTOModel(hr, 'hr.cto'); | ||
}); | ||
|
||
|
||
describe('#visitor', function () { | ||
it('should visit a model manager', function () { | ||
describe('#visitor', function() { | ||
it('should visit a model manager', function() { | ||
const visitor = new ConcertoGraphVisitor(); | ||
visitor.should.not.be.null; | ||
const writer = new InMemoryWriter(); | ||
|
@@ -136,23 +144,32 @@ describe('graph', function () { | |
`); | ||
}); | ||
|
||
|
||
it('should visit find a connected subgraph', function () { | ||
it('should visit find a connected subgraph', function() { | ||
const visitor = new ConcertoGraphVisitor(); | ||
visitor.should.not.be.null; | ||
const writer = new InMemoryWriter(); | ||
|
||
const graph = new DirectedGraph(); | ||
modelManager.accept(visitor, { graph }); | ||
|
||
const connectedGraph = graph.findConnectedGraph('[email protected]'); | ||
expect(connectedGraph.hasEdge('[email protected]', '[email protected]')); | ||
const connectedGraph = graph.findConnectedGraph( | ||
'[email protected]' | ||
); | ||
expect( | ||
connectedGraph.hasEdge( | ||
'[email protected]', | ||
'[email protected]' | ||
) | ||
); | ||
|
||
const filteredModelManager = modelManager | ||
.filter(declaration => connectedGraph.hasVertex(declaration.getFullyQualifiedName())); | ||
const filteredModelManager = modelManager.filter((declaration) => | ||
connectedGraph.hasVertex(declaration.getFullyQualifiedName()) | ||
); | ||
|
||
expect(filteredModelManager.getModelFiles()).toHaveLength(2); | ||
expect(filteredModelManager.getModelFiles()[0].getAllDeclarations()).toHaveLength(5); | ||
expect( | ||
filteredModelManager.getModelFiles()[0].getAllDeclarations() | ||
).toHaveLength(5); | ||
|
||
writer.openFile('graph.mmd'); | ||
connectedGraph.print(writer); | ||
|
@@ -226,6 +243,98 @@ describe('graph', function () { | |
\`[email protected]\` <--> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` | ||
`); | ||
}); | ||
|
||
it('should visit a model manager and create a dependency graph', function() { | ||
const visitor = new ConcertoGraphVisitor(); | ||
visitor.should.not.be.null; | ||
const writer = new InMemoryWriter(); | ||
|
||
const graph = new DirectedGraph(); | ||
modelManager.accept(visitor, { | ||
graph, | ||
createDependencyGraph: true, | ||
}); | ||
|
||
writer.openFile('graph.mmd'); | ||
graph.print(writer); | ||
writer.closeFile(); | ||
expect(writer.data.get('graph.mmd')).toEqual(`flowchart LR | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`String\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`String\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`String\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`String\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` <--> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` --> \`[email protected]\` | ||
\`[email protected]\` | ||
\`[email protected]\` | ||
`); | ||
}); | ||
}); | ||
|