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