mirror of
https://github.com/nasa/openmct.git
synced 2024-12-30 09:58:52 +00:00
Merge branch 'conditionSet-telemetry' of https://github.com/nasa/openmct into condition-class
This commit is contained in:
commit
1589e4236a
@ -24,9 +24,7 @@ export default function ConditionSetCompositionPolicy(openmct) {
|
||||
return {
|
||||
allow: function (parent, child) {
|
||||
let parentType = parent.type;
|
||||
let childType = child.type;
|
||||
|
||||
if (parentType === 'conditionSet' && childType !== 'condition') {
|
||||
if (parentType === 'conditionSet' && !openmct.telemetry.isTelemetryObject(child)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -21,43 +21,67 @@
|
||||
*****************************************************************************/
|
||||
|
||||
import ConditionSetCompositionPolicy from './ConditionSetCompositionPolicy';
|
||||
import { createOpenMct } from "testTools";
|
||||
|
||||
describe('ConditionSetCompositionPolicy', () => {
|
||||
fdescribe('ConditionSetCompositionPolicy', () => {
|
||||
|
||||
let policy;
|
||||
let testTelemetryObject;
|
||||
let openmct = {};
|
||||
let parentDomainObject;
|
||||
let childDomainObject;
|
||||
let composition;
|
||||
|
||||
beforeEach(function () {
|
||||
policy = new ConditionSetCompositionPolicy();
|
||||
beforeAll(function () {
|
||||
testTelemetryObject = {
|
||||
identifier:{ namespace: "", key: "test-object"},
|
||||
type: "test-object",
|
||||
name: "Test Object",
|
||||
telemetry: {
|
||||
values: [{
|
||||
key: "some-key",
|
||||
name: "Some attribute",
|
||||
hints: {
|
||||
domain: 1
|
||||
}
|
||||
}, {
|
||||
key: "some-other-key",
|
||||
name: "Another attribute",
|
||||
hints: {
|
||||
range: 1
|
||||
}
|
||||
}]
|
||||
}
|
||||
};
|
||||
openmct.objects = jasmine.createSpyObj('objects', ['get', 'makeKeyString']);
|
||||
openmct.objects.get.and.returnValue(testTelemetryObject);
|
||||
openmct.objects.makeKeyString.and.returnValue(testTelemetryObject.identifier.key);
|
||||
openmct.telemetry = jasmine.createSpyObj('telemetry', ['isTelemetryObject']);
|
||||
policy = new ConditionSetCompositionPolicy(openmct);
|
||||
parentDomainObject = {};
|
||||
childDomainObject = {};
|
||||
composition = {};
|
||||
});
|
||||
|
||||
it('returns true for object types that are not conditionSets', function () {
|
||||
parentDomainObject.type = 'random';
|
||||
childDomainObject.type = '';
|
||||
expect(policy.allow(parentDomainObject, childDomainObject)).toBe(true);
|
||||
openmct.telemetry.isTelemetryObject.and.returnValue(false);
|
||||
expect(policy.allow(parentDomainObject, {})).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false for object types that are not conditions when parent is a conditionSet', function () {
|
||||
it('returns false for object types that are not telemetry objects when parent is a conditionSet', function () {
|
||||
parentDomainObject.type = 'conditionSet';
|
||||
childDomainObject.type = '';
|
||||
expect(policy.allow(parentDomainObject, childDomainObject)).toBe(false);
|
||||
openmct.telemetry.isTelemetryObject.and.returnValue(false);
|
||||
expect(policy.allow(parentDomainObject, {})).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true for object types that are conditions when parent is a conditionSet', function () {
|
||||
it('returns true for object types that are telemetry objects when parent is a conditionSet', function () {
|
||||
parentDomainObject.type = 'conditionSet';
|
||||
childDomainObject.type = 'condition';
|
||||
expect(policy.allow(parentDomainObject, childDomainObject)).toBe(true);
|
||||
openmct.telemetry.isTelemetryObject.and.returnValue(true);
|
||||
expect(policy.allow(parentDomainObject, testTelemetryObject)).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true for object types that are conditions when parent is not a conditionSet', function () {
|
||||
it('returns true for object types that are telemetry objects when parent is not a conditionSet', function () {
|
||||
parentDomainObject.type = 'random';
|
||||
childDomainObject.type = 'condition';
|
||||
expect(policy.allow(parentDomainObject, childDomainObject)).toBe(true);
|
||||
openmct.telemetry.isTelemetryObject.and.returnValue(true);
|
||||
expect(policy.allow(parentDomainObject, testTelemetryObject)).toBe(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -20,6 +20,7 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
import ConditionSetViewProvider from './ConditionSetViewProvider.js';
|
||||
import ConditionSetCompositionPolicy from "@/plugins/condition/ConditionSetCompositionPolicy";
|
||||
|
||||
export default function ConditionPlugin() {
|
||||
|
||||
@ -45,6 +46,8 @@ export default function ConditionPlugin() {
|
||||
}
|
||||
});
|
||||
|
||||
openmct.composition.addPolicy(new ConditionSetCompositionPolicy(openmct).allow);
|
||||
|
||||
openmct.objectViews.addProvider(new ConditionSetViewProvider(openmct));
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user