summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/composition
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2020-02-14 15:37:17 +0000
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-03-12 09:32:34 +0000
commitebda3c95e2ff975b34033de0640f0a137b8a1fa9 (patch)
tree809a65b13d3019e9a54fe2bcf02a6577d78011ab /catalog-ui/src/app/ng2/pages/composition
parent2a1d018b1b1f364362ff2a764ee16f3320388daa (diff)
Support Tosca DependsOn root node relationship​
tosca.nodes.Root supports the use of a DependsOn relationship to indicate a general dependency relationship between two nodes. SDC currently disallows this relationship to be created in the VF/Service composition view. Change-Id: Ie5f1f5d2e5173b59f878986ee625b27aaa81e4f6 Issue-ID: SDC-2768 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/composition')
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/graph/composition-graph.module.ts2
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-general-utils.ts2
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-links-utils.ts2
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-palette-utils.ts2
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/graph/utils/index.ts2
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/graph/utils/match-capability-requirement-utils.spec.ts (renamed from catalog-ui/src/app/ng2/pages/composition/graph/utils/match-capability-requierment-utils.spec.ts)93
-rw-r--r--catalog-ui/src/app/ng2/pages/composition/graph/utils/match-capability-requirement-utils.ts (renamed from catalog-ui/src/app/ng2/pages/composition/graph/utils/match-capability-requierment-utils.ts)5
7 files changed, 55 insertions, 53 deletions
diff --git a/catalog-ui/src/app/ng2/pages/composition/graph/composition-graph.module.ts b/catalog-ui/src/app/ng2/pages/composition/graph/composition-graph.module.ts
index e58d160c4d..1a20b53bed 100644
--- a/catalog-ui/src/app/ng2/pages/composition/graph/composition-graph.module.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/graph/composition-graph.module.ts
@@ -8,7 +8,7 @@ import {CommonGraphUtils} from "./common/common-graph-utils";
import {LinksFactory} from "app/models/graph/graph-links/links-factory";
import {NodesFactory} from "app/models/graph/nodes/nodes-factory";
import {ImageCreatorService} from "./common/image-creator.service";
-import {MatchCapabilitiesRequirementsUtils} from "./utils/match-capability-requierment-utils";
+import {MatchCapabilitiesRequirementsUtils} from "./utils/match-capability-requirement-utils";
import {CompositionGraphNodesUtils} from "./utils/composition-graph-nodes-utils";
import {ConnectionWizardService} from "app/ng2/pages/composition/graph/connection-wizard/connection-wizard.service";
import {CompositionGraphPaletteUtils} from "./utils/composition-graph-palette-utils";
diff --git a/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-general-utils.ts b/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-general-utils.ts
index bc8bd691c9..8b4a29414b 100644
--- a/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-general-utils.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-general-utils.ts
@@ -21,7 +21,7 @@
import * as _ from "lodash";
import {ComponentInstance, Match, CompositionCiLinkBase, CompositionCiNodeUcpeCp} from "app/models";
import {Dictionary, GraphUIObjects} from "app/utils";
-import {MatchCapabilitiesRequirementsUtils} from "./match-capability-requierment-utils";
+import {MatchCapabilitiesRequirementsUtils} from "./match-capability-requirement-utils";
import {CommonGraphUtils} from "../common/common-graph-utils";
import {Injectable} from "@angular/core";
import {QueueServiceUtils} from "app/ng2/utils/queue-service-utils";
diff --git a/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-links-utils.ts b/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-links-utils.ts
index 6035d05b7f..ba35a98332 100644
--- a/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-links-utils.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-links-utils.ts
@@ -40,7 +40,7 @@ import {
} from "app/models";
import {CommonGraphUtils} from "../common/common-graph-utils";
import {CompositionGraphGeneralUtils} from "./composition-graph-general-utils";
-import {MatchCapabilitiesRequirementsUtils} from "./match-capability-requierment-utils";
+import {MatchCapabilitiesRequirementsUtils} from "./match-capability-requirement-utils";
import {CompositionCiServicePathLink} from "app/models/graph/graph-links/composition-graph-links/composition-ci-service-path-link";
import {Injectable} from "@angular/core";
import {QueueServiceUtils} from "app/ng2/utils/queue-service-utils";
diff --git a/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-palette-utils.ts b/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-palette-utils.ts
index 1776c2f9b9..922f19cb7f 100644
--- a/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-palette-utils.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/graph/utils/composition-graph-palette-utils.ts
@@ -34,7 +34,7 @@ import {CompositionService} from "../../composition.service";
import {WorkspaceService} from "app/ng2/pages/workspace/workspace.service";
import { QueueServiceUtils } from "app/ng2/utils/queue-service-utils";
import {ComponentGenericResponse} from "../../../../services/responses/component-generic-response";
-import {MatchCapabilitiesRequirementsUtils} from "./match-capability-requierment-utils";
+import {MatchCapabilitiesRequirementsUtils} from "./match-capability-requirement-utils";
import {CompositionGraphNodesUtils} from "./index";
@Injectable()
diff --git a/catalog-ui/src/app/ng2/pages/composition/graph/utils/index.ts b/catalog-ui/src/app/ng2/pages/composition/graph/utils/index.ts
index e7f11af248..e1621d1a4c 100644
--- a/catalog-ui/src/app/ng2/pages/composition/graph/utils/index.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/graph/utils/index.ts
@@ -11,7 +11,7 @@
import {CompositionGraphGeneralUtils} from './composition-graph-general-utils';
import {CompositionGraphNodesUtils} from './composition-graph-nodes-utils';
-import {MatchCapabilitiesRequirementsUtils} from './match-capability-requierment-utils'
+import {MatchCapabilitiesRequirementsUtils} from './match-capability-requirement-utils'
import {CompositionGraphPaletteUtils} from './composition-graph-palette-utils';
import {CompositionGraphZoneUtils} from './composition-graph-zone-utils';
import {ServicePathGraphUtils} from './composition-graph-service-path-utils';
diff --git a/catalog-ui/src/app/ng2/pages/composition/graph/utils/match-capability-requierment-utils.spec.ts b/catalog-ui/src/app/ng2/pages/composition/graph/utils/match-capability-requirement-utils.spec.ts
index dbfc3e7219..10b26fc939 100644
--- a/catalog-ui/src/app/ng2/pages/composition/graph/utils/match-capability-requierment-utils.spec.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/graph/utils/match-capability-requirement-utils.spec.ts
@@ -1,12 +1,17 @@
-import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { TestBed } from '@angular/core/testing';
import { Mock } from 'ts-mockery';
import {
CapabilitiesGroup,
- Capability, ComponentInstance, CompositionCiLinkBase, CompositionCiNodeBase, CompositionCiNodeCp,
- CompositionCiNodeVf, CompositionCiNodeVl,
- Requirement, RequirementsGroup
+ Capability,
+ ComponentInstance,
+ CompositionCiLinkBase,
+ CompositionCiNodeCp,
+ CompositionCiNodeVf,
+ CompositionCiNodeVl,
+ Requirement,
+ RequirementsGroup
} from '../../../../../models';
-import { MatchCapabilitiesRequirementsUtils } from './match-capability-requierment-utils';
+import { MatchCapabilitiesRequirementsUtils } from './match-capability-requirement-utils';
describe('match capability requirements utils service ', () => {
@@ -38,47 +43,25 @@ describe('match capability requirements utils service ', () => {
ownerName : 's'
});
- const vlAttachmentReq = Mock.of<Requirement>({
- capability: 'tosca.capabilities.Attachment',
- name: 'local_storage',
- relationship: 'tosca.relationships.AttachesTo',
- uniqueId: 'eef99154-8039-4227-ba68-62a32e6b0d98.local_storage',
- node: 'tosca.nodes.BlockStorage',
- ownerId : '',
- ownerName : 's'
- });
-
- const extVirtualLinkReq = Mock.of<Requirement>({
- capability: 'tosca.capabilities.network.Linkable',
- name: 'external_virtualLink',
- relationship: 'tosca.relationships.network.LinksTo',
- uniqueId: 'eef99154-8039-4227-ba68-62a32e6b0d98.external_virtualLink'
- });
-
const dependencyReq = Mock.of<Requirement>({
capability: 'tosca.capabilities.Node',
name: 'dependency',
+ node: 'tosca.nodes.Root',
relationship: 'tosca.relationships.DependsOn',
- uniqueId: 'eef99154-8039-4227-ba68-62a32e6b0d98.dependency'
+ uniqueId: 'eef99154-8039-4227-ba68-62a32e6b0d98.dependency',
+ minOccurrences: 0,
+ maxOccurrences: 'UNBOUNDED'
});
const featureCap = Mock.of<Capability>({
type: 'tosca.capabilities.Node',
name: 'feature',
+ capabilitySources: ['tosca.nodes.Root'],
uniqueId: 'capability.ddf1301e-866b-4fa3-bc4f-edbd81e532cd.feature',
maxOccurrences: 'UNBOUNDED',
minOccurrences: '1'
});
- const internalConnPointCap = Mock.of<Capability>({
- type: 'tosca.capabilities.Node',
- name: 'internal_connectionPoint',
- capabilitySources : ['org.openecomp.resource.cp.extCP'],
- uniqueId: 'capability.ddf1301e-866b-4fa3-bc4f-edbd81e532cd.internal_connectionPoint',
- maxOccurrences: 'UNBOUNDED',
- minOccurrences: '1'
- });
-
const blockStoreAttachmentCap = Mock.of<Capability>({
type: 'tosca.capabilities.Attachment',
name: 'attachment',
@@ -111,12 +94,10 @@ describe('match capability requirements utils service ', () => {
componentName: 'Compute',
uniqueId : 'compute0',
requirements: Mock.of<RequirementsGroup>({
- 'tosca.capabilities.Node' : [ dependencyReq ],
'tosca.capabilities.Attachment' : [ storeAttachmentReq ]
}),
capabilities: Mock.of<CapabilitiesGroup>({
'tosca.capabilities.network.Bindable' : [ bindingCap ],
- 'tosca.capabilities.Node' : [ featureCap ]
})
})
});
@@ -126,12 +107,8 @@ describe('match capability requirements utils service ', () => {
componentInstance: Mock.of<ComponentInstance>({
componentName: 'BlockStorage',
uniqueId : 'blockstorage0',
- requirements: Mock.of<RequirementsGroup>({
- 'tosca.capabilities.Node' : [ dependencyReq ]
- }),
capabilities: Mock.of<CapabilitiesGroup>({
'tosca.capabilities.Attachment' : [ blockStoreAttachmentCap ],
- 'tosca.capabilities.Node' : [ featureCap ]
})
})
});
@@ -141,12 +118,8 @@ describe('match capability requirements utils service ', () => {
componentInstance: Mock.of<ComponentInstance>({
componentName: 'BlockStorage',
uniqueId : 'extvl0',
- requirements: Mock.of<RequirementsGroup>({
- 'tosca.capabilities.Node' : [ dependencyReq ]
- }),
capabilities: Mock.of<CapabilitiesGroup>({
'tosca.capabilities.network.Linkable' : [ linkableCap ],
- 'tosca.capabilities.Node' : [ featureCap ]
})
})
});
@@ -160,9 +133,6 @@ describe('match capability requirements utils service ', () => {
'tosca.capabilities.network.Linkable' : [ virtualLinkReq ],
'tosca.capabilities.network.Bindable' : [ bindableReq ]
}),
- capabilities: Mock.of<CapabilitiesGroup>({
- 'tosca.capabilities.Node' : [ featureCap ]
- })
})
});
@@ -274,6 +244,39 @@ describe('match capability requirements utils service ', () => {
jest.spyOn(service, 'isMatch').mockReturnValue(true);
expect(service.getMatches({}, capabilities, [], fromId, toId, true)).toHaveLength(4);
});
+
+ it('node have 3 unfulfilled requirements: DependsOn tosca.nodes.Root, BindsTo and LinksTo;' +
+ ' and DependsOn and BindsTo matching capabilities, ' +
+ 'should return 2 matches', () => {
+ const dependencyList = [dependencyReq, bindableReq, virtualLinkReq];
+ jest.spyOn(service, 'getUnfulfilledRequirements').mockReturnValue(dependencyList);
+ const capabilities = {
+ cap1Match: featureCap, cap2NotMatch: Mock.of<Capability>(), cap3Match: bindingCap
+ };
+ const expectedMatchDependsOn = {
+ requirement: dependencyReq,
+ capability: featureCap,
+ isFromTo: true,
+ fromNode: fromId,
+ toNode: toId
+ };
+ const expectedMatchBindsTo = {
+ requirement: bindableReq,
+ capability: bindingCap,
+ isFromTo: true,
+ fromNode: fromId,
+ toNode: toId
+ };
+ const matches = service.getMatches({}, capabilities, [], fromId, toId, true);
+ expect(matches).toHaveLength(2);
+ expect(matches).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining(expectedMatchDependsOn),
+ expect.objectContaining(expectedMatchBindsTo)
+ ])
+ );
+
+ });
});
describe('Find matching nodes ===>', () => {
diff --git a/catalog-ui/src/app/ng2/pages/composition/graph/utils/match-capability-requierment-utils.ts b/catalog-ui/src/app/ng2/pages/composition/graph/utils/match-capability-requirement-utils.ts
index c3a1286a97..ec7f8d1ab6 100644
--- a/catalog-ui/src/app/ng2/pages/composition/graph/utils/match-capability-requierment-utils.ts
+++ b/catalog-ui/src/app/ng2/pages/composition/graph/utils/match-capability-requirement-utils.ts
@@ -113,13 +113,12 @@ export class MatchCapabilitiesRequirementsUtils {
public getUnfulfilledRequirements = (fromNodeId: string, requirements: RequirementsGroup, links: CompositionCiLinkBase[]): Requirement[] => {
const requirementArray: Requirement[] = [];
_.forEach(_.flatten(_.values(requirements)), (requirement: Requirement) => {
- const reqFulfilled = this.isRequirementFulfilled(fromNodeId, requirement, links);
- if (requirement.name !== 'dependency' && requirement.parentName !== 'dependency' && !reqFulfilled) {
+ if (!this.isRequirementFulfilled(fromNodeId, requirement, links)) {
requirementArray.push(requirement);
}
});
return requirementArray;
- }
+ };
/**
* Returns true if there is a match between the capabilities and requirements that are passed in