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