Skip to content

Commit

Permalink
Merge branch 'main' into ap-publish-v3.23.2
Browse files Browse the repository at this point in the history
Signed-off-by: Jamie Shorten <[email protected]>
  • Loading branch information
jamieshorten authored Aug 23, 2024
2 parents 4b0b677 + e7d9c7c commit b6fd9d6
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 41 deletions.
2 changes: 1 addition & 1 deletion lib/common/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
42 changes: 21 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@accordproject/concerto-codegen",
"version": "3.23.2",
"version": "3.23.3",
"description": "Code Generation for the Concerto Modeling Language",
"homepage": "https://github.com/accordproject/concerto",
"engines": {
Expand Down Expand Up @@ -45,7 +45,7 @@
"author": "accordproject.org",
"license": "Apache-2.0",
"devDependencies": {
"@accordproject/concerto-cto": "3.18.0",
"@accordproject/concerto-cto": "3.18.1",
"@babel/preset-env": "7.16.11",
"babel-loader": "8.2.3",
"chai": "4.3.6",
Expand All @@ -70,9 +70,9 @@
"webpack-cli": "4.9.1"
},
"dependencies": {
"@accordproject/concerto-core": "3.18.0",
"@accordproject/concerto-util": "3.18.0",
"@accordproject/concerto-vocabulary": "3.18.0",
"@accordproject/concerto-core": "3.18.1",
"@accordproject/concerto-util": "3.18.1",
"@accordproject/concerto-vocabulary": "3.18.1",
"@openapi-contrib/openapi-schema-to-json-schema": "5.1.0",
"ajv": "8.13.0",
"ajv-formats": "3.0.1",
Expand Down
137 changes: 123 additions & 14 deletions test/common/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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() {
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]\`
`);
});
});
Expand Down

0 comments on commit b6fd9d6

Please sign in to comment.