Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

update the code to add the comma, and fix that test that didnt catch it #4098

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/composer-common/lib/serializer/jsongenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class JSONGenerator {
if (this.permitResourcesForRelationships && item instanceof Resource) {
let fqi = item.getFullyQualifiedIdentifier();
if (parameters.seenResources.has(fqi)) {
parameters.writer.writeComma();
let relationshipText = this.getRelationshipText(relationshipDeclaration, item);
parameters.writer.writeStringValue(relationshipText);
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/composer-common/test/serializer/jsongenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ describe('JSONGenerator', () => {
};
options.stack.push([resource1, resource2, resource3]);
jsonGenerator.visitRelationshipDeclaration(relationshipDeclaration4, options);
options.writer.getBuffer().should.equal('"next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_1","next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_2","next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_3","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_1""resource:org.acme.SimpleAssetCircleArray#DOGE_2"]}"resource:org.acme.SimpleAssetCircleArray#DOGE_1"]},{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_3","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_1",{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_2","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_3""resource:org.acme.SimpleAssetCircleArray#DOGE_1"]}]}]},{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_2","next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_3","next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_1","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_2""resource:org.acme.SimpleAssetCircleArray#DOGE_3"]}"resource:org.acme.SimpleAssetCircleArray#DOGE_2"]},{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_1","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_2",{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_3","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_1""resource:org.acme.SimpleAssetCircleArray#DOGE_2"]}]}]},{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_3","next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_1","next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_2","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_3""resource:org.acme.SimpleAssetCircleArray#DOGE_1"]}"resource:org.acme.SimpleAssetCircleArray#DOGE_3"]},{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_2","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_3",{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_1","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_2""resource:org.acme.SimpleAssetCircleArray#DOGE_3"]}]}]}]');
options.writer.getBuffer().should.equal('"next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_1","next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_2","next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_3","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_1","resource:org.acme.SimpleAssetCircleArray#DOGE_2"]},"resource:org.acme.SimpleAssetCircleArray#DOGE_1"]},{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_3","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_1",{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_2","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_3","resource:org.acme.SimpleAssetCircleArray#DOGE_1"]}]}]},{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_2","next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_3","next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_1","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_2","resource:org.acme.SimpleAssetCircleArray#DOGE_3"]},"resource:org.acme.SimpleAssetCircleArray#DOGE_2"]},{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_1","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_2",{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_3","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_1","resource:org.acme.SimpleAssetCircleArray#DOGE_2"]}]}]},{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_3","next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_1","next":[{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_2","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_3","resource:org.acme.SimpleAssetCircleArray#DOGE_1"]},"resource:org.acme.SimpleAssetCircleArray#DOGE_3"]},{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_2","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_3",{"$class":"org.acme.SimpleAssetCircleArray","assetId":"DOGE_1","next":["resource:org.acme.SimpleAssetCircleArray#DOGE_2","resource:org.acme.SimpleAssetCircleArray#DOGE_3"]}]}]}]');
});

it('should throw if stack contains something other than a Resource or Concept', () => {
Expand Down