Skip to content

Commit

Permalink
fix(tools) Fixes some failing tests after the last commit
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Simeon <jeromesimeon@me.com>
  • Loading branch information
jeromesimeon committed Nov 9, 2020
1 parent f9d5446 commit 77174fd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ describe('JavaVisitor', function () {
param.fileWriter.writeLine.callCount.should.deep.equal(4);
param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, 'import oranges;']);
param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, 'import apples;']);
param.fileWriter.writeLine.getCall(2).args.should.deep.equal([0, 'public class Bob extends org.hyperledger.composer.system.Resource {']);
param.fileWriter.writeLine.getCall(2).args.should.deep.equal([0, 'public class Bob {']);
param.fileWriter.writeLine.getCall(3).args.should.deep.equal([0, '}']);
acceptSpy.withArgs(javaVisit, Object.assign({},param,{mode:'field'})).calledTwice.should.be.ok;
acceptSpy.withArgs(javaVisit, Object.assign({},param,{mode:'getter'})).calledTwice.should.be.ok;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('LoopbackVisitor with Circular Model', () => {

// Visit all of the loaded model files and check that they were all generated
const schemas = modelManager.accept(visitor, { fileWriter: mockFileWriter });
schemas.length.should.equal(32);
schemas.length.should.equal(29);
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,10 @@ describe('TypescriptVisitor', function () {
typescriptVisitor.visitModelFile(mockModelFile, param);

param.fileWriter.openFile.withArgs('org.acme.Person.ts').calledOnce.should.be.ok;
param.fileWriter.writeLine.callCount.should.deep.equal(5);
param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, 'import {Bob} from \'./org.hyperledger.composer.system\';']);
param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, 'import {Fred} from \'./org.hyperledger.composer.system\';']);
param.fileWriter.writeLine.getCall(2).args.should.deep.equal([0, 'import {Property1,Property3} from \'./org.org1\';']);
param.fileWriter.writeLine.getCall(3).args.should.deep.equal([0, '// export namespace org.acme.Person{']);
param.fileWriter.writeLine.getCall(4).args.should.deep.equal([0, '// }']);
param.fileWriter.writeLine.callCount.should.deep.equal(3);
param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, 'import {Property1,Property3} from \'./org.org1\';']);
param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '// export namespace org.acme.Person{']);
param.fileWriter.writeLine.getCall(2).args.should.deep.equal([0, '// }']);
param.fileWriter.closeFile.calledOnce.should.be.ok;

acceptSpy.withArgs(typescriptVisitor, param).calledTwice.should.be.ok;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,19 @@ describe('XmlSchemaVisitor', function () {
};
mockModelFile.getNamespace.returns('org.hyperledger.composer.system');
mockModelFile.getAllDeclarations.returns([mockClassDeclaration]);
mockModelFile.getImports.returns(['org.imported.ImportedType']);
mockModelManager.getModelFiles.returns([mockModelFile]);

xmlSchemaVisitor.visit(mockModelManager, param);

param.fileWriter.openFile.withArgs('org.hyperledger.composer.system.xsd').calledOnce.should.be.ok;
param.fileWriter.writeLine.callCount.should.deep.equal(4);
param.fileWriter.writeLine.callCount.should.deep.equal(6);
param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '<?xml version="1.0"?>']);
param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '<xs:schema xmlns:org.hyperledger.composer.system="org.hyperledger.composer.system" targetNamespace="org.hyperledger.composer.system" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" ']);
param.fileWriter.writeLine.getCall(2).args.should.deep.equal([0, '>']);
param.fileWriter.writeLine.getCall(3).args.should.deep.equal([0, '</xs:schema>']);
param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '<xs:schema xmlns:org.hyperledger.composer.system=\"org.hyperledger.composer.system\" targetNamespace=\"org.hyperledger.composer.system\" elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" ']);
param.fileWriter.writeLine.getCall(2).args.should.deep.equal([0, 'xmlns:org.imported=\"org.imported\"']);
param.fileWriter.writeLine.getCall(3).args.should.deep.equal([0, '>']);
param.fileWriter.writeLine.getCall(4).args.should.deep.equal([0, '<xs:import namespace=\"org.imported\" schemaLocation=\"org.imported.xsd\"/>']);
param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '</xs:schema>']);

param.fileWriter.closeFile.calledOnce.should.be.ok;
});
Expand Down Expand Up @@ -178,16 +181,20 @@ describe('XmlSchemaVisitor', function () {
};
mockModelFile.getNamespace.returns('org.hyperledger.composer.system');
mockModelFile.getAllDeclarations.returns([mockClassDeclaration]);
mockModelFile.getImports.returns(['org.imported.ImportedType']);

mockModelManager.getModelFiles.returns([mockModelFile]);

xmlSchemaVisitor.visitModelManager(mockModelManager, param);

param.fileWriter.openFile.withArgs('org.hyperledger.composer.system.xsd').calledOnce.should.be.ok;
param.fileWriter.writeLine.callCount.should.deep.equal(4);
param.fileWriter.writeLine.callCount.should.deep.equal(6);
param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '<?xml version="1.0"?>']);
param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '<xs:schema xmlns:org.hyperledger.composer.system="org.hyperledger.composer.system" targetNamespace="org.hyperledger.composer.system" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" ']);
param.fileWriter.writeLine.getCall(2).args.should.deep.equal([0, '>']);
param.fileWriter.writeLine.getCall(3).args.should.deep.equal([0, '</xs:schema>']);
param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '<xs:schema xmlns:org.hyperledger.composer.system=\"org.hyperledger.composer.system\" targetNamespace=\"org.hyperledger.composer.system\" elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" ']);
param.fileWriter.writeLine.getCall(2).args.should.deep.equal([0, 'xmlns:org.imported=\"org.imported\"']);
param.fileWriter.writeLine.getCall(3).args.should.deep.equal([0, '>']);
param.fileWriter.writeLine.getCall(4).args.should.deep.equal([0, '<xs:import namespace=\"org.imported\" schemaLocation=\"org.imported.xsd\"/>']);
param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '</xs:schema>']);

param.fileWriter.closeFile.calledOnce.should.be.ok;
});
Expand Down Expand Up @@ -238,17 +245,15 @@ describe('XmlSchemaVisitor', function () {
xmlSchemaVisitor.visitModelManager(mockModelManager, param);

param.fileWriter.openFile.withArgs('org.foo.xsd').calledOnce.should.be.ok;
param.fileWriter.writeLine.callCount.should.deep.equal(10);
param.fileWriter.writeLine.callCount.should.deep.equal(8);
param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '<?xml version="1.0"?>']);
param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '<xs:schema xmlns:org.foo="org.foo" targetNamespace="org.foo" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" ']);
param.fileWriter.writeLine.getCall(2).args.should.deep.equal([1, 'xmlns:org.hyperledger.composer.system="org.hyperledger.composer.system"']);
param.fileWriter.writeLine.getCall(3).args.should.deep.equal([0, 'xmlns:org.imported="org.imported"']);
param.fileWriter.writeLine.getCall(4).args.should.deep.equal([0, 'xmlns:org.different="org.different"']);
param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '>']);
param.fileWriter.writeLine.getCall(6).args.should.deep.equal([0, '<xs:import namespace="org.hyperledger.composer.system" schemaLocation="org.hyperledger.composer.system.xsd"/>']);
param.fileWriter.writeLine.getCall(7).args.should.deep.equal([0, '<xs:import namespace="org.imported" schemaLocation="org.imported.xsd"/>']);
param.fileWriter.writeLine.getCall(8).args.should.deep.equal([0, '<xs:import namespace="org.different" schemaLocation="org.different.xsd"/>']);
param.fileWriter.writeLine.getCall(9).args.should.deep.equal([0, '</xs:schema>']);
param.fileWriter.writeLine.getCall(2).args.should.deep.equal([0, 'xmlns:org.imported="org.imported"']);
param.fileWriter.writeLine.getCall(3).args.should.deep.equal([0, 'xmlns:org.different="org.different"']);
param.fileWriter.writeLine.getCall(4).args.should.deep.equal([0, '>']);
param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '<xs:import namespace="org.imported" schemaLocation="org.imported.xsd"/>']);
param.fileWriter.writeLine.getCall(6).args.should.deep.equal([0, '<xs:import namespace="org.different" schemaLocation="org.different.xsd"/>']);
param.fileWriter.writeLine.getCall(7).args.should.deep.equal([0, '</xs:schema>']);

param.fileWriter.closeFile.calledOnce.should.be.ok;
});
Expand Down

0 comments on commit 77174fd

Please sign in to comment.