1 package org.openecomp.sdc.be.components.impl;
3 import static org.junit.Assert.assertTrue;
4 import static org.mockito.ArgumentMatchers.any;
5 import static org.mockito.ArgumentMatchers.anySet;
6 import static org.mockito.ArgumentMatchers.anyString;
7 import static org.mockito.ArgumentMatchers.eq;
8 import static org.mockito.Mockito.when;
10 import java.util.ArrayList;
11 import java.util.HashMap;
12 import java.util.HashSet;
13 import java.util.List;
16 import java.util.function.BiPredicate;
18 import org.apache.commons.lang3.tuple.ImmutablePair;
19 import org.apache.commons.lang3.tuple.Pair;
20 import org.assertj.core.util.Lists;
21 import org.junit.Assert;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.mockito.Mock;
25 import org.mockito.Mockito;
26 import org.mockito.MockitoAnnotations;
27 import org.openecomp.sdc.be.components.validation.UserValidations;
28 import org.openecomp.sdc.be.dao.api.ActionStatus;
29 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
30 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
31 import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
32 import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
33 import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition;
34 import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
35 import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
36 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
37 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
38 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
39 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
40 import org.openecomp.sdc.be.impl.ComponentsUtils;
41 import org.openecomp.sdc.be.impl.ServletUtils;
42 import org.openecomp.sdc.be.info.CreateAndAssotiateInfo;
43 import org.openecomp.sdc.be.model.CapabilityDefinition;
44 import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
45 import org.openecomp.sdc.be.model.Component;
46 import org.openecomp.sdc.be.model.ComponentInstance;
47 import org.openecomp.sdc.be.model.ComponentInstanceInput;
48 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
49 import org.openecomp.sdc.be.model.ComponentParametersView;
50 import org.openecomp.sdc.be.model.RelationshipImpl;
51 import org.openecomp.sdc.be.model.RelationshipInfo;
52 import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
53 import org.openecomp.sdc.be.model.RequirementDefinition;
54 import org.openecomp.sdc.be.model.Resource;
55 import org.openecomp.sdc.be.model.Service;
56 import org.openecomp.sdc.be.model.User;
57 import org.openecomp.sdc.be.model.jsontitan.operations.ForwardingPathOperation;
58 import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
59 import org.openecomp.sdc.be.model.operations.api.IComponentInstanceOperation;
60 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
61 import org.openecomp.sdc.be.model.operations.impl.ArtifactOperation;
62 import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
63 import org.openecomp.sdc.be.user.UserBusinessLogic;
64 import org.openecomp.sdc.exception.ResponseFormat;
65 import org.openecomp.sdc.common.datastructure.Wrapper;
67 import fj.data.Either;
68 import javassist.CodeConverter.ArrayAccessReplacementMethodNames;
69 import mockit.Deencapsulation;
74 * The test suite designed for test functionality of
75 * ComponentInstanceBusinessLogic class
77 public class ComponentInstanceBusinessLogicTest {
79 private final static String USER_ID = "jh0003";
80 private final static String COMPONENT_ID = "componentId";
81 private final static String TO_INSTANCE_ID = "toInstanceId";
82 private final static String FROM_INSTANCE_ID = "fromInstanceId";
83 private final static String RELATION_ID = "relationId";
84 private final static String CAPABILITY_OWNER_ID = "capabilityOwnerId";
85 private final static String CAPABILITY_UID = "capabilityUid";
86 private final static String CAPABILITY_NAME = "capabilityName";
87 private final static String REQUIREMENT_OWNER_ID = "requirementOwnerId";
88 private final static String REQUIREMENT_UID = "requirementUid";
89 private final static String REQUIREMENT_NAME = "requirementName";
90 private final static String RELATIONSHIP_TYPE = "relationshipType";
92 private static ComponentsUtils componentsUtils;
93 private static ServletUtils servletUtils;
94 private static ResponseFormat responseFormat;
95 private static ToscaOperationFacade toscaOperationFacade;
96 private static IComponentInstanceOperation componentInstanceOperation;
97 private static UserBusinessLogic userAdmin;
99 private static ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
100 private static ForwardingPathOperation forwardingPathOperation;
101 private static User user;
102 private static UserValidations userValidations;
103 private static Component service;
104 private static Component resource;
105 private static ComponentInstance toInstance;
106 private static ComponentInstance fromInstance;
107 private static CapabilityDataDefinition capability;
108 private static RequirementDataDefinition requirement;
109 private static RequirementCapabilityRelDef relation;
110 private static BaseBusinessLogic baseBusinessLogic;
111 private static ArtifactsBusinessLogic artifactsBusinessLogic;
112 private static ToscaDataDefinition toscaDataDefinition;
120 MockitoAnnotations.initMocks(this);
124 public void testGetRelationByIdSuccess() {
125 getServiceRelationByIdSuccess(service);
126 getServiceRelationByIdSuccess(resource);
130 public void testGetRelationByIdUserValidationFailure() {
131 getServiceRelationByIdUserValidationFailure(service);
132 getServiceRelationByIdUserValidationFailure(resource);
136 public void testGetRelationByIdComponentNotFoundFailure() {
137 getRelationByIdComponentNotFoundFailure(service);
138 getRelationByIdComponentNotFoundFailure(resource);
143 public void testForwardingPathOnVersionChange() {
144 getforwardingPathOnVersionChange();
147 private void getforwardingPathOnVersionChange() {
148 String containerComponentParam = "services";
149 String containerComponentID = "121-cont";
150 String componentInstanceID = "121-cont-1-comp";
151 Service component = new Service();
152 Map<String, ForwardingPathDataDefinition> forwardingPaths = generateForwardingPath(componentInstanceID);
154 // Add existing componentInstance to component
155 List<ComponentInstance> componentInstanceList = new ArrayList<>();
156 ComponentInstance oldComponentInstance = new ComponentInstance();
157 oldComponentInstance.setName("OLD_COMP_INSTANCE");
158 oldComponentInstance.setUniqueId(componentInstanceID);
159 oldComponentInstance.setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_UID, "1-comp");
160 componentInstanceList.add(oldComponentInstance);
161 component.setComponentInstances(componentInstanceList);
162 component.setForwardingPaths(forwardingPaths);
164 List<ComponentInstance> componentInstanceListNew = new ArrayList<>();
165 ComponentInstance newComponentInstance = new ComponentInstance();
166 String new_Comp_UID = "2-comp";
167 newComponentInstance.setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_UID, new_Comp_UID);
168 newComponentInstance.setUniqueId(new_Comp_UID);
169 componentInstanceListNew.add(newComponentInstance);
170 Component component2 = new Service();
171 component2.setComponentInstances(componentInstanceListNew);
173 // Mock for getting component
174 when(toscaOperationFacade.getToscaElement(eq(containerComponentID), any(ComponentParametersView.class)))
175 .thenReturn(Either.left(component));
176 when(toscaOperationFacade.validateComponentExists(any(String.class))).thenReturn(Either.left(Boolean.TRUE));
177 // Mock for getting component for componentInstance
178 when(toscaOperationFacade.getToscaFullElement(eq("1-comp"))).thenReturn(Either.left(component));
179 when(toscaOperationFacade.getToscaFullElement(eq(new_Comp_UID))).thenReturn(Either.left(component2));
181 Either<Set<String>, ResponseFormat> resultOp = componentInstanceBusinessLogic.forwardingPathOnVersionChange(
182 containerComponentParam, containerComponentID, componentInstanceID, newComponentInstance);
183 Assert.assertEquals(1, resultOp.left().value().size());
184 Assert.assertEquals("FP-ID-1", resultOp.left().value().iterator().next());
189 public void testDeleteForwardingPathsWhenComponentinstanceDeleted(){
191 ComponentTypeEnum containerComponentType = ComponentTypeEnum.findByParamName("services");
192 String containerComponentID = "Service-comp";
193 String componentInstanceID = "NodeA1";
194 Service component = new Service();
195 component.setComponentInstances(Arrays.asList(createComponentIstance("NodeA2"),createComponentIstance("NodeB2"),
196 createComponentIstance(componentInstanceID)));
198 component.addForwardingPath(createPath("path1", componentInstanceID, "NodeB1", "1"));
199 component.addForwardingPath(createPath("Path2", "NodeA2","NodeB2", "2"));
200 when(toscaOperationFacade.getToscaElement(eq(containerComponentID),any(ComponentParametersView.class))).thenReturn(Either.left(component));
201 when(toscaOperationFacade.getToscaElement(eq(containerComponentID))).thenReturn(Either.left(component));
202 when(forwardingPathOperation.deleteForwardingPath(any(Service.class), anySet())).thenReturn(Either.left(new HashSet<>()));
203 final ComponentInstance ci = new ComponentInstance();
204 ci.setName(componentInstanceID);
205 Either<ComponentInstance, ResponseFormat> responseFormatEither = componentInstanceBusinessLogic.deleteForwardingPathsRelatedTobeDeletedComponentInstance(
206 containerComponentID, containerComponentType, Either.left(ci));
207 Assert.assertTrue(responseFormatEither.isLeft());
211 private ComponentInstance createComponentIstance(String path1) {
212 ComponentInstance componentInstance = new ComponentInstance();
213 componentInstance.setName(path1);
214 return componentInstance;
218 public void testDeleteForwardingPathsWhenErrorInComponentinstanceDelete() {
220 ComponentTypeEnum containerComponentType = ComponentTypeEnum.findByParamName("services");
221 String containerComponentID = "Service-comp";
222 String componentInstanceID = "NodeA1";
223 Service component = new Service();
225 component.addForwardingPath(createPath("path1", "NodeA1", "NodeB1", "1"));
226 component.addForwardingPath(createPath("Path2", "NodeA2", "NodeB2", "2"));
227 when(toscaOperationFacade.getToscaElement(eq(containerComponentID), any(ComponentParametersView.class)))
228 .thenReturn(Either.left(component));
229 when(toscaOperationFacade.getToscaElement(eq(containerComponentID))).thenReturn(Either.left(component));
230 when(forwardingPathOperation.deleteForwardingPath(any(Service.class), anySet()))
231 .thenReturn(Either.left(new HashSet<>()));
232 Either<ComponentInstance, ResponseFormat> responseFormatEither = componentInstanceBusinessLogic
233 .deleteForwardingPathsRelatedTobeDeletedComponentInstance(containerComponentID,
234 containerComponentType, Either.right(new ResponseFormat()));
235 Assert.assertTrue(responseFormatEither.isRight());
239 private ForwardingPathDataDefinition createPath(String pathName, String fromNode, String toNode, String uniqueId) {
240 ForwardingPathDataDefinition forwardingPath = new ForwardingPathDataDefinition(pathName);
241 forwardingPath.setProtocol("protocol");
242 forwardingPath.setDestinationPortNumber("port");
243 forwardingPath.setUniqueId(uniqueId);
244 ListDataDefinition<ForwardingPathElementDataDefinition> forwardingPathElementListDataDefinition = new ListDataDefinition<>();
245 forwardingPathElementListDataDefinition.add(new ForwardingPathElementDataDefinition(fromNode, toNode,
246 "nodeAcpType", "nodeBcpType", "nodeDcpName", "nodeBcpName"));
247 forwardingPath.setPathElements(forwardingPathElementListDataDefinition);
249 return forwardingPath;
252 private Map<String, ForwardingPathDataDefinition> generateForwardingPath(String componentInstanceID) {
253 ForwardingPathDataDefinition forwardingPath = new ForwardingPathDataDefinition("fpName");
254 String protocol = "protocol";
255 forwardingPath.setProtocol(protocol);
256 forwardingPath.setDestinationPortNumber("DestinationPortNumber");
257 forwardingPath.setUniqueId("FP-ID-1");
258 ListDataDefinition<ForwardingPathElementDataDefinition> forwardingPathElementListDataDefinition = new ListDataDefinition<>();
259 forwardingPathElementListDataDefinition.add(new ForwardingPathElementDataDefinition(componentInstanceID,
260 "nodeB", "nodeA_FORWARDER_CAPABILITY", "nodeBcpType", "nodeDcpName", "nodeBcpName"));
261 forwardingPath.setPathElements(forwardingPathElementListDataDefinition);
262 Map<String, ForwardingPathDataDefinition> forwardingPaths = new HashMap<>();
263 forwardingPaths.put("1122", forwardingPath);
264 return forwardingPaths;
267 @SuppressWarnings("unchecked")
268 private void getServiceRelationByIdSuccess(Component component) {
269 Either<User, ActionStatus> eitherCreator = Either.left(user);
270 when(userAdmin.getUser(eq(USER_ID), eq(false))).thenReturn(eitherCreator);
271 Either<Component, StorageOperationStatus> getComponentRes = Either.left(component);
272 when(toscaOperationFacade.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
273 .thenReturn(getComponentRes);
275 Either<RequirementDataDefinition, StorageOperationStatus> getfulfilledRequirementRes = Either.left(requirement);
276 when(toscaOperationFacade.getFulfilledRequirementByRelation(eq(COMPONENT_ID), eq(FROM_INSTANCE_ID),
277 eq(relation), any(BiPredicate.class))).thenReturn(getfulfilledRequirementRes);
279 Either<CapabilityDataDefinition, StorageOperationStatus> getfulfilledCapabilityRes = Either.left(capability);
280 when(toscaOperationFacade.getFulfilledCapabilityByRelation(eq(COMPONENT_ID), eq(FROM_INSTANCE_ID), eq(relation),
281 any(BiPredicate.class))).thenReturn(getfulfilledCapabilityRes);
283 Either<RequirementCapabilityRelDef, ResponseFormat> response = componentInstanceBusinessLogic
284 .getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
285 assertTrue(response.isLeft());
288 private void getServiceRelationByIdUserValidationFailure(Component component) {
289 // Either<User, ActionStatus> eitherCreator =
290 // Either.right(ActionStatus.USER_NOT_FOUND);
291 // when(userAdmin.getUser(eq(USER_ID),
292 // eq(false))).thenReturn(eitherCreator);
293 when(userValidations.validateUserExists(eq(USER_ID), eq("get relation by Id"), eq(false)))
294 .thenReturn(Either.right(new ResponseFormat(404)));
295 Either<RequirementCapabilityRelDef, ResponseFormat> response = componentInstanceBusinessLogic
296 .getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
297 assertTrue(response.isRight());
300 private void getRelationByIdComponentNotFoundFailure(Component component) {
301 Either<User, ActionStatus> eitherCreator = Either.left(user);
302 when(userAdmin.getUser(eq(USER_ID), eq(false))).thenReturn(eitherCreator);
303 Either<Component, StorageOperationStatus> getComponentRes = Either.right(StorageOperationStatus.NOT_FOUND);
304 when(toscaOperationFacade.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
305 .thenReturn(getComponentRes);
307 Either<RequirementCapabilityRelDef, ResponseFormat> response = componentInstanceBusinessLogic
308 .getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
309 assertTrue(response.isRight());
312 private static void createMocks() {
313 componentsUtils = Mockito.mock(ComponentsUtils.class);
314 servletUtils = Mockito.mock(ServletUtils.class);
315 responseFormat = Mockito.mock(ResponseFormat.class);
316 toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
317 userAdmin = Mockito.mock(UserBusinessLogic.class);
318 user = Mockito.mock(User.class);
319 baseBusinessLogic = Mockito.mock(BaseBusinessLogic.class);
320 userValidations = Mockito.mock(UserValidations.class);
321 forwardingPathOperation = Mockito.mock(ForwardingPathOperation.class);
322 componentInstanceOperation = Mockito.mock(IComponentInstanceOperation.class);
323 artifactsBusinessLogic = Mockito.mock(ArtifactsBusinessLogic.class);
324 toscaDataDefinition = Mockito.mock(ToscaDataDefinition.class);
327 private static void setMocks() {
328 componentInstanceBusinessLogic = new ComponentInstanceBusinessLogic();
329 componentInstanceBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
330 componentInstanceBusinessLogic.setUserAdmin(userAdmin);
331 componentInstanceBusinessLogic.setComponentsUtils(componentsUtils);
332 componentInstanceBusinessLogic.setUserValidations(userValidations);
333 componentInstanceBusinessLogic.setForwardingPathOperation(forwardingPathOperation);
336 private static void stubMethods() {
337 when(servletUtils.getComponentsUtils()).thenReturn(componentsUtils);
338 when(userValidations.validateUserExists(eq(USER_ID), eq("get relation by Id"), eq(false)))
339 .thenReturn(Either.left(user));
340 when(componentsUtils.getResponseFormat(eq(ActionStatus.RELATION_NOT_FOUND), eq(RELATION_ID), eq(COMPONENT_ID)))
341 .thenReturn(responseFormat);
342 Either<User, ActionStatus> eitherGetUser = Either.left(user);
343 when(userAdmin.getUser("jh0003", false)).thenReturn(eitherGetUser);
344 when(userValidations.validateUserExists(eq(user.getUserId()), anyString(), eq(false)))
345 .thenReturn(Either.left(user));
348 private static void createComponents() {
355 private static Component createResource() {
356 resource = new Resource();
357 resource.setUniqueId(COMPONENT_ID);
358 resource.setComponentInstancesRelations(Lists.newArrayList(relation));
359 resource.setComponentInstances(Lists.newArrayList(toInstance, fromInstance));
360 resource.setCapabilities(toInstance.getCapabilities());
361 resource.setRequirements(fromInstance.getRequirements());
362 resource.setComponentType(ComponentTypeEnum.RESOURCE);
366 private static Component createService() {
367 service = new Service();
368 service.setUniqueId(COMPONENT_ID);
369 service.setComponentInstancesRelations(Lists.newArrayList(relation));
370 service.setComponentInstances(Lists.newArrayList(toInstance, fromInstance));
371 service.setCapabilities(toInstance.getCapabilities());
372 service.setRequirements(fromInstance.getRequirements());
373 service.setComponentType(ComponentTypeEnum.SERVICE);
377 private static ComponentInstance createInstances() {
378 toInstance = new ComponentInstance();
379 toInstance.setUniqueId(TO_INSTANCE_ID);
380 toInstance.setComponentUid("uuuiiid");
381 toInstance.setName("tests");
383 fromInstance = new ComponentInstance();
384 fromInstance.setUniqueId(FROM_INSTANCE_ID);
386 capability = new CapabilityDataDefinition();
387 capability.setOwnerId(CAPABILITY_OWNER_ID);
388 capability.setUniqueId(CAPABILITY_UID);
389 capability.setName(CAPABILITY_NAME);
391 Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
392 capabilities.put(capability.getName(), Lists.newArrayList(new CapabilityDefinition(capability)));
394 requirement = new RequirementDataDefinition();
395 requirement.setOwnerId(REQUIREMENT_OWNER_ID);
396 requirement.setUniqueId(REQUIREMENT_UID);
397 requirement.setName(REQUIREMENT_NAME);
398 requirement.setRelationship(RELATIONSHIP_TYPE);
400 Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
401 requirements.put(requirement.getCapability(), Lists.newArrayList(new RequirementDefinition(requirement)));
403 toInstance.setCapabilities(capabilities);
404 fromInstance.setRequirements(requirements);
408 private static void createRelation() {
410 relation = new RequirementCapabilityRelDef();
411 CapabilityRequirementRelationship relationship = new CapabilityRequirementRelationship();
412 RelationshipInfo relationInfo = new RelationshipInfo();
413 relationInfo.setId(RELATION_ID);
414 relationship.setRelation(relationInfo);
416 relation.setRelationships(Lists.newArrayList(relationship));
417 relation.setToNode(TO_INSTANCE_ID);
418 relation.setFromNode(FROM_INSTANCE_ID);
420 relationInfo.setCapabilityOwnerId(CAPABILITY_OWNER_ID);
421 relationInfo.setCapabilityUid(CAPABILITY_UID);
422 relationInfo.setCapability(CAPABILITY_NAME);
423 relationInfo.setRequirementOwnerId(REQUIREMENT_OWNER_ID);
424 relationInfo.setRequirementUid(REQUIREMENT_UID);
425 relationInfo.setRequirement(REQUIREMENT_NAME);
426 RelationshipImpl relationshipImpl = new RelationshipImpl();
427 relationshipImpl.setType(RELATIONSHIP_TYPE);
428 relationInfo.setRelationships(relationshipImpl);
431 ///////////////////////////////////////////////////////////////////////////////
432 /////////////////////////////new test//////////////////////////////////////////
433 ///////////////////////////////////////////////////////////////////////////////
436 private ComponentInstanceBusinessLogic createTestSubject() {
437 return componentInstanceBusinessLogic;
445 public void testChangeServiceProxyVersion() throws Exception {
446 ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
447 String containerComponentType = "";
448 String containerComponentId = "";
449 String serviceProxyId = "";
450 String userId = user.getUserId();
451 Either<ComponentInstance, ResponseFormat> result;
454 componentInstanceBusinessLogic = createTestSubject();
455 result = componentInstanceBusinessLogic.changeServiceProxyVersion(containerComponentType, containerComponentId, serviceProxyId,
466 public void testCreateServiceProxy() throws Exception {
467 ComponentInstanceBusinessLogic testSubject;
468 String containerComponentType = "";
469 String containerComponentId = "";
470 String userId = user.getUserId();
471 ComponentInstance componentInstance = createInstances();
472 Either<ComponentInstance, ResponseFormat> result;
475 testSubject = createTestSubject();
476 result = testSubject.createServiceProxy(containerComponentType, containerComponentId, userId,
485 public void testDeleteForwardingPathsRelatedTobeDeletedComponentInstance() throws Exception {
486 ComponentInstanceBusinessLogic testSubject;
487 String containerComponentId = "";
488 String componentInstanceId = "";
489 ComponentTypeEnum containerComponentType = ComponentTypeEnum.RESOURCE;
490 Either<ComponentInstance, ResponseFormat> resultOp = null;
491 Either<ComponentInstance, ResponseFormat> result;
494 testSubject = createTestSubject();
495 result = testSubject.deleteForwardingPathsRelatedTobeDeletedComponentInstance(containerComponentId,
496 containerComponentType, resultOp);
501 public void testDeleteServiceProxy() throws Exception {
502 ComponentInstanceBusinessLogic testSubject;
503 String containerComponentType = "";
504 String containerComponentId = "";
505 String serviceProxyId = "";
506 String userId = user.getUserId();
507 Either<ComponentInstance, ResponseFormat> result;
510 testSubject = createTestSubject();
511 result = testSubject.deleteServiceProxy(containerComponentType, containerComponentId, serviceProxyId, userId);
520 public void testGetComponentInstanceInputsByInputId() throws Exception {
521 ComponentInstanceBusinessLogic testSubject;
522 Component component = new Service();
524 List<ComponentInstanceInput> result;
527 testSubject = createTestSubject();
528 result = testSubject.getComponentInstanceInputsByInputId(component, inputId);
534 public void testGetComponentInstancePropertiesByInputId() throws Exception {
535 ComponentInstanceBusinessLogic testSubject;
536 Component component = new Service();
538 List<ComponentInstanceProperty> result;
541 testSubject = createTestSubject();
542 result = testSubject.getComponentInstancePropertiesByInputId(component, inputId);
547 public void testGetRelationById() throws Exception {
548 ComponentInstanceBusinessLogic testSubject;
549 String componentId = "";
550 String relationId = "";
551 String userId = user.getUserId();
552 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE_INSTANCE;
553 Either<RequirementCapabilityRelDef, ResponseFormat> result;
556 testSubject = createTestSubject();
557 result = testSubject.getRelationById(componentId, relationId, userId, componentTypeEnum);
565 public void testCreateComponentInstance_1() throws Exception {
566 ComponentInstanceBusinessLogic testSubject;String containerComponentParam = "";
567 String containerComponentId = "";
568 String userId = user.getUserId();
569 ComponentInstance resourceInstance = null;
570 boolean inTransaction = false;
571 boolean needLock = false;
572 Either<ComponentInstance,ResponseFormat> result;
575 testSubject=createTestSubject();result=testSubject.createComponentInstance(containerComponentParam, containerComponentId, userId, resourceInstance, inTransaction, needLock);
583 public void testCreateAndAssociateRIToRI() throws Exception {
584 ComponentInstanceBusinessLogic testSubject;
586 String containerComponentParam = "";
587 String containerComponentId = "";
588 String userId = user.getUserId();
589 CreateAndAssotiateInfo createAndAssotiateInfo = new CreateAndAssotiateInfo(null, null);
590 Either<CreateAndAssotiateInfo,ResponseFormat> result;
593 testSubject=createTestSubject();result=testSubject.createAndAssociateRIToRI(containerComponentParam, containerComponentId, userId, createAndAssotiateInfo);
597 public void testGetOriginComponentFromComponentInstance_1() throws Exception {
598 ComponentInstanceBusinessLogic testSubject;
599 Component compoent = createResource();
600 String componentInstanceName = "";
601 String origComponetId = compoent.getUniqueId();
602 Either<Component, StorageOperationStatus> oldResourceRes = Either.left(compoent);
603 when(toscaOperationFacade.getToscaFullElement(compoent.getUniqueId())).thenReturn(oldResourceRes);
604 Either<Component,ResponseFormat> result;
607 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getOriginComponentFromComponentInstance", new Object[]{componentInstanceName, origComponetId});
612 public void testCreateComponentInstanceOnGraph() throws Exception {
613 ComponentInstanceBusinessLogic testSubject;
614 Component containerComponent = createResource();
615 Component originComponent = null;
616 ComponentInstance componentInstance = createInstances();
617 Either<ComponentInstance,ResponseFormat> result;
619 Either<ImmutablePair<Component, String>, StorageOperationStatus> result2 = Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND);
620 when(toscaOperationFacade.addComponentInstanceToTopologyTemplate(containerComponent, containerComponent,componentInstance, false, user)).thenReturn(result2);
623 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createComponentInstanceOnGraph", new Object[]{containerComponent, containerComponent, componentInstance, user});
627 public void testCreateComponentInstanceOnGraph2() throws Exception {
628 ComponentInstanceBusinessLogic testSubject;
629 Component containerComponent = createResource();
630 containerComponent.setName("name");
631 ComponentInstance componentInstance = createInstances();
632 Either<ComponentInstance,ResponseFormat> result;
633 ImmutablePair<Component, String> pair = new ImmutablePair<>(containerComponent,"");
638 Either<ImmutablePair<Component, String>, StorageOperationStatus> result2 = Either.left(pair);
639 when(toscaOperationFacade.addComponentInstanceToTopologyTemplate(containerComponent, containerComponent,componentInstance, false, user)).thenReturn(result2);
642 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createComponentInstanceOnGraph", new Object[]{containerComponent, containerComponent, componentInstance, user});
646 public void testUpdateComponentInstanceMetadata() throws Exception {
647 ComponentInstanceBusinessLogic testSubject;
648 String containerComponentParam = "";
649 String containerComponentId = "";
650 String componentInstanceId = "";
651 String userId = user.getUserId();
652 ComponentInstance componentInstance = createInstances();
653 Either<ComponentInstance,ResponseFormat> result;
656 testSubject=createTestSubject();result=testSubject.updateComponentInstanceMetadata(containerComponentParam, containerComponentId, componentInstanceId, userId, componentInstance);
661 public void testUpdateComponentInstanceMetadata_1() throws Exception {
662 ComponentInstanceBusinessLogic testSubject;String containerComponentParam = "";
663 String containerComponentId = "";
664 String componentInstanceId = "";
665 String userId = user.getUserId();
666 ComponentInstance componentInstance = createInstances();
667 boolean inTransaction = false;
668 boolean needLock = false;
669 boolean createNewTransaction = false;
670 Either<ComponentInstance,ResponseFormat> result;
673 testSubject=createTestSubject();result=testSubject.updateComponentInstanceMetadata(containerComponentParam, containerComponentId, componentInstanceId, userId, componentInstance, inTransaction, needLock, createNewTransaction);
681 public void testValidateParent() throws Exception {
682 ComponentInstanceBusinessLogic testSubject;
683 Component containerComponent = createResource();
684 String nodeTemplateId = "";
688 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateParent", new Object[]{containerComponent, nodeTemplateId});
693 public void testGetComponentType() throws Exception {
694 ComponentInstanceBusinessLogic testSubject;
695 ComponentTypeEnum containerComponentType = ComponentTypeEnum.RESOURCE;
696 ComponentTypeEnum result;
699 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getComponentType", new Object[]{ComponentTypeEnum.class});
705 public void testGetNewGroupName() throws Exception {
706 ComponentInstanceBusinessLogic testSubject;String oldPrefix = "";
707 String newNormailzedPrefix = "";
708 String qualifiedGroupInstanceName = "";
712 testSubject=createTestSubject();
713 result=Deencapsulation.invoke(testSubject, "getNewGroupName", new Object[]{oldPrefix, newNormailzedPrefix, qualifiedGroupInstanceName});
718 public void testUpdateComponentInstanceMetadata_3() throws Exception {
719 ComponentInstanceBusinessLogic testSubject;
720 ComponentInstance oldComponentInstance = createInstances();
721 ComponentInstance newComponentInstance = null;
722 ComponentInstance result;
725 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "updateComponentInstanceMetadata", new Object[]{oldComponentInstance, oldComponentInstance});
730 public void testDeleteComponentInstance() throws Exception {
731 ComponentInstanceBusinessLogic testSubject;String containerComponentParam = "";
732 String containerComponentId = "";
733 String componentInstanceId = "";
734 String userId = user.getUserId();
735 Either<ComponentInstance,ResponseFormat> result;
738 testSubject=createTestSubject();result=testSubject.deleteComponentInstance(containerComponentParam, containerComponentId, componentInstanceId, userId);
743 public void testDeleteForwardingPaths() throws Exception {
744 ComponentInstanceBusinessLogic testSubject;
745 Component service = createService();
746 String serviceId = service.getUniqueId();
747 List<String> pathIdsToDelete = new ArrayList<>();
748 Either<Set<String>,ResponseFormat> result;
750 // Either<Service, StorageOperationStatus> storageStatus = toscaOperationFacade.getToscaElement(serviceId);
751 when(toscaOperationFacade.getToscaElement(serviceId)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
754 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "deleteForwardingPaths", new Object[]{serviceId, pathIdsToDelete});
759 public void testAssociateRIToRIOnGraph() throws Exception {
760 ComponentInstanceBusinessLogic testSubject;
761 Component containerComponent = createResource();
762 RequirementCapabilityRelDef requirementDef = new RequirementCapabilityRelDef();
763 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
764 boolean inTransaction = false;
765 Either<RequirementCapabilityRelDef,ResponseFormat> result;
769 Either<RequirementCapabilityRelDef, StorageOperationStatus> getResourceResult = Either.left(requirementDef);
770 when(toscaOperationFacade.associateResourceInstances(containerComponent.getUniqueId(), requirementDef)).thenReturn(getResourceResult);
773 testSubject=createTestSubject();result=testSubject.associateRIToRIOnGraph(containerComponent, requirementDef, componentTypeEnum, inTransaction);
779 public void testFindRelation() throws Exception {
780 ComponentInstanceBusinessLogic testSubject;
781 String relationId = "";
782 List<RequirementCapabilityRelDef> requirementCapabilityRelations = new ArrayList<>();
783 RequirementCapabilityRelDef result;
786 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "findRelation", new Object[]{relationId, requirementCapabilityRelations});
791 public void testIsNetworkRoleServiceProperty() throws Exception {
792 ComponentInstanceBusinessLogic testSubject;
793 ComponentInstanceProperty property = new ComponentInstanceProperty();
794 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
798 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "isNetworkRoleServiceProperty", new Object[]{property, componentTypeEnum});
803 public void testConcatServiceNameToVLINetworkRolePropertiesValues() throws Exception {
804 ComponentInstanceBusinessLogic testSubject;
805 ToscaOperationFacade toscaOperationFacade = new ToscaOperationFacade();
806 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
807 String componentId = "";
808 String resourceInstanceId = "";
809 List<ComponentInstanceProperty> properties = new ArrayList<>();
810 StorageOperationStatus result;
813 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "concatServiceNameToVLINetworkRolePropertiesValues", new Object[]{toscaOperationFacade, componentTypeEnum, componentId, resourceInstanceId, properties});
818 public void testCreateOrUpdatePropertiesValues() throws Exception {
819 ComponentInstanceBusinessLogic testSubject;
820 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
821 Component component = createResource();
822 String componentId = component.getUniqueId();
823 String resourceInstanceId = "";
824 List<ComponentInstanceProperty> properties = new ArrayList<>();
825 String userId = user.getUserId();
826 Either<List<ComponentInstanceProperty>,ResponseFormat> result;
828 // Either<Component, StorageOperationStatus> getResourceResult = toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll);
829 when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(component));
832 testSubject=createTestSubject();
833 result=testSubject.createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties, userId);
835 componentTypeEnum =null;
836 result=testSubject.createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties, userId);
838 when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
839 result=testSubject.createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties, userId);
845 public void testUpdateCapabilityPropertyOnContainerComponent() throws Exception {
846 ComponentInstanceBusinessLogic testSubject;
847 ComponentInstanceProperty property = new ComponentInstanceProperty();
848 String newValue = "";
849 Component containerComponent = createResource();
850 ComponentInstance foundResourceInstance = createInstances();
851 String capabilityType = "";
852 String capabilityName = "";
853 ResponseFormat result;
856 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "updateCapabilityPropertyOnContainerComponent", new Object[]{property, newValue, containerComponent, foundResourceInstance, capabilityType, capabilityName});
862 public void testCreateOrUpdateInstanceInputValues() throws Exception {
863 ComponentInstanceBusinessLogic testSubject;
864 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
865 Component resource = createResource();
866 String componentId = resource.getUniqueId();
867 String resourceInstanceId = "";
868 List<ComponentInstanceInput> inputs = new ArrayList<>();
869 String userId = user.getUserId();
870 Either<List<ComponentInstanceInput>,ResponseFormat> result;
872 when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(resource));
875 testSubject=createTestSubject();
876 result=testSubject.createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs, userId);
877 componentTypeEnum =null;
878 result=testSubject.createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs, userId);
881 when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
882 result=testSubject.createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs, userId);
888 public void testCreateOrUpdateGroupInstancePropertyValue() throws Exception {
889 ComponentInstanceBusinessLogic testSubject;
890 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
891 Component resource = createResource();
892 String componentId = resource.getUniqueId();
893 String resourceInstanceId = "";
894 String groupInstanceId = "";
895 ComponentInstanceProperty property = new ComponentInstanceProperty();
896 String userId = user.getUserId();
897 Either<ComponentInstanceProperty,ResponseFormat> result;
900 when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.left(resource));
903 testSubject=createTestSubject();
904 result=testSubject.createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId, groupInstanceId, property, userId);
905 componentTypeEnum = null;
906 result=testSubject.createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId, groupInstanceId, property, userId);
908 when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
909 result=testSubject.createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId, groupInstanceId, property, userId);
914 public void testCreateOrUpdateInputValue() throws Exception {
915 ComponentInstanceBusinessLogic testSubject;
916 Component component = createResource();
917 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
918 String componentId = component.getUniqueId();
919 String resourceInstanceId = component.getUniqueId();
920 ComponentInstanceInput inputProperty = new ComponentInstanceInput();
921 String userId = user.getUserId();
922 Either<ComponentInstanceInput,ResponseFormat> result;
925 Either<Component, StorageOperationStatus> getResourceResult = Either.left(component);
926 when(toscaOperationFacade.getToscaElement(component.getUniqueId(), JsonParseFlagEnum.ParseMetadata)).thenReturn(getResourceResult);
929 testSubject=createTestSubject();
930 result=testSubject.createOrUpdateInputValue(componentTypeEnum, componentId, resourceInstanceId, inputProperty, userId);
932 componentTypeEnum = null;
933 result=testSubject.createOrUpdateInputValue(componentTypeEnum, componentId, resourceInstanceId, inputProperty, userId);
935 when(toscaOperationFacade.getToscaElement(component.getUniqueId(), JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
936 result=testSubject.createOrUpdateInputValue(componentTypeEnum, componentId, resourceInstanceId, inputProperty, userId);
941 public void testDeletePropertyValue() throws Exception {
942 ComponentInstanceBusinessLogic testSubject;
943 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
944 Component service = createService();
945 String serviceId = service.getUniqueId();
946 String resourceInstanceId = "";
947 String propertyValueId = "";
948 String userId = user.getUserId();
949 Either<ComponentInstanceProperty,ResponseFormat> result;
951 when(toscaOperationFacade.getToscaElement(serviceId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.left(service));
954 testSubject=createTestSubject();
955 result=testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId, userId);
956 componentTypeEnum= null;
957 result=testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId, userId);
959 when(toscaOperationFacade.getToscaElement(serviceId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
960 result=testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId, userId);
965 public void testGetAndValidateOriginComponentOfComponentInstance() throws Exception {
966 ComponentInstanceBusinessLogic testSubject;
967 ComponentTypeEnum containerComponentType = ComponentTypeEnum.RESOURCE;
968 Component resource = createResource();
969 ComponentInstance componentInstance = createInstances();
970 Either<Component,ResponseFormat> result;
972 when(toscaOperationFacade.getToscaFullElement(componentInstance.getComponentUid())).thenReturn(Either.left(resource));
975 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getAndValidateOriginComponentOfComponentInstance", new Object[]{containerComponentType, componentInstance});
983 public void testGetComponentParametersViewForForwardingPath() throws Exception {
984 ComponentInstanceBusinessLogic testSubject;
985 ComponentParametersView result;
988 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getComponentParametersViewForForwardingPath");
993 public void testChangeComponentInstanceVersion() throws Exception {
994 ComponentInstanceBusinessLogic testSubject;
995 String containerComponentParam = "";
996 String containerComponentId = "";
997 String componentInstanceId = "";
998 String userId = user.getUserId();
999 ComponentInstance newComponentInstance = createInstances();
1000 Either<ComponentInstance,ResponseFormat> result;
1003 testSubject=createTestSubject();result=testSubject.changeComponentInstanceVersion(containerComponentParam, containerComponentId, componentInstanceId, userId, newComponentInstance);
1004 newComponentInstance = null;
1005 testSubject=createTestSubject();result=testSubject.changeComponentInstanceVersion(containerComponentParam, containerComponentId, componentInstanceId, userId, newComponentInstance);
1010 public void testValidateInstanceNameUniquenessUponUpdate() throws Exception {
1011 ComponentInstanceBusinessLogic testSubject;
1012 Component containerComponent = createResource();
1013 ComponentInstance oldComponentInstance = createInstances();
1014 String newInstanceName = oldComponentInstance.getName();
1018 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateInstanceNameUniquenessUponUpdate", new Object[]{containerComponent, oldComponentInstance, newInstanceName});
1023 public void testGetResourceInstanceById() throws Exception {
1024 ComponentInstanceBusinessLogic testSubject;
1025 Component containerComponent = createResource();
1026 String instanceId = "";
1027 Either<ComponentInstance,StorageOperationStatus> result;
1030 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getResourceInstanceById", new Object[]{containerComponent, instanceId});
1035 public void testBuildComponentInstance() throws Exception {
1036 ComponentInstanceBusinessLogic testSubject;
1037 ComponentInstance resourceInstanceForUpdate = createInstances();
1038 ComponentInstance origInstanceForUpdate = null;
1039 ComponentInstance result;
1042 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "buildComponentInstance", new Object[]{resourceInstanceForUpdate, resourceInstanceForUpdate});
1050 public void testFindCapabilityOfInstance() throws Exception {
1051 ComponentInstanceBusinessLogic testSubject;String componentId = "";
1052 String instanceId = "";
1053 String capabilityType = "";
1054 String capabilityName = "";
1055 String ownerId = "";
1056 Map<String,List<CapabilityDefinition>> instanceCapabilities = new HashMap<>();
1057 Either<List<ComponentInstanceProperty>,ResponseFormat> result;
1060 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "findCapabilityOfInstance", new Object[]{componentId, instanceId, capabilityType, capabilityName, ownerId, instanceCapabilities});
1065 public void testFetchComponentInstanceCapabilityProperties() throws Exception {
1066 ComponentInstanceBusinessLogic testSubject;String componentId = "";
1067 String instanceId = "";
1068 String capabilityType = "";
1069 String capabilityName = "";
1070 String ownerId = "";
1071 Either<List<ComponentInstanceProperty>,ResponseFormat> result;
1074 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "fetchComponentInstanceCapabilityProperties", new Object[]{componentId, instanceId, capabilityType, capabilityName, ownerId});
1079 public void testUpdateCapabilityPropertyOnContainerComponent_1() throws Exception {
1080 ComponentInstanceBusinessLogic testSubject;
1081 ComponentInstanceProperty property = new ComponentInstanceProperty();
1082 String newValue = "";
1083 Component containerComponent = createResource();
1084 ComponentInstance foundResourceInstance = createInstances();
1085 String capabilityType = "";
1086 String capabilityName = "";
1087 String ownerId = "";
1088 ResponseFormat result;
1091 testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "updateCapabilityPropertyOnContainerComponent", new Object[]{property, newValue, containerComponent, foundResourceInstance, capabilityType, capabilityName, ownerId});
1096 public void testUpdateInstanceCapabilityProperties() throws Exception {
1097 ComponentInstanceBusinessLogic testSubject;
1098 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
1099 Component resource = createResource();
1100 String containerComponentId = resource.getUniqueId();
1101 String componentInstanceUniqueId = "";
1102 String capabilityType = "";
1103 String capabilityName = "";
1104 String ownerId = "";
1105 List<ComponentInstanceProperty> properties = new ArrayList<>();
1106 String userId = user.getUserId();
1107 Either<List<ComponentInstanceProperty>,ResponseFormat> result;
1110 when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.left(resource));
1115 testSubject=createTestSubject();
1116 result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, ownerId, properties, userId);
1117 when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND));
1118 result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, ownerId, properties, userId);
1119 componentTypeEnum = null;
1120 result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, ownerId, properties, userId);
1127 public void testUpdateInstanceCapabilityProperties_1() throws Exception {
1128 ComponentInstanceBusinessLogic testSubject;
1129 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
1130 Component component = createResource();
1131 String containerComponentId = component.getUniqueId();
1132 String componentInstanceUniqueId = "";
1133 String capabilityType = "";
1134 String capabilityName = "";
1135 List<ComponentInstanceProperty> properties = new ArrayList<>();
1136 String userId = user.getUserId();
1137 Either<List<ComponentInstanceProperty>,ResponseFormat> result;
1140 when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
1142 testSubject=createTestSubject();
1143 result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, properties, userId);
1144 when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.left(component));
1145 result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, properties, userId);