1 package org.openecomp.sdc.be.components.merge.instance;
4 import org.junit.Before;
6 import org.junit.runner.RunWith;
7 import org.mockito.ArgumentCaptor;
8 import org.mockito.Captor;
9 import org.mockito.Mock;
10 import org.mockito.Mockito;
11 import org.mockito.junit.MockitoJUnitRunner;
12 import org.openecomp.sdc.be.components.impl.utils.ExceptionUtils;
13 import org.openecomp.sdc.be.components.merge.utils.MergeInstanceUtils;
14 import org.openecomp.sdc.be.components.utils.GroupDefinitionBuilder;
15 import org.openecomp.sdc.be.components.utils.ResourceBuilder;
16 import org.openecomp.sdc.be.dao.api.ActionStatus;
17 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
18 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
19 import org.openecomp.sdc.be.impl.ComponentsUtils;
20 import org.openecomp.sdc.be.model.*;
21 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
22 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
23 import org.openecomp.sdc.exception.ResponseFormat;
26 import java.util.stream.IntStream;
28 import static org.assertj.core.api.Assertions.assertThat;
29 import static org.assertj.core.api.Assertions.tuple;
30 import static org.junit.Assert.*;
31 import static org.mockito.Mockito.verify;
32 import static org.mockito.Mockito.when;
34 @RunWith(MockitoJUnitRunner.class)
35 public class ComponentInstanceRelationMergeTest {
36 private ComponentInstanceRelationMerge compInstanceRelationMerge;
38 private DataForMergeHolder dataHolder;
39 private Component containerComponent;
40 private Component updatedContainerComponent;
41 private ComponentInstance currentResourceInstance;
43 private RequirementCapabilityRelDef requirementDef1;
44 private RequirementCapabilityRelDef requirementDef2;
45 private RequirementCapabilityRelDef capabilityDef1;
46 private RequirementCapabilityRelDef capabilityDef2;
47 private RequirementCapabilityRelDef capabilityDef3;
50 private ComponentsUtils componentsUtils;
53 private ToscaOperationFacade toscaOperationFacade;
59 private ExceptionUtils exceptionUtils;
62 private ArgumentCaptor<ContainerRelationsMergeInfo> argumentCaptor;
66 public void startUp() {
67 MergeInstanceUtils mergeInstanceUtils = new MergeInstanceUtils(toscaOperationFacade, exceptionUtils);
68 compInstanceRelationMerge = new ComponentInstanceRelationMerge(componentsUtils, mergeInstanceUtils, toscaOperationFacade);
70 containerComponent = new Service();
71 List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
73 requirementDef1 = createRequirementDef("SRV1.VF1.VFI_1", "SRV1.VF2.VFI_1", "SRV1.VF1.VFC_1.VFCI_1", "Requirement1");
74 resourceInstancesRelations.add(requirementDef1);
75 requirementDef2 = createRequirementDef("SRV1.VF1.VFI_1", "SRV1.VF3.VFI_1", "SRV1.VF1.VFC_2.VFCI_2", "Requirement2");
76 resourceInstancesRelations.add(requirementDef2);
79 capabilityDef1 = createCapabilityDef("SRV1.VF4.VFI_1", "SRV1.VF1.VFI_1", "SRV1.VF1.VFC_3.VFCI_3", "Capability3");
80 resourceInstancesRelations.add(capabilityDef1);
81 capabilityDef2 = createCapabilityDef("SRV1.VF5.VFI_1", "SRV1.VF1.VFI_1", "SRV1.VF1.VFC_4.VFCI_1", "Capability4");
82 resourceInstancesRelations.add(capabilityDef2);
85 capabilityDef3 = createCapabilityDef("SRV1.VF5.VFI_1", "SRV1.VF1.VFI_1", "grp1Id", "Capability5");
86 resourceInstancesRelations.add(capabilityDef3);
88 containerComponent.setComponentInstancesRelations(resourceInstancesRelations );
90 currentResourceInstance = new ComponentInstance();
91 currentResourceInstance.setUniqueId("SRV1.VF1.VFI_1");
92 currentResourceInstance.setComponentUid("SRV1.VF1");
93 currentResourceInstance.setIsProxy(false);
95 updatedContainerComponent = new Service();
96 updatedContainerComponent.setUniqueId("123123123123123123");
100 public void testSaveDataBeforeMerge() {
101 Resource vf = new ResourceBuilder()
102 .setResourceType(ResourceTypeEnum.VF)
103 .setComponentType(ComponentTypeEnum.RESOURCE)
104 .addComponentInstance(createVfci("vfc_A", "SRV1.VF1.VFC_1.VFCI_1", "SRV1.VF1.VFC_1", true))
105 .addComponentInstance(createVfci("vfc_B", "SRV1.VF1.VFC_2.VFCI_2", "SRV1.VF1.VFC_2", true))
106 .addComponentInstance(createVfci("vfc_C", "SRV1.VF1.VFC_3.VFCI_3", "SRV1.VF1.VFC_3", false))
107 .addComponentInstance(createVfci("vfc_D", "SRV1.VF1.VFC_4.VFCI_1", "SRV1.VF1.VFC_4", true))
108 .addGroup(createGroup("grp1", "grp1Id"))
111 compInstanceRelationMerge.saveDataBeforeMerge(dataHolder, containerComponent, currentResourceInstance, vf);
113 verify(dataHolder).setVfRelationsInfo(argumentCaptor.capture());
114 ContainerRelationsMergeInfo relationsMergeInfo = argumentCaptor.getValue();
115 List<RelationMergeInfo> fromRelationsMergeInfo = relationsMergeInfo.getFromRelationsInfo();
116 List<RelationMergeInfo> toRelationsMergeInfo = relationsMergeInfo.getToRelationsInfo();
118 assertNotNull("Expected not null list of relations merge info", fromRelationsMergeInfo);
119 assertNotNull("Expected not null list of relations merge info", toRelationsMergeInfo);
121 assertEquals("Expected 2 elements", 2, fromRelationsMergeInfo.size());
122 assertEquals("Expected 2 elements", 2, toRelationsMergeInfo.size());
126 public void testSaveDataBeforeMerge_RelationsNull() {
127 Resource vf = new Resource();
129 List<ComponentInstance> vfcInstances = new ArrayList<>();
130 vfcInstances.add(createVfci("vfc_A", "SRV1.VF1.VFC_1.VFCI_1", "SRV1.VF1.VFC_1", true));
131 vfcInstances.add(createVfci("vfc_B", "SRV1.VF1.VFC_2.VFCI_2", "SRV1.VF1.VFC_2", true));
132 vfcInstances.add(createVfci("vfc_C", "SRV1.VF1.VFC_3.VFCI_3", "SRV1.VF1.VFC_3", false));
133 vfcInstances.add(createVfci("vfc_D", "SRV1.VF1.VFC_4.VFCI_1", "SRV1.VF1.VFC_4", true));
134 vf.setComponentInstances(vfcInstances);
135 vf.setComponentType(ComponentTypeEnum.RESOURCE);
136 vf.setResourceType(ResourceTypeEnum.VF);
138 containerComponent.setComponentInstancesRelations(null);
139 compInstanceRelationMerge.saveDataBeforeMerge(dataHolder, containerComponent, currentResourceInstance, vf);
141 verify(dataHolder, Mockito.never()).setVfRelationsInfo(Mockito.any());
145 public void testSaveDataBeforeMerge_RelationsEmptyList() {
146 Resource vf = new Resource();
148 List<ComponentInstance> vfcInstances = new ArrayList<>();
149 vfcInstances.add(createVfci("vfc_A", "SRV1.VF1.VFC_1.VFCI_1", "SRV1.VF1.VFC_1", true));
150 vfcInstances.add(createVfci("vfc_B", "SRV1.VF1.VFC_2.VFCI_2", "SRV1.VF1.VFC_2", true));
151 vfcInstances.add(createVfci("vfc_C", "SRV1.VF1.VFC_3.VFCI_3", "SRV1.VF1.VFC_3", false));
152 vfcInstances.add(createVfci("vfc_D", "SRV1.VF1.VFC_4.VFCI_1", "SRV1.VF1.VFC_4", true));
153 vf.setComponentInstances(vfcInstances);
154 vf.setComponentType(ComponentTypeEnum.RESOURCE);
155 vf.setResourceType(ResourceTypeEnum.VF);
157 containerComponent.setComponentInstancesRelations(Collections.emptyList());
158 compInstanceRelationMerge.saveDataBeforeMerge(dataHolder, containerComponent, currentResourceInstance, vf);
160 verify(dataHolder, Mockito.never()).setVfRelationsInfo(Mockito.any());
164 public void testMergeDataAfterCreate_NoSavedData() {
165 when(dataHolder.getContainerRelationsMergeInfo()).thenReturn(null);
166 compInstanceRelationMerge.mergeDataAfterCreate(user, dataHolder, updatedContainerComponent, "SRV1.VF1.VFI_2");
167 List<RequirementCapabilityRelDef> relations = updatedContainerComponent.getComponentInstancesRelations();
168 assertNull("Expected no relations", relations);
172 public void testMergeDataAfterCreate() {
173 Resource newInstanceOriginVf = new ResourceBuilder()
174 .setResourceType(ResourceTypeEnum.VF)
175 .setComponentType(ComponentTypeEnum.RESOURCE)
176 .addComponentInstance(createVfci("vfc_A", "SRV1.VF1.VFC_1.VFCI_1", "SRV1.VF1.VFC_1", true))
177 .addComponentInstance(createVfci("vfc_B", "SRV1.VF1.VFC_2.VFCI_2", "SRV1.VF1.VFC_2", true))
178 .addComponentInstance(createVfci("vfc_C", "SRV1.VF1.VFC_3.VFCI_3", "SRV1.VF1.VFC_3", false))
179 .addComponentInstance(createVfci("vfc_D", "SRV1.VF1.VFC_4.VFCI_1", "SRV1.VF1.VFC_4", true))
180 .addGroup(createGroup("grp1", "grp1Id"))
184 List<ComponentInstance> componentInstances = new ArrayList<>();
185 componentInstances.add(createVfi("SRV1.VF1", "SRV1.VF1.VFI_2"));
186 updatedContainerComponent.setComponentInstances(componentInstances);
188 List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
189 updatedContainerComponent.setComponentInstancesRelations(resourceInstancesRelations);
191 List<RelationMergeInfo> fromRelationsMergeInfo = new ArrayList<>();
192 List<RelationMergeInfo> toRelationsMergeInfo = new ArrayList<>();
194 RelationMergeInfo relationMergeInfo1 = new RelationMergeInfo("CapabilityType1", "capabilityA", "vfc_A", requirementDef1);
195 fromRelationsMergeInfo.add(relationMergeInfo1);
196 RelationMergeInfo relationMergeInfo2 = new RelationMergeInfo("CapabilityType4", "capabilityD", "vfc_D", capabilityDef2);
197 toRelationsMergeInfo.add(relationMergeInfo2);
199 RelationMergeInfo relationMergeInfo3 = new RelationMergeInfo("CapabilityType5", "capabilityE", "grp1", capabilityDef3);
200 toRelationsMergeInfo.add(relationMergeInfo3);
202 ContainerRelationsMergeInfo relationsMergeInfo = new ContainerRelationsMergeInfo(fromRelationsMergeInfo, toRelationsMergeInfo);
204 when(toscaOperationFacade.getToscaElement("SRV1.VF1")).thenReturn(Either.left(newInstanceOriginVf));
205 when(dataHolder.getContainerRelationsMergeInfo()).thenReturn(relationsMergeInfo);
206 when(toscaOperationFacade.associateResourceInstances(Mockito.anyString(), Mockito.anyList())).thenReturn(StorageOperationStatus.OK);
207 Either<Component, ResponseFormat> mergeResult = compInstanceRelationMerge.mergeDataAfterCreate(user, dataHolder, updatedContainerComponent, "SRV1.VF1.VFI_2");
208 assertTrue(mergeResult.isLeft());
209 List<RequirementCapabilityRelDef> relations = updatedContainerComponent.getComponentInstancesRelations();
210 assertThat(relations)
211 .containsExactlyInAnyOrder(requirementDef1, capabilityDef2, capabilityDef3)
212 .extracting(relation -> relation.resolveSingleRelationship().getRelation().getCapabilityOwnerId(),
213 relation -> relation.resolveSingleRelationship().getRelation().getRequirementOwnerId())
214 .containsExactlyInAnyOrder(tuple("SRV1.VF1.VFC_4.VFCI_1", null),
215 tuple("grp1Id", null),
216 tuple(null, "SRV1.VF1.VFC_1.VFCI_1"));
221 public void testMergeDataAfterCreate_FailedToAssociateResourceInstances() {
222 Resource vf = new Resource();
224 List<ComponentInstance> vfcInstances = new ArrayList<>();
225 vfcInstances.add(createVfci("vfc_A", "SRV1.VF1.VFC_1.VFCI_1", "SRV1.VF1.VFC_1", true));
226 vfcInstances.add(createVfci("vfc_B", "SRV1.VF1.VFC_2.VFCI_2", "SRV1.VF1.VFC_2", true));
227 vfcInstances.add(createVfci("vfc_C", "SRV1.VF1.VFC_3.VFCI_3", "SRV1.VF1.VFC_3", false));
228 vfcInstances.add(createVfci("vfc_D", "SRV1.VF1.VFC_4.VFCI_1", "SRV1.VF1.VFC_4", true));
229 vf.setComponentInstances(vfcInstances);
230 vf.setComponentType(ComponentTypeEnum.RESOURCE);
231 vf.setResourceType(ResourceTypeEnum.VF);
233 Either<Component, StorageOperationStatus> eitherVF = Either.left(vf);
234 when(toscaOperationFacade.getToscaElement("SRV1.VF1")).thenReturn(eitherVF);
237 List<RelationMergeInfo> fromRelationsMergeInfo = new ArrayList<>();
238 List<RelationMergeInfo> toRelationsMergeInfo = new ArrayList<>();
240 RelationMergeInfo relationMergeInfo1 = new RelationMergeInfo("CapabilityType1", "capabilityA", "vfc_A", requirementDef1);
241 fromRelationsMergeInfo.add(relationMergeInfo1);
242 RelationMergeInfo relationMergeInfo2 = new RelationMergeInfo("CapabilityType4", "capabilityD", "vfc_D", capabilityDef2);
243 toRelationsMergeInfo.add(relationMergeInfo2);
245 ContainerRelationsMergeInfo relationsMergeInfo = new ContainerRelationsMergeInfo(fromRelationsMergeInfo, toRelationsMergeInfo);
247 when(dataHolder.getContainerRelationsMergeInfo()).thenReturn(relationsMergeInfo);
249 List<ComponentInstance> componentInstances = new ArrayList<>();
250 componentInstances.add(createVfi("SRV1.VF1", "SRV1.VF1.VFI_2"));
251 componentInstances.add(createVfi("SRV1.VF2", "SRV1.VF2.VFI_1"));
252 componentInstances.add(createVfi("SRV1.VF3", "SRV1.VF3.VFI_1"));
253 componentInstances.add(createVfi("SRV1.VF4", "SRV1.VF4.VFI_1"));
254 componentInstances.add(createVfi("SRV1.VF5", "SRV1.VF5.VFI_1"));
255 updatedContainerComponent.setComponentInstances(componentInstances);
257 List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
258 updatedContainerComponent.setComponentInstancesRelations(resourceInstancesRelations);
260 when(toscaOperationFacade.associateResourceInstances(Mockito.anyString(), Mockito.anyList())).thenReturn(StorageOperationStatus.GENERAL_ERROR);
261 when(componentsUtils.convertFromStorageResponse(Mockito.any())).thenReturn(ActionStatus.GENERAL_ERROR);
263 ResponseFormat expectedRresponseFormat = new ResponseFormat();
264 when(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR, updatedContainerComponent.getUniqueId())).thenReturn(expectedRresponseFormat );
266 Either<Component, ResponseFormat> result = compInstanceRelationMerge.mergeDataAfterCreate(user, dataHolder, updatedContainerComponent, "SRV1.VF1.VFI_2");
267 assertTrue(result.isRight());
268 assertEquals(expectedRresponseFormat, result.right().value());
272 public void testMergeDataAfterCreate_UpdatedContainerEmpty() {
273 List<RelationMergeInfo> fromRelationsMergeInfo = new ArrayList<>();
274 List<RelationMergeInfo> toRelationsMergeInfo = new ArrayList<>();
276 RelationMergeInfo relationMergeInfo1 = new RelationMergeInfo("CapabilityType1", "capabilityA", "vfc_A", requirementDef1);
277 fromRelationsMergeInfo.add(relationMergeInfo1);
278 RelationMergeInfo relationMergeInfo2 = new RelationMergeInfo("CapabilityType4", "capabilityD", "vfc_D", capabilityDef2);
279 toRelationsMergeInfo.add(relationMergeInfo2);
281 ContainerRelationsMergeInfo relationsMergeInfo = new ContainerRelationsMergeInfo(fromRelationsMergeInfo, toRelationsMergeInfo);
283 when(dataHolder.getContainerRelationsMergeInfo()).thenReturn(relationsMergeInfo);
285 Either<Component, ResponseFormat> result = compInstanceRelationMerge.mergeDataAfterCreate(user, dataHolder, updatedContainerComponent, "SRV1.VF1.VFI_2");
286 assertTrue(result.isLeft());
287 assertEquals(updatedContainerComponent, result.left().value());
291 public void testMergeDataAfterCreate_OwnerChanged() {
292 Resource vf = new Resource();
294 List<ComponentInstance> vfcInstances = new ArrayList<>();
295 vfcInstances.add(createVfci("vfc_A", "SRV1.VF1.VFC_1.VFCI_2", "SRV1.VF1.VFC_1", true));
296 vfcInstances.add(createVfci("vfc_B", "SRV1.VF1.VFC_2.VFCI_2", "SRV1.VF1.VFC_2", true));
297 vfcInstances.add(createVfci("vfc_C", "SRV1.VF1.VFC_3.VFCI_3", "SRV1.VF1.VFC_3", false));
298 vfcInstances.add(createVfci("vfc_D", "SRV1.VF1.VFC_4.VFCI_2", "SRV1.VF1.VFC_4", true));
299 vf.setComponentInstances(vfcInstances);
300 vf.setComponentType(ComponentTypeEnum.RESOURCE);
301 vf.setResourceType(ResourceTypeEnum.VF);
303 Either<Component, StorageOperationStatus> eitherVF = Either.left(vf);
304 when(toscaOperationFacade.getToscaElement("SRV1.VF1")).thenReturn(eitherVF);
307 List<RelationMergeInfo> fromRelationsMergeInfo = new ArrayList<>();
308 List<RelationMergeInfo> toRelationsMergeInfo = new ArrayList<>();
310 RelationMergeInfo relationMergeInfo1 = new RelationMergeInfo("CapabilityType1", "capabilityA", "vfc_A", requirementDef1);
311 fromRelationsMergeInfo.add(relationMergeInfo1);
312 RelationMergeInfo relationMergeInfo2 = new RelationMergeInfo("CapabilityType4", "capabilityD", "vfc_D", capabilityDef2);
313 toRelationsMergeInfo.add(relationMergeInfo2);
315 ContainerRelationsMergeInfo relationsMergeInfo = new ContainerRelationsMergeInfo(fromRelationsMergeInfo, toRelationsMergeInfo);
317 when(dataHolder.getContainerRelationsMergeInfo()).thenReturn(relationsMergeInfo);
319 List<ComponentInstance> componentInstances = new ArrayList<>();
320 componentInstances.add(createVfi("SRV1.VF1", "SRV1.VF1.VFI_2"));
321 componentInstances.add(createVfi("SRV1.VF2", "SRV1.VF2.VFI_1"));
322 componentInstances.add(createVfi("SRV1.VF3", "SRV1.VF3.VFI_1"));
323 componentInstances.add(createVfi("SRV1.VF4", "SRV1.VF4.VFI_1"));
324 componentInstances.add(createVfi("SRV1.VF5", "SRV1.VF5.VFI_1"));
325 updatedContainerComponent.setComponentInstances(componentInstances);
327 List<RequirementCapabilityRelDef> resourceInstancesRelations = new ArrayList<>();
328 updatedContainerComponent.setComponentInstancesRelations(resourceInstancesRelations);
330 when(toscaOperationFacade.associateResourceInstances(Mockito.anyString(), Mockito.anyList())).thenReturn(StorageOperationStatus.OK);
332 compInstanceRelationMerge.mergeDataAfterCreate(user, dataHolder, updatedContainerComponent, "SRV1.VF1.VFI_2");
334 verify(dataHolder).getContainerRelationsMergeInfo();
335 verify(toscaOperationFacade).associateResourceInstances(Mockito.anyString(), Mockito.anyList());
337 List<RequirementCapabilityRelDef> relations = updatedContainerComponent.getComponentInstancesRelations();
338 assertEquals("Expected 2 relations", 2, relations.size());
341 RequirementCapabilityRelDef capabilityRelDef = relations.get(0);
342 assertEquals("SRV1.VF1.VFC_4.VFCI_2", capabilityRelDef.resolveSingleRelationship().getRelation().getCapabilityOwnerId());
343 assertEquals("SRV1.VF5.VFI_1", capabilityRelDef.getFromNode());
344 assertEquals("SRV1.VF1.VFI_2", capabilityRelDef.getToNode());
346 RequirementCapabilityRelDef requirementRelDef = relations.get(1);
347 assertEquals("SRV1.VF1.VFC_1.VFCI_2", requirementRelDef.resolveSingleRelationship().getRelation().getRequirementOwnerId());
348 assertEquals("SRV1.VF1.VFI_2", requirementRelDef.getFromNode());
349 assertEquals("SRV1.VF2.VFI_1", requirementRelDef.getToNode());
358 private ComponentInstance createVfi(String vfId, String vfiUniqueId) {
359 ComponentInstance vfi = new ComponentInstance();
360 vfi.setUniqueId(vfiUniqueId);
361 vfi.setComponentUid(vfId);
363 Resource vf = new Resource();
364 vf.setUniqueId(vfId);
368 private ComponentInstance createVfci(String name, String uniqueId, String componentUid, boolean foundVfc) {
369 ComponentInstance compInst = new ComponentInstance();
370 compInst.setName(name);
371 compInst.setUniqueId(uniqueId);
372 compInst.setComponentUid(componentUid);
375 createVfc(componentUid);
378 failLoadVfc(componentUid);
383 public GroupDefinition createGroup(String name, String id) {
384 return GroupDefinitionBuilder.create()
386 .setInvariantName(name)
391 private void failLoadVfc(String uid) {
392 Either<Component, StorageOperationStatus> eitherVFC = Either.right(StorageOperationStatus.NOT_FOUND);
393 when(toscaOperationFacade.getToscaElement(uid)).thenReturn(eitherVFC);
396 private Component createVfc(String uid) {
397 Resource vfc = new Resource();
398 vfc.setComponentType(ComponentTypeEnum.RESOURCE);
399 vfc.setUniqueId(uid);
401 Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
402 Map<String, List<RequirementDefinition>> requirements = new HashMap<>();;
403 IntStream.range(0, 5).forEach(i -> {
405 List<CapabilityDefinition> capList = new LinkedList<>();
407 CapabilityDefinition capDef = new CapabilityDefinition();
408 capDef.setName("CapabilityName" + i);
409 capDef.setUniqueId("Capability" + i);
410 capDef.setType("CapabilityType" + i);
412 capabilities.put("Key" + i, capList);
414 List<RequirementDefinition> reqList = new LinkedList<>();
416 RequirementDefinition reqDef = new RequirementDefinition();
417 reqDef.setName("RequirementName" + i);
418 reqDef.setUniqueId("Requirement" + i);
419 reqDef.setCapability("CapabilityType" + i);
421 requirements.put("Key" + i, reqList);
424 vfc.setCapabilities(capabilities );
425 vfc.setRequirements(requirements);
427 Either<Component, StorageOperationStatus> eitherVFC = Either.left(vfc);
428 when(toscaOperationFacade.getToscaElement(uid)).thenReturn(eitherVFC);
433 private RequirementCapabilityRelDef createRequirementCapabilityDef(String fromNode, String toNode) {
434 RequirementCapabilityRelDef reqCapDef = new RequirementCapabilityRelDef();
436 reqCapDef.setFromNode(fromNode);
437 reqCapDef.setToNode(toNode);
439 List<CapabilityRequirementRelationship> relationships = new ArrayList<>();
440 CapabilityRequirementRelationship capabilityRequirementRelationship = new CapabilityRequirementRelationship();
441 relationships.add(capabilityRequirementRelationship);
442 reqCapDef.setRelationships(relationships);
447 private RequirementCapabilityRelDef createRequirementDef(String fromNode, String toNode, String ownerId, String requirementUid) {
448 RequirementCapabilityRelDef reqCapDef = createRequirementCapabilityDef(fromNode, toNode);
449 CapabilityRequirementRelationship capabilityRequirementRelationship = reqCapDef.resolveSingleRelationship();
451 RelationshipInfo relationshipInfo = new RelationshipInfo();
452 relationshipInfo.setRequirementOwnerId(ownerId);
453 relationshipInfo.setRequirementUid(requirementUid);
454 relationshipInfo.setRelationships(new RelationshipImpl());
455 capabilityRequirementRelationship.setRelation(relationshipInfo );
462 private RequirementCapabilityRelDef createCapabilityDef(String fromNode, String toNode, String ownerId, String capabilityUid) {
463 RequirementCapabilityRelDef reqCapDef = createRequirementCapabilityDef(fromNode, toNode);
464 CapabilityRequirementRelationship capabilityRequirementRelationship = reqCapDef.resolveSingleRelationship();
466 RelationshipInfo relationshipInfo = new RelationshipInfo();
467 relationshipInfo.setCapabilityOwnerId(ownerId);
468 relationshipInfo.setCapabilityUid(capabilityUid);
469 relationshipInfo.setRelationships(new RelationshipImpl());
470 capabilityRequirementRelationship.setRelation(relationshipInfo );