45b938f9883477a7cfc3029a031ab7d5e6e4cca3
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / impl / ComponentInstanceBusinessLogicTest.java
1 package org.openecomp.sdc.be.components.impl;
2
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;
9
10 import java.util.ArrayList;
11 import java.util.HashMap;
12 import java.util.HashSet;
13 import java.util.List;
14 import java.util.Map;
15 import java.util.Set;
16 import java.util.function.BiPredicate;
17
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;
66
67 import fj.data.Either;
68 import javassist.CodeConverter.ArrayAccessReplacementMethodNames;
69 import mockit.Deencapsulation;
70
71 import java.util.*;
72
73 /**
74  * The test suite designed for test functionality of
75  * ComponentInstanceBusinessLogic class
76  */
77 public class ComponentInstanceBusinessLogicTest {
78
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";
91
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;
98
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;
113
114         @Before
115         public void init() {
116                 createMocks();
117                 setMocks();
118                 stubMethods();
119                 createComponents();
120                 MockitoAnnotations.initMocks(this);
121         }
122
123         @Test
124         public void testGetRelationByIdSuccess() {
125                 getServiceRelationByIdSuccess(service);
126                 getServiceRelationByIdSuccess(resource);
127         }
128
129         @Test
130         public void testGetRelationByIdUserValidationFailure() {
131                 getServiceRelationByIdUserValidationFailure(service);
132                 getServiceRelationByIdUserValidationFailure(resource);
133         }
134
135         @Test
136         public void testGetRelationByIdComponentNotFoundFailure() {
137                 getRelationByIdComponentNotFoundFailure(service);
138                 getRelationByIdComponentNotFoundFailure(resource);
139         }
140
141         
142         @Test
143         public void testForwardingPathOnVersionChange() {
144                 getforwardingPathOnVersionChange();
145         }
146
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);
153
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);
163
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);
172
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));
180
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());
185
186         }
187
188         @Test
189         public void testDeleteForwardingPathsWhenComponentinstanceDeleted() {
190
191                 ComponentTypeEnum containerComponentType = ComponentTypeEnum.findByParamName("services");
192                 String containerComponentID = "Service-comp";
193                 String componentInstanceID = "NodeA1";
194                 Service component = new Service();
195
196                 component.addForwardingPath(createPath("path1", "NodeA1", "NodeB1", "1"));
197                 component.addForwardingPath(createPath("Path2", "NodeA2", "NodeB2", "2"));
198                 when(toscaOperationFacade.getToscaElement(eq(containerComponentID), any(ComponentParametersView.class)))
199                                 .thenReturn(Either.left(component));
200                 when(toscaOperationFacade.getToscaElement(eq(containerComponentID))).thenReturn(Either.left(component));
201                 when(forwardingPathOperation.deleteForwardingPath(any(Service.class), anySet()))
202                                 .thenReturn(Either.left(new HashSet<>()));
203                 Either<ComponentInstance, ResponseFormat> responseFormatEither = componentInstanceBusinessLogic
204                                 .deleteForwardingPathsRelatedTobeDeletedComponentInstance(containerComponentID, componentInstanceID,
205                                                 containerComponentType, Either.left(new ComponentInstance()));
206                 Assert.assertTrue(responseFormatEither.isLeft());
207
208         }
209
210         @Test
211         public void testDeleteForwardingPathsWhenErrorInComponentinstanceDelete() {
212
213                 ComponentTypeEnum containerComponentType = ComponentTypeEnum.findByParamName("services");
214                 String containerComponentID = "Service-comp";
215                 String componentInstanceID = "NodeA1";
216                 Service component = new Service();
217
218                 component.addForwardingPath(createPath("path1", "NodeA1", "NodeB1", "1"));
219                 component.addForwardingPath(createPath("Path2", "NodeA2", "NodeB2", "2"));
220                 when(toscaOperationFacade.getToscaElement(eq(containerComponentID), any(ComponentParametersView.class)))
221                                 .thenReturn(Either.left(component));
222                 when(toscaOperationFacade.getToscaElement(eq(containerComponentID))).thenReturn(Either.left(component));
223                 when(forwardingPathOperation.deleteForwardingPath(any(Service.class), anySet()))
224                                 .thenReturn(Either.left(new HashSet<>()));
225                 Either<ComponentInstance, ResponseFormat> responseFormatEither = componentInstanceBusinessLogic
226                                 .deleteForwardingPathsRelatedTobeDeletedComponentInstance(containerComponentID, componentInstanceID,
227                                                 containerComponentType, Either.right(new ResponseFormat()));
228                 Assert.assertTrue(responseFormatEither.isRight());
229
230         }
231
232         private ForwardingPathDataDefinition createPath(String pathName, String fromNode, String toNode, String uniqueId) {
233                 ForwardingPathDataDefinition forwardingPath = new ForwardingPathDataDefinition(pathName);
234                 forwardingPath.setProtocol("protocol");
235                 forwardingPath.setDestinationPortNumber("port");
236                 forwardingPath.setUniqueId(uniqueId);
237                 ListDataDefinition<ForwardingPathElementDataDefinition> forwardingPathElementListDataDefinition = new ListDataDefinition<>();
238                 forwardingPathElementListDataDefinition.add(new ForwardingPathElementDataDefinition(fromNode, toNode,
239                                 "nodeAcpType", "nodeBcpType", "nodeDcpName", "nodeBcpName"));
240                 forwardingPath.setPathElements(forwardingPathElementListDataDefinition);
241
242                 return forwardingPath;
243         }
244
245         private Map<String, ForwardingPathDataDefinition> generateForwardingPath(String componentInstanceID) {
246                 ForwardingPathDataDefinition forwardingPath = new ForwardingPathDataDefinition("fpName");
247                 String protocol = "protocol";
248                 forwardingPath.setProtocol(protocol);
249                 forwardingPath.setDestinationPortNumber("DestinationPortNumber");
250                 forwardingPath.setUniqueId("FP-ID-1");
251                 ListDataDefinition<ForwardingPathElementDataDefinition> forwardingPathElementListDataDefinition = new ListDataDefinition<>();
252                 forwardingPathElementListDataDefinition.add(new ForwardingPathElementDataDefinition(componentInstanceID,
253                                 "nodeB", "nodeA_FORWARDER_CAPABILITY", "nodeBcpType", "nodeDcpName", "nodeBcpName"));
254                 forwardingPath.setPathElements(forwardingPathElementListDataDefinition);
255                 Map<String, ForwardingPathDataDefinition> forwardingPaths = new HashMap<>();
256                 forwardingPaths.put("1122", forwardingPath);
257                 return forwardingPaths;
258         }
259
260         @SuppressWarnings("unchecked")
261         private void getServiceRelationByIdSuccess(Component component) {
262                 Either<User, ActionStatus> eitherCreator = Either.left(user);
263                 when(userAdmin.getUser(eq(USER_ID), eq(false))).thenReturn(eitherCreator);
264                 Either<Component, StorageOperationStatus> getComponentRes = Either.left(component);
265                 when(toscaOperationFacade.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
266                                 .thenReturn(getComponentRes);
267
268                 Either<RequirementDataDefinition, StorageOperationStatus> getfulfilledRequirementRes = Either.left(requirement);
269                 when(toscaOperationFacade.getFulfilledRequirementByRelation(eq(COMPONENT_ID), eq(FROM_INSTANCE_ID),
270                                 eq(relation), any(BiPredicate.class))).thenReturn(getfulfilledRequirementRes);
271
272                 Either<CapabilityDataDefinition, StorageOperationStatus> getfulfilledCapabilityRes = Either.left(capability);
273                 when(toscaOperationFacade.getFulfilledCapabilityByRelation(eq(COMPONENT_ID), eq(FROM_INSTANCE_ID), eq(relation),
274                                 any(BiPredicate.class))).thenReturn(getfulfilledCapabilityRes);
275
276                 Either<RequirementCapabilityRelDef, ResponseFormat> response = componentInstanceBusinessLogic
277                                 .getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
278                 assertTrue(response.isLeft());
279         }
280
281         private void getServiceRelationByIdUserValidationFailure(Component component) {
282                 // Either<User, ActionStatus> eitherCreator =
283                 // Either.right(ActionStatus.USER_NOT_FOUND);
284                 // when(userAdmin.getUser(eq(USER_ID),
285                 // eq(false))).thenReturn(eitherCreator);
286                 when(userValidations.validateUserExists(eq(USER_ID), eq("get relation by Id"), eq(false)))
287                                 .thenReturn(Either.right(new ResponseFormat(404)));
288                 Either<RequirementCapabilityRelDef, ResponseFormat> response = componentInstanceBusinessLogic
289                                 .getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
290                 assertTrue(response.isRight());
291         }
292
293         private void getRelationByIdComponentNotFoundFailure(Component component) {
294                 Either<User, ActionStatus> eitherCreator = Either.left(user);
295                 when(userAdmin.getUser(eq(USER_ID), eq(false))).thenReturn(eitherCreator);
296                 Either<Component, StorageOperationStatus> getComponentRes = Either.right(StorageOperationStatus.NOT_FOUND);
297                 when(toscaOperationFacade.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
298                                 .thenReturn(getComponentRes);
299
300                 Either<RequirementCapabilityRelDef, ResponseFormat> response = componentInstanceBusinessLogic
301                                 .getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
302                 assertTrue(response.isRight());
303         }
304
305         private static void createMocks() {
306                 componentsUtils = Mockito.mock(ComponentsUtils.class);
307                 servletUtils = Mockito.mock(ServletUtils.class);
308                 responseFormat = Mockito.mock(ResponseFormat.class);
309                 toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
310                 userAdmin = Mockito.mock(UserBusinessLogic.class);
311                 user = Mockito.mock(User.class);
312                 baseBusinessLogic = Mockito.mock(BaseBusinessLogic.class);
313                 userValidations = Mockito.mock(UserValidations.class);
314                 forwardingPathOperation = Mockito.mock(ForwardingPathOperation.class);
315                 componentInstanceOperation = Mockito.mock(IComponentInstanceOperation.class);
316                 artifactsBusinessLogic = Mockito.mock(ArtifactsBusinessLogic.class);
317                 toscaDataDefinition = Mockito.mock(ToscaDataDefinition.class);
318         }
319
320         private static void setMocks() {
321                 componentInstanceBusinessLogic = new ComponentInstanceBusinessLogic();
322                 componentInstanceBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
323                 componentInstanceBusinessLogic.setUserAdmin(userAdmin);
324                 componentInstanceBusinessLogic.setComponentsUtils(componentsUtils);
325                 componentInstanceBusinessLogic.setUserValidations(userValidations);
326                 componentInstanceBusinessLogic.setForwardingPathOperation(forwardingPathOperation);
327         }
328
329         private static void stubMethods() {
330                 when(servletUtils.getComponentsUtils()).thenReturn(componentsUtils);
331                 when(userValidations.validateUserExists(eq(USER_ID), eq("get relation by Id"), eq(false)))
332                                 .thenReturn(Either.left(user));
333                 when(componentsUtils.getResponseFormat(eq(ActionStatus.RELATION_NOT_FOUND), eq(RELATION_ID), eq(COMPONENT_ID)))
334                                 .thenReturn(responseFormat);
335                 Either<User, ActionStatus> eitherGetUser = Either.left(user);
336                 when(userAdmin.getUser("jh0003", false)).thenReturn(eitherGetUser);
337                 when(userValidations.validateUserExists(eq(user.getUserId()), anyString(), eq(false)))
338                                 .thenReturn(Either.left(user));
339         }
340
341         private static void createComponents() {
342                 createRelation();
343                 createInstances();
344                 createService();
345                 createResource();
346         }
347
348         private static Component createResource() {
349                 resource = new Resource();
350                 resource.setUniqueId(COMPONENT_ID);
351                 resource.setComponentInstancesRelations(Lists.newArrayList(relation));
352                 resource.setComponentInstances(Lists.newArrayList(toInstance, fromInstance));
353                 resource.setCapabilities(toInstance.getCapabilities());
354                 resource.setRequirements(fromInstance.getRequirements());
355                 resource.setComponentType(ComponentTypeEnum.RESOURCE);
356                 return resource;
357         }
358
359         private static Component createService() {
360                 service = new Service();
361                 service.setUniqueId(COMPONENT_ID);
362                 service.setComponentInstancesRelations(Lists.newArrayList(relation));
363                 service.setComponentInstances(Lists.newArrayList(toInstance, fromInstance));
364                 service.setCapabilities(toInstance.getCapabilities());
365                 service.setRequirements(fromInstance.getRequirements());
366                 service.setComponentType(ComponentTypeEnum.SERVICE);
367                 return service;
368         }
369
370         private static ComponentInstance createInstances() {
371                 toInstance = new ComponentInstance();
372                 toInstance.setUniqueId(TO_INSTANCE_ID);
373                 toInstance.setComponentUid("uuuiiid");
374                 toInstance.setName("tests");
375
376                 fromInstance = new ComponentInstance();
377                 fromInstance.setUniqueId(FROM_INSTANCE_ID);
378
379                 capability = new CapabilityDataDefinition();
380                 capability.setOwnerId(CAPABILITY_OWNER_ID);
381                 capability.setUniqueId(CAPABILITY_UID);
382                 capability.setName(CAPABILITY_NAME);
383
384                 Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
385                 capabilities.put(capability.getName(), Lists.newArrayList(new CapabilityDefinition(capability)));
386
387                 requirement = new RequirementDataDefinition();
388                 requirement.setOwnerId(REQUIREMENT_OWNER_ID);
389                 requirement.setUniqueId(REQUIREMENT_UID);
390                 requirement.setName(REQUIREMENT_NAME);
391                 requirement.setRelationship(RELATIONSHIP_TYPE);
392
393                 Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
394                 requirements.put(requirement.getCapability(), Lists.newArrayList(new RequirementDefinition(requirement)));
395
396                 toInstance.setCapabilities(capabilities);
397                 fromInstance.setRequirements(requirements);
398                 return toInstance;
399         }
400
401         private static void createRelation() {
402
403                 relation = new RequirementCapabilityRelDef();
404                 CapabilityRequirementRelationship relationship = new CapabilityRequirementRelationship();
405                 RelationshipInfo relationInfo = new RelationshipInfo();
406                 relationInfo.setId(RELATION_ID);
407                 relationship.setRelation(relationInfo);
408
409                 relation.setRelationships(Lists.newArrayList(relationship));
410                 relation.setToNode(TO_INSTANCE_ID);
411                 relation.setFromNode(FROM_INSTANCE_ID);
412
413                 relationInfo.setCapabilityOwnerId(CAPABILITY_OWNER_ID);
414                 relationInfo.setCapabilityUid(CAPABILITY_UID);
415                 relationInfo.setCapability(CAPABILITY_NAME);
416                 relationInfo.setRequirementOwnerId(REQUIREMENT_OWNER_ID);
417                 relationInfo.setRequirementUid(REQUIREMENT_UID);
418                 relationInfo.setRequirement(REQUIREMENT_NAME);
419                 RelationshipImpl relationshipImpl = new RelationshipImpl();
420                 relationshipImpl.setType(RELATIONSHIP_TYPE);
421                 relationInfo.setRelationships(relationshipImpl);
422         }
423
424         ///////////////////////////////////////////////////////////////////////////////
425         /////////////////////////////new test//////////////////////////////////////////
426         ///////////////////////////////////////////////////////////////////////////////
427         
428         
429         private ComponentInstanceBusinessLogic createTestSubject() {
430                         return componentInstanceBusinessLogic;
431         }
432
433         
434
435
436         
437         @Test
438         public void testChangeServiceProxyVersion() throws Exception {
439                 ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
440                 String containerComponentType = "";
441                 String containerComponentId = "";
442                 String serviceProxyId = "";
443                 String userId = user.getUserId();
444                 Either<ComponentInstance, ResponseFormat> result;
445
446                 // default test
447                 componentInstanceBusinessLogic = createTestSubject();
448                 result = componentInstanceBusinessLogic.changeServiceProxyVersion(containerComponentType, containerComponentId, serviceProxyId,
449                                 userId);
450         }
451
452
453
454
455         
456
457         
458         @Test
459         public void testCreateServiceProxy() throws Exception {
460                 ComponentInstanceBusinessLogic testSubject;
461                 String containerComponentType = "";
462                 String containerComponentId = "";
463                 String userId = user.getUserId();
464                 ComponentInstance componentInstance = createInstances();
465                 Either<ComponentInstance, ResponseFormat> result;
466
467                 // default test
468                 testSubject = createTestSubject();
469                 result = testSubject.createServiceProxy(containerComponentType, containerComponentId, userId,
470                                 componentInstance);
471         }
472
473
474
475         
476         
477         @Test
478         public void testDeleteForwardingPathsRelatedTobeDeletedComponentInstance() throws Exception {
479                 ComponentInstanceBusinessLogic testSubject;
480                 String containerComponentId = "";
481                 String componentInstanceId = "";
482                 ComponentTypeEnum containerComponentType = ComponentTypeEnum.RESOURCE;
483                 Either<ComponentInstance, ResponseFormat> resultOp = null;
484                 Either<ComponentInstance, ResponseFormat> result;
485
486                 // default test
487                 testSubject = createTestSubject();
488                 result = testSubject.deleteForwardingPathsRelatedTobeDeletedComponentInstance(containerComponentId,
489                                 componentInstanceId, containerComponentType, resultOp);
490         }
491
492         
493         @Test
494         public void testDeleteServiceProxy() throws Exception {
495                 ComponentInstanceBusinessLogic testSubject;
496                 String containerComponentType = "";
497                 String containerComponentId = "";
498                 String serviceProxyId = "";
499                 String userId = user.getUserId();
500                 Either<ComponentInstance, ResponseFormat> result;
501
502                 // default test
503                 testSubject = createTestSubject();
504                 result = testSubject.deleteServiceProxy(containerComponentType, containerComponentId, serviceProxyId, userId);
505         }
506
507
508         
509
510
511         
512         @Test
513         public void testGetComponentInstanceInputsByInputId() throws Exception {
514                 ComponentInstanceBusinessLogic testSubject;
515                 Component component = new Service();
516                 String inputId = "";
517                 List<ComponentInstanceInput> result;
518
519                 // default test
520                 testSubject = createTestSubject();
521                 result = testSubject.getComponentInstanceInputsByInputId(component, inputId);
522         }
523
524
525         
526         @Test
527         public void testGetComponentInstancePropertiesByInputId() throws Exception {
528                 ComponentInstanceBusinessLogic testSubject;
529                 Component component = new Service();
530                 String inputId = "";
531                 List<ComponentInstanceProperty> result;
532
533                 // default test
534                 testSubject = createTestSubject();
535                 result = testSubject.getComponentInstancePropertiesByInputId(component, inputId);
536         }
537
538         
539         @Test
540         public void testGetRelationById() throws Exception {
541                 ComponentInstanceBusinessLogic testSubject;
542                 String componentId = "";
543                 String relationId = "";
544                 String userId = user.getUserId();
545                 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE_INSTANCE;
546                 Either<RequirementCapabilityRelDef, ResponseFormat> result;
547
548                 // default test
549                 testSubject = createTestSubject();
550                 result = testSubject.getRelationById(componentId, relationId, userId, componentTypeEnum);
551         }
552
553         
554
555
556         
557         @Test
558         public void testCreateComponentInstance_1() throws Exception {
559         ComponentInstanceBusinessLogic testSubject;String containerComponentParam = "";
560         String containerComponentId = "";
561         String userId = user.getUserId();
562         ComponentInstance resourceInstance = null;
563         boolean inTransaction = false;
564         boolean needLock = false;
565         Either<ComponentInstance,ResponseFormat> result;
566         
567         // default test
568         testSubject=createTestSubject();result=testSubject.createComponentInstance(containerComponentParam, containerComponentId, userId, resourceInstance, inTransaction, needLock);
569         }
570
571         
572
573
574         
575         @Test
576         public void testCreateAndAssociateRIToRI() throws Exception {
577         ComponentInstanceBusinessLogic testSubject;
578         
579         String containerComponentParam = "";
580         String containerComponentId = "";
581         String userId = user.getUserId();
582         CreateAndAssotiateInfo createAndAssotiateInfo = new CreateAndAssotiateInfo(null, null);
583         Either<CreateAndAssotiateInfo,ResponseFormat> result;
584         
585         // default test
586         testSubject=createTestSubject();result=testSubject.createAndAssociateRIToRI(containerComponentParam, containerComponentId, userId, createAndAssotiateInfo);
587         }
588         
589         @Test
590         public void testGetOriginComponentFromComponentInstance_1() throws Exception {
591         ComponentInstanceBusinessLogic testSubject;
592         Component compoent = createResource();
593         String componentInstanceName = "";
594         String origComponetId = compoent.getUniqueId();
595         Either<Component, StorageOperationStatus> oldResourceRes = Either.left(compoent);
596         when(toscaOperationFacade.getToscaFullElement(compoent.getUniqueId())).thenReturn(oldResourceRes);
597         Either<Component,ResponseFormat> result;
598         
599         // default test
600         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getOriginComponentFromComponentInstance", new Object[]{componentInstanceName, origComponetId});
601         }
602
603         
604         @Test
605         public void testCreateComponentInstanceOnGraph() throws Exception {
606         ComponentInstanceBusinessLogic testSubject;
607         Component containerComponent = createResource();
608         Component originComponent = null;
609         ComponentInstance componentInstance = createInstances();
610         Either<ComponentInstance,ResponseFormat> result;
611         
612         Either<ImmutablePair<Component, String>, StorageOperationStatus> result2 = Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND);
613         when(toscaOperationFacade.addComponentInstanceToTopologyTemplate(containerComponent, containerComponent,componentInstance, false, user)).thenReturn(result2);
614         
615         // default test
616         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createComponentInstanceOnGraph", new Object[]{containerComponent, containerComponent, componentInstance, user});
617         }
618         
619         /*@Test
620         public void testCreateComponentInstanceOnGraph2() throws Exception {
621         ComponentInstanceBusinessLogic testSubject;
622         Component containerComponent = createResource();
623         containerComponent.setName("name");
624         ComponentInstance componentInstance = createInstances();
625         Either<ComponentInstance,ResponseFormat> result;
626         ImmutablePair<Component, String> pair =  new ImmutablePair<>(containerComponent,"");
627         
628         
629         
630         
631         Either<ImmutablePair<Component, String>, StorageOperationStatus> result2 = Either.left(pair);
632         when(toscaOperationFacade.addComponentInstanceToTopologyTemplate(containerComponent, containerComponent,componentInstance, false, user)).thenReturn(result2);
633         
634         // default test
635         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createComponentInstanceOnGraph", new Object[]{containerComponent, containerComponent, componentInstance, user});
636         }*/
637         
638         @Test
639         public void testUpdateComponentInstanceMetadata() throws Exception {
640         ComponentInstanceBusinessLogic testSubject;
641         String containerComponentParam = "";
642         String containerComponentId = "";
643         String componentInstanceId = "";
644         String userId = user.getUserId();
645         ComponentInstance componentInstance = createInstances();
646         Either<ComponentInstance,ResponseFormat> result;
647         
648         // default test
649         testSubject=createTestSubject();result=testSubject.updateComponentInstanceMetadata(containerComponentParam, containerComponentId, componentInstanceId, userId, componentInstance);
650         }
651
652         
653         @Test
654         public void testUpdateComponentInstanceMetadata_1() throws Exception {
655         ComponentInstanceBusinessLogic testSubject;String containerComponentParam = "";
656         String containerComponentId = "";
657         String componentInstanceId = "";
658         String userId = user.getUserId();
659         ComponentInstance componentInstance = createInstances();
660         boolean inTransaction = false;
661         boolean needLock = false;
662         boolean createNewTransaction = false;
663         Either<ComponentInstance,ResponseFormat> result;
664         
665         // default test
666         testSubject=createTestSubject();result=testSubject.updateComponentInstanceMetadata(containerComponentParam, containerComponentId, componentInstanceId, userId, componentInstance, inTransaction, needLock, createNewTransaction);
667         }
668
669         
670
671
672         
673         @Test
674         public void testValidateParent() throws Exception {
675         ComponentInstanceBusinessLogic testSubject;
676         Component containerComponent = createResource();
677         String nodeTemplateId = "";
678         boolean result;
679         
680         // default test
681         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateParent", new Object[]{containerComponent, nodeTemplateId});
682         }
683
684         
685         @Test
686         public void testGetComponentType() throws Exception {
687         ComponentInstanceBusinessLogic testSubject;
688         ComponentTypeEnum containerComponentType = ComponentTypeEnum.RESOURCE;
689         ComponentTypeEnum result;
690         
691         // default test
692         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getComponentType", new Object[]{ComponentTypeEnum.class});
693         }
694
695         
696         
697         @Test
698         public void testGetNewGroupName() throws Exception {
699         ComponentInstanceBusinessLogic testSubject;String oldPrefix = "";
700         String newNormailzedPrefix = "";
701         String qualifiedGroupInstanceName = "";
702         String result;
703         
704         // test 1
705         testSubject=createTestSubject();
706         result=Deencapsulation.invoke(testSubject, "getNewGroupName", new Object[]{oldPrefix, newNormailzedPrefix, qualifiedGroupInstanceName});
707         }
708
709         
710         @Test
711         public void testUpdateComponentInstanceMetadata_3() throws Exception {
712         ComponentInstanceBusinessLogic testSubject;
713         ComponentInstance oldComponentInstance = createInstances();
714         ComponentInstance newComponentInstance = null;
715         ComponentInstance result;
716         
717         // default test
718         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "updateComponentInstanceMetadata", new Object[]{oldComponentInstance, oldComponentInstance});
719         }
720
721         
722         @Test
723         public void testDeleteComponentInstance() throws Exception {
724         ComponentInstanceBusinessLogic testSubject;String containerComponentParam = "";
725         String containerComponentId = "";
726         String componentInstanceId = "";
727         String userId = user.getUserId();
728         Either<ComponentInstance,ResponseFormat> result;
729         
730         // default test
731         testSubject=createTestSubject();result=testSubject.deleteComponentInstance(containerComponentParam, containerComponentId, componentInstanceId, userId);
732         }
733
734         
735         @Test
736         public void testDeleteForwardingPaths() throws Exception {
737         ComponentInstanceBusinessLogic testSubject;
738         Component service = createService();
739         String serviceId = service.getUniqueId();
740         List<String> pathIdsToDelete = new ArrayList<>();
741         Either<Set<String>,ResponseFormat> result;
742         
743 //      Either<Service, StorageOperationStatus> storageStatus = toscaOperationFacade.getToscaElement(serviceId);
744         when(toscaOperationFacade.getToscaElement(serviceId)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
745         
746         // default test
747         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "deleteForwardingPaths", new Object[]{serviceId, pathIdsToDelete});
748         }
749
750         
751         @Test
752         public void testAssociateRIToRIOnGraph() throws Exception {
753         ComponentInstanceBusinessLogic testSubject;
754         Component containerComponent = createResource();
755         RequirementCapabilityRelDef requirementDef = new RequirementCapabilityRelDef();
756         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
757         boolean inTransaction = false;
758         Either<RequirementCapabilityRelDef,ResponseFormat> result;
759         
760         
761
762         Either<RequirementCapabilityRelDef, StorageOperationStatus> getResourceResult = Either.left(requirementDef);
763         when(toscaOperationFacade.associateResourceInstances(containerComponent.getUniqueId(), requirementDef)).thenReturn(getResourceResult);
764         
765         // default test
766         testSubject=createTestSubject();result=testSubject.associateRIToRIOnGraph(containerComponent, requirementDef, componentTypeEnum, inTransaction);
767         }
768
769
770         
771         @Test
772         public void testFindRelation() throws Exception {
773         ComponentInstanceBusinessLogic testSubject;
774         String relationId = "";
775         List<RequirementCapabilityRelDef> requirementCapabilityRelations = new ArrayList<>();
776         RequirementCapabilityRelDef result;
777         
778         // default test
779         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "findRelation", new Object[]{relationId, requirementCapabilityRelations});
780         }
781
782                 
783         @Test
784         public void testIsNetworkRoleServiceProperty() throws Exception {
785         ComponentInstanceBusinessLogic testSubject;
786         ComponentInstanceProperty property = new ComponentInstanceProperty();
787         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
788         boolean result;
789         
790         // default test
791         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "isNetworkRoleServiceProperty", new Object[]{property, componentTypeEnum});
792         }
793
794         
795         @Test
796         public void testConcatServiceNameToVLINetworkRolePropertiesValues() throws Exception {
797         ComponentInstanceBusinessLogic testSubject;
798         ToscaOperationFacade toscaOperationFacade = new ToscaOperationFacade();
799         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
800         String componentId = "";
801         String resourceInstanceId = "";
802         List<ComponentInstanceProperty> properties = new ArrayList<>();
803         StorageOperationStatus result;
804         
805         // default test
806         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "concatServiceNameToVLINetworkRolePropertiesValues", new Object[]{toscaOperationFacade, componentTypeEnum, componentId, resourceInstanceId, properties});
807         }
808
809         
810         @Test
811         public void testCreateOrUpdatePropertiesValues() throws Exception {
812         ComponentInstanceBusinessLogic testSubject;
813         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
814         Component component = createResource();
815         String componentId = component.getUniqueId();
816         String resourceInstanceId = "";
817         List<ComponentInstanceProperty> properties = new ArrayList<>();
818         String userId = user.getUserId();
819         Either<List<ComponentInstanceProperty>,ResponseFormat> result;
820         
821 //      Either<Component, StorageOperationStatus> getResourceResult = toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll);
822         when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(component));
823         
824         // test 1
825         testSubject=createTestSubject();
826         result=testSubject.createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties, userId);
827         
828         componentTypeEnum =null;
829         result=testSubject.createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties, userId);
830         
831         when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
832         result=testSubject.createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties, userId);
833         
834         }
835
836         
837         @Test
838         public void testUpdateCapabilityPropertyOnContainerComponent() throws Exception {
839         ComponentInstanceBusinessLogic testSubject;
840         ComponentInstanceProperty property = new ComponentInstanceProperty();
841         String newValue = "";
842         Component containerComponent = createResource();
843         ComponentInstance foundResourceInstance = createInstances();
844         String capabilityType = "";
845         String capabilityName = "";
846         ResponseFormat result;
847         
848         // default test
849         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "updateCapabilityPropertyOnContainerComponent", new Object[]{property, newValue, containerComponent, foundResourceInstance, capabilityType, capabilityName});
850         }
851
852         
853         
854         @Test
855         public void testCreateOrUpdateInstanceInputValues() throws Exception {
856         ComponentInstanceBusinessLogic testSubject;
857         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
858         Component resource = createResource();
859         String componentId = resource.getUniqueId();
860         String resourceInstanceId = "";
861         List<ComponentInstanceInput> inputs = new ArrayList<>();
862         String userId = user.getUserId();
863         Either<List<ComponentInstanceInput>,ResponseFormat> result;
864         
865          when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(resource));
866         
867         // test 1
868         testSubject=createTestSubject();
869         result=testSubject.createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs, userId);
870         componentTypeEnum =null;
871         result=testSubject.createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs, userId);
872         
873         
874          when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
875          result=testSubject.createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs, userId);
876         
877         }
878
879         
880         @Test
881         public void testCreateOrUpdateGroupInstancePropertyValue() throws Exception {
882         ComponentInstanceBusinessLogic testSubject;
883         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
884         Component resource = createResource();
885         String componentId = resource.getUniqueId();
886         String resourceInstanceId = "";
887         String groupInstanceId = "";
888         ComponentInstanceProperty property = new ComponentInstanceProperty();
889         String userId = user.getUserId();
890         Either<ComponentInstanceProperty,ResponseFormat> result;
891         
892         
893          when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.left(resource));
894         
895         // test 1
896         testSubject=createTestSubject();
897         result=testSubject.createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId, groupInstanceId, property, userId);
898         componentTypeEnum = null;
899         result=testSubject.createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId, groupInstanceId, property, userId);
900         
901          when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
902          result=testSubject.createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId, groupInstanceId, property, userId);
903         }
904
905         
906         @Test
907         public void testCreateOrUpdateInputValue() throws Exception {
908         ComponentInstanceBusinessLogic testSubject;
909         Component component = createResource();
910         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
911         String componentId = component.getUniqueId();
912         String resourceInstanceId = component.getUniqueId();
913         ComponentInstanceInput inputProperty = new ComponentInstanceInput();
914         String userId = user.getUserId();
915         Either<ComponentInstanceInput,ResponseFormat> result;
916         
917
918         Either<Component, StorageOperationStatus> getResourceResult = Either.left(component);
919         when(toscaOperationFacade.getToscaElement(component.getUniqueId(), JsonParseFlagEnum.ParseMetadata)).thenReturn(getResourceResult);
920         
921         // test 1
922         testSubject=createTestSubject();
923         result=testSubject.createOrUpdateInputValue(componentTypeEnum, componentId, resourceInstanceId, inputProperty, userId);
924         
925         componentTypeEnum = null;
926         result=testSubject.createOrUpdateInputValue(componentTypeEnum, componentId, resourceInstanceId, inputProperty, userId);
927         
928         when(toscaOperationFacade.getToscaElement(component.getUniqueId(), JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
929         result=testSubject.createOrUpdateInputValue(componentTypeEnum, componentId, resourceInstanceId, inputProperty, userId);                 
930         }
931
932         
933         @Test
934         public void testDeletePropertyValue() throws Exception {
935         ComponentInstanceBusinessLogic testSubject;
936         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
937         Component service = createService();
938         String serviceId = service.getUniqueId();
939         String resourceInstanceId = "";
940         String propertyValueId = "";
941         String userId = user.getUserId();
942         Either<ComponentInstanceProperty,ResponseFormat> result;
943         
944          when(toscaOperationFacade.getToscaElement(serviceId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.left(service));
945         
946         // test 1
947         testSubject=createTestSubject();
948         result=testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId, userId);
949         componentTypeEnum= null;
950         result=testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId, userId);
951         
952          when(toscaOperationFacade.getToscaElement(serviceId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
953         result=testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId, userId);
954         }
955
956         
957         @Test
958         public void testGetAndValidateOriginComponentOfComponentInstance() throws Exception {
959         ComponentInstanceBusinessLogic testSubject;
960         ComponentTypeEnum containerComponentType = ComponentTypeEnum.RESOURCE;
961         Component resource = createResource();
962         ComponentInstance componentInstance = createInstances();
963         Either<Component,ResponseFormat> result;
964         
965          when(toscaOperationFacade.getToscaFullElement(componentInstance.getComponentUid())).thenReturn(Either.left(resource));
966         
967         // default test
968         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getAndValidateOriginComponentOfComponentInstance", new Object[]{containerComponentType, componentInstance});
969         }
970
971         
972
973
974         
975         @Test
976         public void testGetComponentParametersViewForForwardingPath() throws Exception {
977         ComponentInstanceBusinessLogic testSubject;
978         ComponentParametersView result;
979         
980         // default test
981         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getComponentParametersViewForForwardingPath");
982         }
983
984         
985         @Test
986         public void testChangeComponentInstanceVersion() throws Exception {
987         ComponentInstanceBusinessLogic testSubject;
988         String containerComponentParam = "";
989         String containerComponentId = "";
990         String componentInstanceId = "";
991         String userId = user.getUserId();
992         ComponentInstance newComponentInstance = createInstances();
993         Either<ComponentInstance,ResponseFormat> result;
994         
995         // default test
996         testSubject=createTestSubject();result=testSubject.changeComponentInstanceVersion(containerComponentParam, containerComponentId, componentInstanceId, userId, newComponentInstance);
997         newComponentInstance = null;
998         testSubject=createTestSubject();result=testSubject.changeComponentInstanceVersion(containerComponentParam, containerComponentId, componentInstanceId, userId, newComponentInstance);
999         
1000         }
1001         
1002         @Test
1003         public void testValidateInstanceNameUniquenessUponUpdate() throws Exception {
1004         ComponentInstanceBusinessLogic testSubject;
1005         Component containerComponent = createResource();
1006         ComponentInstance oldComponentInstance = createInstances();
1007         String newInstanceName = oldComponentInstance.getName();
1008         Boolean result;
1009         
1010         // default test
1011         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateInstanceNameUniquenessUponUpdate", new Object[]{containerComponent, oldComponentInstance, newInstanceName});
1012         }
1013
1014         
1015         @Test
1016         public void testGetResourceInstanceById() throws Exception {
1017         ComponentInstanceBusinessLogic testSubject;
1018         Component containerComponent = createResource();
1019         String instanceId = "";
1020         Either<ComponentInstance,StorageOperationStatus> result;
1021         
1022         // default test
1023         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getResourceInstanceById", new Object[]{containerComponent, instanceId});
1024         }
1025
1026         
1027         @Test
1028         public void testBuildComponentInstance() throws Exception {
1029         ComponentInstanceBusinessLogic testSubject;
1030         ComponentInstance resourceInstanceForUpdate = createInstances();
1031         ComponentInstance origInstanceForUpdate = null;
1032         ComponentInstance result;
1033         
1034         // default test
1035         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "buildComponentInstance", new Object[]{resourceInstanceForUpdate, resourceInstanceForUpdate});
1036         }
1037
1038         
1039
1040
1041         
1042         @Test
1043         public void testFindCapabilityOfInstance() throws Exception {
1044         ComponentInstanceBusinessLogic testSubject;String componentId = "";
1045         String instanceId = "";
1046         String capabilityType = "";
1047         String capabilityName = "";
1048         String ownerId = "";
1049         Map<String,List<CapabilityDefinition>> instanceCapabilities = new HashMap<>();
1050         Either<List<ComponentInstanceProperty>,ResponseFormat> result;
1051         
1052         // default test
1053         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "findCapabilityOfInstance", new Object[]{componentId, instanceId, capabilityType, capabilityName, ownerId, instanceCapabilities});
1054         }
1055
1056         
1057         @Test
1058         public void testFetchComponentInstanceCapabilityProperties() throws Exception {
1059         ComponentInstanceBusinessLogic testSubject;String componentId = "";
1060         String instanceId = "";
1061         String capabilityType = "";
1062         String capabilityName = "";
1063         String ownerId = "";
1064         Either<List<ComponentInstanceProperty>,ResponseFormat> result;
1065         
1066         // default test
1067         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "fetchComponentInstanceCapabilityProperties", new Object[]{componentId, instanceId, capabilityType, capabilityName, ownerId});
1068         }
1069
1070         
1071         @Test
1072         public void testUpdateCapabilityPropertyOnContainerComponent_1() throws Exception {
1073         ComponentInstanceBusinessLogic testSubject;
1074         ComponentInstanceProperty property = new ComponentInstanceProperty();
1075         String newValue = "";
1076         Component containerComponent = createResource();
1077         ComponentInstance foundResourceInstance = createInstances();
1078         String capabilityType = "";
1079         String capabilityName = "";
1080         String ownerId = "";
1081         ResponseFormat result;
1082         
1083         // default test
1084         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "updateCapabilityPropertyOnContainerComponent", new Object[]{property, newValue, containerComponent, foundResourceInstance, capabilityType, capabilityName, ownerId});
1085         }
1086
1087         
1088         @Test
1089         public void testUpdateInstanceCapabilityProperties() throws Exception {
1090         ComponentInstanceBusinessLogic testSubject;
1091         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
1092         Component resource = createResource();
1093         String containerComponentId = resource.getUniqueId();
1094         String componentInstanceUniqueId = "";
1095         String capabilityType = "";
1096         String capabilityName = "";
1097         String ownerId = "";
1098         List<ComponentInstanceProperty> properties = new ArrayList<>();
1099         String userId = user.getUserId();
1100         Either<List<ComponentInstanceProperty>,ResponseFormat> result;
1101         
1102         
1103          when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.left(resource));
1104         
1105         
1106         
1107         // test 1
1108         testSubject=createTestSubject();
1109         result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, ownerId, properties, userId);
1110         when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND));
1111         result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, ownerId, properties, userId);
1112         componentTypeEnum = null;
1113         result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, ownerId, properties, userId);
1114         
1115         
1116         }
1117
1118         
1119         @Test
1120         public void testUpdateInstanceCapabilityProperties_1() throws Exception {
1121         ComponentInstanceBusinessLogic testSubject;
1122         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
1123         Component component = createResource();
1124         String containerComponentId = component.getUniqueId();
1125         String componentInstanceUniqueId = "";
1126         String capabilityType = "";
1127         String capabilityName = "";
1128         List<ComponentInstanceProperty> properties = new ArrayList<>();
1129         String userId = user.getUserId();
1130         Either<List<ComponentInstanceProperty>,ResponseFormat> result;
1131         
1132          
1133          when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
1134         // test 1
1135         testSubject=createTestSubject();
1136         result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, properties, userId);
1137          when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.left(component));
1138          result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, properties, userId);
1139         }
1140
1141
1142 }
1143
1144         
1145