[Entanglement] Update specs

Update specs for move/copy/link services to account
for re-validation at time an action is performed.
nasa/openmctweb#98
This commit is contained in:
Victor Woeltjen 2015-09-22 15:42:39 -07:00
parent 119403e71c
commit 6996883b85
4 changed files with 76 additions and 54 deletions

View File

@ -44,7 +44,8 @@ define(
* @method platform/entanglement.AbstractComposeService#perform
*/
/**
* Check if one object can be composed into another.
* Check if this composition change is valid for these objects.
*
* @param {DomainObject} domainObject the domain object to
* move, copy, or link.
* @param {DomainObject} parent the domain object whose composition

View File

@ -41,19 +41,24 @@ define(
}
describe("CopyService", function () {
describe("validate", function () {
var policyService,
copyService,
object,
parentCandidate,
validate;
var policyService;
beforeEach(function () {
policyService = jasmine.createSpyObj(
'policyService',
['allow']
);
policyService.allow.andReturn(true);
});
describe("validate", function () {
var copyService,
object,
parentCandidate,
validate;
beforeEach(function () {
copyService = new CopyService(
null,
null,
@ -148,7 +153,7 @@ define(
);
createObjectPromise = synchronousPromise(undefined);
creationService.createObject.andReturn(createObjectPromise);
copyService = new CopyService(null, creationService);
copyService = new CopyService(null, creationService, policyService);
copyResult = copyService.perform(object, newParent);
copyFinished = jasmine.createSpy('copyFinished');
copyResult.then(copyFinished);
@ -180,7 +185,8 @@ define(
});
describe("on domainObject with composition", function () {
var childObject,
var newObject,
childObject,
compositionCapability,
compositionPromise;
@ -216,6 +222,17 @@ define(
composition: compositionCapability
}
});
newObject = domainObjectFactory({
name: 'object',
id: 'abc2',
model: {
name: 'some object',
composition: []
},
capabilities: {
composition: compositionCapability
}
});
newParent = domainObjectFactory({
name: 'newParent',
id: '456',
@ -227,9 +244,11 @@ define(
'creationService',
['createObject']
);
createObjectPromise = synchronousPromise(undefined);
policyService.allow.andReturn(true);
createObjectPromise = synchronousPromise(newObject);
creationService.createObject.andReturn(createObjectPromise);
copyService = new CopyService(mockQ, creationService);
copyService = new CopyService(mockQ, creationService, policyService);
copyResult = copyService.perform(object, newParent);
copyFinished = jasmine.createSpy('copyFinished');
copyResult.then(copyFinished);

View File

@ -41,6 +41,7 @@ define(
'policyService',
['allow']
);
mockPolicyService.allow.andReturn(true);
linkService = new LinkService(mockPolicyService);
});
@ -66,7 +67,6 @@ define(
validate = function () {
return linkService.validate(object, parentCandidate);
};
mockPolicyService.allow.andReturn(true);
});
it("does not allow invalid parentCandidate", function () {

View File

@ -40,26 +40,13 @@ define(
var moveService,
policyService,
linkService;
beforeEach(function () {
policyService = jasmine.createSpyObj(
'policyService',
['allow']
);
linkService = new MockLinkService();
moveService = new MoveService(policyService, linkService);
});
describe("validate", function () {
var object,
object,
objectContextCapability,
currentParent,
parentCandidate,
validate;
linkService;
beforeEach(function () {
objectContextCapability = jasmine.createSpyObj(
'objectContextCapability',
[
@ -91,7 +78,19 @@ define(
type: { type: 'parentCandidate' }
}
});
policyService = jasmine.createSpyObj(
'policyService',
['allow']
);
linkService = new MockLinkService();
policyService.allow.andReturn(true);
moveService = new MoveService(policyService, linkService);
});
describe("validate", function () {
var validate;
beforeEach(function () {
validate = function () {
return moveService.validate(object, parentCandidate);
};
@ -145,14 +144,15 @@ define(
describe("perform", function () {
var object,
newParent,
actionCapability,
var actionCapability,
locationCapability,
locationPromise,
newParent,
moveResult;
beforeEach(function () {
newParent = parentCandidate;
actionCapability = jasmine.createSpyObj(
'actionCapability',
['perform']
@ -175,7 +175,9 @@ define(
name: 'object',
capabilities: {
action: actionCapability,
location: locationCapability
location: locationCapability,
context: objectContextCapability,
type: { type: 'object' }
}
});