mirror of
https://github.com/nasa/openmct.git
synced 2025-02-07 11:30:28 +00:00
[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:
parent
119403e71c
commit
6996883b85
@ -44,7 +44,8 @@ define(
|
|||||||
* @method platform/entanglement.AbstractComposeService#perform
|
* @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
|
* @param {DomainObject} domainObject the domain object to
|
||||||
* move, copy, or link.
|
* move, copy, or link.
|
||||||
* @param {DomainObject} parent the domain object whose composition
|
* @param {DomainObject} parent the domain object whose composition
|
||||||
|
@ -41,19 +41,24 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("CopyService", function () {
|
describe("CopyService", function () {
|
||||||
|
var policyService;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
policyService = jasmine.createSpyObj(
|
||||||
|
'policyService',
|
||||||
|
['allow']
|
||||||
|
);
|
||||||
|
policyService.allow.andReturn(true);
|
||||||
|
});
|
||||||
|
|
||||||
describe("validate", function () {
|
describe("validate", function () {
|
||||||
|
|
||||||
var policyService,
|
var copyService,
|
||||||
copyService,
|
|
||||||
object,
|
object,
|
||||||
parentCandidate,
|
parentCandidate,
|
||||||
validate;
|
validate;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
policyService = jasmine.createSpyObj(
|
|
||||||
'policyService',
|
|
||||||
['allow']
|
|
||||||
);
|
|
||||||
copyService = new CopyService(
|
copyService = new CopyService(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@ -148,7 +153,7 @@ define(
|
|||||||
);
|
);
|
||||||
createObjectPromise = synchronousPromise(undefined);
|
createObjectPromise = synchronousPromise(undefined);
|
||||||
creationService.createObject.andReturn(createObjectPromise);
|
creationService.createObject.andReturn(createObjectPromise);
|
||||||
copyService = new CopyService(null, creationService);
|
copyService = new CopyService(null, creationService, policyService);
|
||||||
copyResult = copyService.perform(object, newParent);
|
copyResult = copyService.perform(object, newParent);
|
||||||
copyFinished = jasmine.createSpy('copyFinished');
|
copyFinished = jasmine.createSpy('copyFinished');
|
||||||
copyResult.then(copyFinished);
|
copyResult.then(copyFinished);
|
||||||
@ -180,7 +185,8 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("on domainObject with composition", function () {
|
describe("on domainObject with composition", function () {
|
||||||
var childObject,
|
var newObject,
|
||||||
|
childObject,
|
||||||
compositionCapability,
|
compositionCapability,
|
||||||
compositionPromise;
|
compositionPromise;
|
||||||
|
|
||||||
@ -216,6 +222,17 @@ define(
|
|||||||
composition: compositionCapability
|
composition: compositionCapability
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
newObject = domainObjectFactory({
|
||||||
|
name: 'object',
|
||||||
|
id: 'abc2',
|
||||||
|
model: {
|
||||||
|
name: 'some object',
|
||||||
|
composition: []
|
||||||
|
},
|
||||||
|
capabilities: {
|
||||||
|
composition: compositionCapability
|
||||||
|
}
|
||||||
|
});
|
||||||
newParent = domainObjectFactory({
|
newParent = domainObjectFactory({
|
||||||
name: 'newParent',
|
name: 'newParent',
|
||||||
id: '456',
|
id: '456',
|
||||||
@ -227,9 +244,11 @@ define(
|
|||||||
'creationService',
|
'creationService',
|
||||||
['createObject']
|
['createObject']
|
||||||
);
|
);
|
||||||
createObjectPromise = synchronousPromise(undefined);
|
policyService.allow.andReturn(true);
|
||||||
|
|
||||||
|
createObjectPromise = synchronousPromise(newObject);
|
||||||
creationService.createObject.andReturn(createObjectPromise);
|
creationService.createObject.andReturn(createObjectPromise);
|
||||||
copyService = new CopyService(mockQ, creationService);
|
copyService = new CopyService(mockQ, creationService, policyService);
|
||||||
copyResult = copyService.perform(object, newParent);
|
copyResult = copyService.perform(object, newParent);
|
||||||
copyFinished = jasmine.createSpy('copyFinished');
|
copyFinished = jasmine.createSpy('copyFinished');
|
||||||
copyResult.then(copyFinished);
|
copyResult.then(copyFinished);
|
||||||
|
@ -41,6 +41,7 @@ define(
|
|||||||
'policyService',
|
'policyService',
|
||||||
['allow']
|
['allow']
|
||||||
);
|
);
|
||||||
|
mockPolicyService.allow.andReturn(true);
|
||||||
linkService = new LinkService(mockPolicyService);
|
linkService = new LinkService(mockPolicyService);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -66,7 +67,6 @@ define(
|
|||||||
validate = function () {
|
validate = function () {
|
||||||
return linkService.validate(object, parentCandidate);
|
return linkService.validate(object, parentCandidate);
|
||||||
};
|
};
|
||||||
mockPolicyService.allow.andReturn(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not allow invalid parentCandidate", function () {
|
it("does not allow invalid parentCandidate", function () {
|
||||||
|
@ -40,58 +40,57 @@ define(
|
|||||||
|
|
||||||
var moveService,
|
var moveService,
|
||||||
policyService,
|
policyService,
|
||||||
|
object,
|
||||||
|
objectContextCapability,
|
||||||
|
currentParent,
|
||||||
|
parentCandidate,
|
||||||
linkService;
|
linkService;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
objectContextCapability = jasmine.createSpyObj(
|
||||||
|
'objectContextCapability',
|
||||||
|
[
|
||||||
|
'getParent'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
object = domainObjectFactory({
|
||||||
|
name: 'object',
|
||||||
|
id: 'a',
|
||||||
|
capabilities: {
|
||||||
|
context: objectContextCapability,
|
||||||
|
type: { type: 'object' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
currentParent = domainObjectFactory({
|
||||||
|
name: 'currentParent',
|
||||||
|
id: 'b'
|
||||||
|
});
|
||||||
|
|
||||||
|
objectContextCapability.getParent.andReturn(currentParent);
|
||||||
|
|
||||||
|
parentCandidate = domainObjectFactory({
|
||||||
|
name: 'parentCandidate',
|
||||||
|
model: { composition: [] },
|
||||||
|
id: 'c',
|
||||||
|
capabilities: {
|
||||||
|
type: { type: 'parentCandidate' }
|
||||||
|
}
|
||||||
|
});
|
||||||
policyService = jasmine.createSpyObj(
|
policyService = jasmine.createSpyObj(
|
||||||
'policyService',
|
'policyService',
|
||||||
['allow']
|
['allow']
|
||||||
);
|
);
|
||||||
linkService = new MockLinkService();
|
linkService = new MockLinkService();
|
||||||
|
policyService.allow.andReturn(true);
|
||||||
moveService = new MoveService(policyService, linkService);
|
moveService = new MoveService(policyService, linkService);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("validate", function () {
|
describe("validate", function () {
|
||||||
var object,
|
var validate;
|
||||||
objectContextCapability,
|
|
||||||
currentParent,
|
|
||||||
parentCandidate,
|
|
||||||
validate;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
|
||||||
objectContextCapability = jasmine.createSpyObj(
|
|
||||||
'objectContextCapability',
|
|
||||||
[
|
|
||||||
'getParent'
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
object = domainObjectFactory({
|
|
||||||
name: 'object',
|
|
||||||
id: 'a',
|
|
||||||
capabilities: {
|
|
||||||
context: objectContextCapability,
|
|
||||||
type: { type: 'object' }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
currentParent = domainObjectFactory({
|
|
||||||
name: 'currentParent',
|
|
||||||
id: 'b'
|
|
||||||
});
|
|
||||||
|
|
||||||
objectContextCapability.getParent.andReturn(currentParent);
|
|
||||||
|
|
||||||
parentCandidate = domainObjectFactory({
|
|
||||||
name: 'parentCandidate',
|
|
||||||
model: { composition: [] },
|
|
||||||
id: 'c',
|
|
||||||
capabilities: {
|
|
||||||
type: { type: 'parentCandidate' }
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
validate = function () {
|
validate = function () {
|
||||||
return moveService.validate(object, parentCandidate);
|
return moveService.validate(object, parentCandidate);
|
||||||
};
|
};
|
||||||
@ -145,14 +144,15 @@ define(
|
|||||||
|
|
||||||
describe("perform", function () {
|
describe("perform", function () {
|
||||||
|
|
||||||
var object,
|
var actionCapability,
|
||||||
newParent,
|
|
||||||
actionCapability,
|
|
||||||
locationCapability,
|
locationCapability,
|
||||||
locationPromise,
|
locationPromise,
|
||||||
|
newParent,
|
||||||
moveResult;
|
moveResult;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
newParent = parentCandidate;
|
||||||
|
|
||||||
actionCapability = jasmine.createSpyObj(
|
actionCapability = jasmine.createSpyObj(
|
||||||
'actionCapability',
|
'actionCapability',
|
||||||
['perform']
|
['perform']
|
||||||
@ -175,7 +175,9 @@ define(
|
|||||||
name: 'object',
|
name: 'object',
|
||||||
capabilities: {
|
capabilities: {
|
||||||
action: actionCapability,
|
action: actionCapability,
|
||||||
location: locationCapability
|
location: locationCapability,
|
||||||
|
context: objectContextCapability,
|
||||||
|
type: { type: 'object' }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user