Skip to content

Commit

Permalink
fix for file import problem (hyperledger-archives#2357)
Browse files Browse the repository at this point in the history
Signed-off-by: awjh-ibm <[email protected]>
  • Loading branch information
awjh-ibm authored and nklincoln committed Oct 12, 2017
1 parent 4652ce1 commit 5f3ee71
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,19 @@ describe('DeployComponent', () => {
getPackageJson: sinon.stub().returns({json: 'some json'})
};

mockAssetDeclaration = sinon.createStubInstance(AssetDeclaration);
mockParticipantDeclaration = sinon.createStubInstance(ParticipantDeclaration);
mockTransactionDeclaration = sinon.createStubInstance(TransactionDeclaration);

mockModelManager = sinon.createStubInstance(ModelManager);
mockModelManager.getParticipantDeclarations.returns([mockParticipantDeclaration]);
mockModelManager.getTransactionDeclarations.returns([mockTransactionDeclaration]);
mockModelManager.getAssetDeclarations.returns([mockAssetDeclaration]);

let businessNetworkMock = {
network: 'mockNetwork',
getMetadata: sinon.stub().returns(metaDataMock)
getMetadata: sinon.stub().returns(metaDataMock),
getModelManager: sinon.stub().returns(mockModelManager)
};

mockClientService.getBusinessNetworkFromArchive.returns(Promise.resolve(businessNetworkMock));
Expand All @@ -339,6 +349,9 @@ describe('DeployComponent', () => {

mockClientService.getBusinessNetworkFromArchive.should.have.been.called;
component['currentBusinessNetwork'].network.should.equal('mockNetwork');
component['currentBusinessNetwork']['participants'].should.deep.equal([mockParticipantDeclaration]);
component['currentBusinessNetwork']['transactions'].should.deep.equal([mockTransactionDeclaration]);
component['currentBusinessNetwork']['assets'].should.deep.equal([mockAssetDeclaration]);
component['expandInput'].should.equal(false);
component['chosenNetwork'].should.deep.equal({json: 'some json'});
component['sampleDropped'].should.equal(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ rule NetworkAdminSystem {
.then((businessNetwork) => {
this.chosenNetwork = businessNetwork.getMetadata().getPackageJson();
this.currentBusinessNetwork = businessNetwork;
this.currentBusinessNetwork.participants = businessNetwork.getModelManager().getParticipantDeclarations(false);
this.currentBusinessNetwork.assets = businessNetwork.getModelManager().getAssetDeclarations(false);
this.currentBusinessNetwork.transactions = businessNetwork.getModelManager().getTransactionDeclarations(false);
this.sampleDropped = true;
// needed for if browse file
this.expandInput = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,19 @@ describe('UpdateComponent', () => {
getPackageJson: sinon.stub().returns({json: 'some json'})
};

mockAssetDeclaration = sinon.createStubInstance(AssetDeclaration);
mockParticipantDeclaration = sinon.createStubInstance(ParticipantDeclaration);
mockTransactionDeclaration = sinon.createStubInstance(TransactionDeclaration);

mockModelManager = sinon.createStubInstance(ModelManager);
mockModelManager.getParticipantDeclarations.returns([mockParticipantDeclaration]);
mockModelManager.getTransactionDeclarations.returns([mockTransactionDeclaration]);
mockModelManager.getAssetDeclarations.returns([mockAssetDeclaration]);

let businessNetworkMock = {
network: 'mockNetwork',
getMetadata: sinon.stub().returns(metaDataMock)
getMetadata: sinon.stub().returns(metaDataMock),
getModelManager: sinon.stub().returns(mockModelManager)
};

mockClientService.getBusinessNetworkFromArchive.returns(Promise.resolve(businessNetworkMock));
Expand All @@ -343,6 +353,9 @@ describe('UpdateComponent', () => {

mockClientService.getBusinessNetworkFromArchive.should.have.been.called;
component['currentBusinessNetwork'].network.should.equal('mockNetwork');
component['currentBusinessNetwork']['participants'].should.deep.equal([mockParticipantDeclaration]);
component['currentBusinessNetwork']['transactions'].should.deep.equal([mockTransactionDeclaration]);
component['currentBusinessNetwork']['assets'].should.deep.equal([mockAssetDeclaration]);
component['expandInput'].should.equal(false);
component['chosenNetwork'].should.deep.equal({json: 'some json'});
component['sampleDropped'].should.equal(true);
Expand Down

0 comments on commit 5f3ee71

Please sign in to comment.