1 package org.openecomp.sdc.be.components.impl;
 
   3 import static org.junit.Assert.assertTrue;
 
   4 import static org.mockito.ArgumentMatchers.any;
 
   5 import static org.mockito.ArgumentMatchers.anySet;
 
   6 import static org.mockito.ArgumentMatchers.anyString;
 
   7 import static org.mockito.ArgumentMatchers.eq;
 
   8 import static org.mockito.Mockito.when;
 
  10 import java.util.ArrayList;
 
  11 import java.util.HashMap;
 
  12 import java.util.HashSet;
 
  13 import java.util.List;
 
  16 import java.util.function.BiPredicate;
 
  18 import org.apache.commons.lang3.tuple.ImmutablePair;
 
  19 import org.apache.commons.lang3.tuple.Pair;
 
  20 import org.assertj.core.util.Lists;
 
  21 import org.junit.Assert;
 
  22 import org.junit.Before;
 
  23 import org.junit.Test;
 
  24 import org.mockito.Mock;
 
  25 import org.mockito.Mockito;
 
  26 import org.mockito.MockitoAnnotations;
 
  27 import org.openecomp.sdc.be.components.validation.UserValidations;
 
  28 import org.openecomp.sdc.be.dao.api.ActionStatus;
 
  29 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
 
  30 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
 
  31 import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
 
  32 import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
 
  33 import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition;
 
  34 import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
 
  35 import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
 
  36 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
 
  37 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
 
  38 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
 
  39 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
 
  40 import org.openecomp.sdc.be.impl.ComponentsUtils;
 
  41 import org.openecomp.sdc.be.impl.ServletUtils;
 
  42 import org.openecomp.sdc.be.info.CreateAndAssotiateInfo;
 
  43 import org.openecomp.sdc.be.model.CapabilityDefinition;
 
  44 import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
 
  45 import org.openecomp.sdc.be.model.Component;
 
  46 import org.openecomp.sdc.be.model.ComponentInstance;
 
  47 import org.openecomp.sdc.be.model.ComponentInstanceInput;
 
  48 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
 
  49 import org.openecomp.sdc.be.model.ComponentParametersView;
 
  50 import org.openecomp.sdc.be.model.RelationshipImpl;
 
  51 import org.openecomp.sdc.be.model.RelationshipInfo;
 
  52 import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
 
  53 import org.openecomp.sdc.be.model.RequirementDefinition;
 
  54 import org.openecomp.sdc.be.model.Resource;
 
  55 import org.openecomp.sdc.be.model.Service;
 
  56 import org.openecomp.sdc.be.model.User;
 
  57 import org.openecomp.sdc.be.model.jsontitan.operations.ForwardingPathOperation;
 
  58 import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
 
  59 import org.openecomp.sdc.be.model.operations.api.IComponentInstanceOperation;
 
  60 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
 
  61 import org.openecomp.sdc.be.model.operations.impl.ArtifactOperation;
 
  62 import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
 
  63 import org.openecomp.sdc.be.user.UserBusinessLogic;
 
  64 import org.openecomp.sdc.exception.ResponseFormat;
 
  65 import org.openecomp.sdc.common.datastructure.Wrapper;
 
  67 import fj.data.Either;
 
  68 import javassist.CodeConverter.ArrayAccessReplacementMethodNames;
 
  69 import mockit.Deencapsulation;
 
  74  * The test suite designed for test functionality of
 
  75  * ComponentInstanceBusinessLogic class
 
  77 public class ComponentInstanceBusinessLogicTest {
 
  79         private final static String USER_ID = "jh0003";
 
  80         private final static String COMPONENT_ID = "componentId";
 
  81         private final static String TO_INSTANCE_ID = "toInstanceId";
 
  82         private final static String FROM_INSTANCE_ID = "fromInstanceId";
 
  83         private final static String RELATION_ID = "relationId";
 
  84         private final static String CAPABILITY_OWNER_ID = "capabilityOwnerId";
 
  85         private final static String CAPABILITY_UID = "capabilityUid";
 
  86         private final static String CAPABILITY_NAME = "capabilityName";
 
  87         private final static String REQUIREMENT_OWNER_ID = "requirementOwnerId";
 
  88         private final static String REQUIREMENT_UID = "requirementUid";
 
  89         private final static String REQUIREMENT_NAME = "requirementName";
 
  90         private final static String RELATIONSHIP_TYPE = "relationshipType";
 
  92         private static ComponentsUtils componentsUtils;
 
  93         private static ServletUtils servletUtils;
 
  94         private static ResponseFormat responseFormat;
 
  95         private static ToscaOperationFacade toscaOperationFacade;
 
  96         private static IComponentInstanceOperation componentInstanceOperation;
 
  97         private static UserBusinessLogic userAdmin;
 
  99         private static ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
 
 100         private static ForwardingPathOperation forwardingPathOperation;
 
 101         private static User user;
 
 102         private static UserValidations userValidations;
 
 103         private static Component service;
 
 104         private static Component resource;
 
 105         private static ComponentInstance toInstance;
 
 106         private static ComponentInstance fromInstance;
 
 107         private static CapabilityDataDefinition capability;
 
 108         private static RequirementDataDefinition requirement;
 
 109         private static RequirementCapabilityRelDef relation;
 
 110         private static BaseBusinessLogic baseBusinessLogic;
 
 111         private static ArtifactsBusinessLogic artifactsBusinessLogic;
 
 112         private static ToscaDataDefinition toscaDataDefinition;
 
 120                 MockitoAnnotations.initMocks(this);
 
 124         public void testGetRelationByIdSuccess() {
 
 125                 getServiceRelationByIdSuccess(service);
 
 126                 getServiceRelationByIdSuccess(resource);
 
 130         public void testGetRelationByIdUserValidationFailure() {
 
 131                 getServiceRelationByIdUserValidationFailure(service);
 
 132                 getServiceRelationByIdUserValidationFailure(resource);
 
 136         public void testGetRelationByIdComponentNotFoundFailure() {
 
 137                 getRelationByIdComponentNotFoundFailure(service);
 
 138                 getRelationByIdComponentNotFoundFailure(resource);
 
 143         public void testForwardingPathOnVersionChange() {
 
 144                 getforwardingPathOnVersionChange();
 
 147         private void getforwardingPathOnVersionChange() {
 
 148                 String containerComponentParam = "services";
 
 149                 String containerComponentID = "121-cont";
 
 150                 String componentInstanceID = "121-cont-1-comp";
 
 151                 Service component = new Service();
 
 152                 Map<String, ForwardingPathDataDefinition> forwardingPaths = generateForwardingPath(componentInstanceID);
 
 154                 // Add existing componentInstance to component
 
 155                 List<ComponentInstance> componentInstanceList = new ArrayList<>();
 
 156                 ComponentInstance oldComponentInstance = new ComponentInstance();
 
 157                 oldComponentInstance.setName("OLD_COMP_INSTANCE");
 
 158                 oldComponentInstance.setUniqueId(componentInstanceID);
 
 159                 oldComponentInstance.setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_UID, "1-comp");
 
 160                 componentInstanceList.add(oldComponentInstance);
 
 161                 component.setComponentInstances(componentInstanceList);
 
 162                 component.setForwardingPaths(forwardingPaths);
 
 164                 List<ComponentInstance> componentInstanceListNew = new ArrayList<>();
 
 165                 ComponentInstance newComponentInstance = new ComponentInstance();
 
 166                 String new_Comp_UID = "2-comp";
 
 167                 newComponentInstance.setToscaPresentationValue(JsonPresentationFields.CI_COMPONENT_UID, new_Comp_UID);
 
 168                 newComponentInstance.setUniqueId(new_Comp_UID);
 
 169                 componentInstanceListNew.add(newComponentInstance);
 
 170                 Component component2 = new Service();
 
 171                 component2.setComponentInstances(componentInstanceListNew);
 
 173                 // Mock for getting component
 
 174                 when(toscaOperationFacade.getToscaElement(eq(containerComponentID), any(ComponentParametersView.class)))
 
 175                                 .thenReturn(Either.left(component));
 
 176                 when(toscaOperationFacade.validateComponentExists(any(String.class))).thenReturn(Either.left(Boolean.TRUE));
 
 177                 // Mock for getting component for componentInstance
 
 178                 when(toscaOperationFacade.getToscaFullElement(eq("1-comp"))).thenReturn(Either.left(component));
 
 179                 when(toscaOperationFacade.getToscaFullElement(eq(new_Comp_UID))).thenReturn(Either.left(component2));
 
 181                 Either<Set<String>, ResponseFormat> resultOp = componentInstanceBusinessLogic.forwardingPathOnVersionChange(
 
 182                                 containerComponentParam, containerComponentID, componentInstanceID, newComponentInstance);
 
 183                 Assert.assertEquals(1, resultOp.left().value().size());
 
 184                 Assert.assertEquals("FP-ID-1", resultOp.left().value().iterator().next());
 
 189         public void testDeleteForwardingPathsWhenComponentinstanceDeleted() {
 
 191                 ComponentTypeEnum containerComponentType = ComponentTypeEnum.findByParamName("services");
 
 192                 String containerComponentID = "Service-comp";
 
 193                 String componentInstanceID = "NodeA1";
 
 194                 Service component = new Service();
 
 196                 component.addForwardingPath(createPath("path1", "NodeA1", "NodeB1", "1"));
 
 197                 component.addForwardingPath(createPath("Path2", "NodeA2", "NodeB2", "2"));
 
 198                 when(toscaOperationFacade.getToscaElement(eq(containerComponentID), any(ComponentParametersView.class)))
 
 199                                 .thenReturn(Either.left(component));
 
 200                 when(toscaOperationFacade.getToscaElement(eq(containerComponentID))).thenReturn(Either.left(component));
 
 201                 when(forwardingPathOperation.deleteForwardingPath(any(Service.class), anySet()))
 
 202                                 .thenReturn(Either.left(new HashSet<>()));
 
 203                 Either<ComponentInstance, ResponseFormat> responseFormatEither = componentInstanceBusinessLogic
 
 204                                 .deleteForwardingPathsRelatedTobeDeletedComponentInstance(containerComponentID, componentInstanceID,
 
 205                                                 containerComponentType, Either.left(new ComponentInstance()));
 
 206                 Assert.assertTrue(responseFormatEither.isLeft());
 
 211         public void testDeleteForwardingPathsWhenErrorInComponentinstanceDelete() {
 
 213                 ComponentTypeEnum containerComponentType = ComponentTypeEnum.findByParamName("services");
 
 214                 String containerComponentID = "Service-comp";
 
 215                 String componentInstanceID = "NodeA1";
 
 216                 Service component = new Service();
 
 218                 component.addForwardingPath(createPath("path1", "NodeA1", "NodeB1", "1"));
 
 219                 component.addForwardingPath(createPath("Path2", "NodeA2", "NodeB2", "2"));
 
 220                 when(toscaOperationFacade.getToscaElement(eq(containerComponentID), any(ComponentParametersView.class)))
 
 221                                 .thenReturn(Either.left(component));
 
 222                 when(toscaOperationFacade.getToscaElement(eq(containerComponentID))).thenReturn(Either.left(component));
 
 223                 when(forwardingPathOperation.deleteForwardingPath(any(Service.class), anySet()))
 
 224                                 .thenReturn(Either.left(new HashSet<>()));
 
 225                 Either<ComponentInstance, ResponseFormat> responseFormatEither = componentInstanceBusinessLogic
 
 226                                 .deleteForwardingPathsRelatedTobeDeletedComponentInstance(containerComponentID, componentInstanceID,
 
 227                                                 containerComponentType, Either.right(new ResponseFormat()));
 
 228                 Assert.assertTrue(responseFormatEither.isRight());
 
 232         private ForwardingPathDataDefinition createPath(String pathName, String fromNode, String toNode, String uniqueId) {
 
 233                 ForwardingPathDataDefinition forwardingPath = new ForwardingPathDataDefinition(pathName);
 
 234                 forwardingPath.setProtocol("protocol");
 
 235                 forwardingPath.setDestinationPortNumber("port");
 
 236                 forwardingPath.setUniqueId(uniqueId);
 
 237                 ListDataDefinition<ForwardingPathElementDataDefinition> forwardingPathElementListDataDefinition = new ListDataDefinition<>();
 
 238                 forwardingPathElementListDataDefinition.add(new ForwardingPathElementDataDefinition(fromNode, toNode,
 
 239                                 "nodeAcpType", "nodeBcpType", "nodeDcpName", "nodeBcpName"));
 
 240                 forwardingPath.setPathElements(forwardingPathElementListDataDefinition);
 
 242                 return forwardingPath;
 
 245         private Map<String, ForwardingPathDataDefinition> generateForwardingPath(String componentInstanceID) {
 
 246                 ForwardingPathDataDefinition forwardingPath = new ForwardingPathDataDefinition("fpName");
 
 247                 String protocol = "protocol";
 
 248                 forwardingPath.setProtocol(protocol);
 
 249                 forwardingPath.setDestinationPortNumber("DestinationPortNumber");
 
 250                 forwardingPath.setUniqueId("FP-ID-1");
 
 251                 ListDataDefinition<ForwardingPathElementDataDefinition> forwardingPathElementListDataDefinition = new ListDataDefinition<>();
 
 252                 forwardingPathElementListDataDefinition.add(new ForwardingPathElementDataDefinition(componentInstanceID,
 
 253                                 "nodeB", "nodeA_FORWARDER_CAPABILITY", "nodeBcpType", "nodeDcpName", "nodeBcpName"));
 
 254                 forwardingPath.setPathElements(forwardingPathElementListDataDefinition);
 
 255                 Map<String, ForwardingPathDataDefinition> forwardingPaths = new HashMap<>();
 
 256                 forwardingPaths.put("1122", forwardingPath);
 
 257                 return forwardingPaths;
 
 260         @SuppressWarnings("unchecked")
 
 261         private void getServiceRelationByIdSuccess(Component component) {
 
 262                 Either<User, ActionStatus> eitherCreator = Either.left(user);
 
 263                 when(userAdmin.getUser(eq(USER_ID), eq(false))).thenReturn(eitherCreator);
 
 264                 Either<Component, StorageOperationStatus> getComponentRes = Either.left(component);
 
 265                 when(toscaOperationFacade.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
 
 266                                 .thenReturn(getComponentRes);
 
 268                 Either<RequirementDataDefinition, StorageOperationStatus> getfulfilledRequirementRes = Either.left(requirement);
 
 269                 when(toscaOperationFacade.getFulfilledRequirementByRelation(eq(COMPONENT_ID), eq(FROM_INSTANCE_ID),
 
 270                                 eq(relation), any(BiPredicate.class))).thenReturn(getfulfilledRequirementRes);
 
 272                 Either<CapabilityDataDefinition, StorageOperationStatus> getfulfilledCapabilityRes = Either.left(capability);
 
 273                 when(toscaOperationFacade.getFulfilledCapabilityByRelation(eq(COMPONENT_ID), eq(FROM_INSTANCE_ID), eq(relation),
 
 274                                 any(BiPredicate.class))).thenReturn(getfulfilledCapabilityRes);
 
 276                 Either<RequirementCapabilityRelDef, ResponseFormat> response = componentInstanceBusinessLogic
 
 277                                 .getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
 
 278                 assertTrue(response.isLeft());
 
 281         private void getServiceRelationByIdUserValidationFailure(Component component) {
 
 282                 // Either<User, ActionStatus> eitherCreator =
 
 283                 // Either.right(ActionStatus.USER_NOT_FOUND);
 
 284                 // when(userAdmin.getUser(eq(USER_ID),
 
 285                 // eq(false))).thenReturn(eitherCreator);
 
 286                 when(userValidations.validateUserExists(eq(USER_ID), eq("get relation by Id"), eq(false)))
 
 287                                 .thenReturn(Either.right(new ResponseFormat(404)));
 
 288                 Either<RequirementCapabilityRelDef, ResponseFormat> response = componentInstanceBusinessLogic
 
 289                                 .getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
 
 290                 assertTrue(response.isRight());
 
 293         private void getRelationByIdComponentNotFoundFailure(Component component) {
 
 294                 Either<User, ActionStatus> eitherCreator = Either.left(user);
 
 295                 when(userAdmin.getUser(eq(USER_ID), eq(false))).thenReturn(eitherCreator);
 
 296                 Either<Component, StorageOperationStatus> getComponentRes = Either.right(StorageOperationStatus.NOT_FOUND);
 
 297                 when(toscaOperationFacade.getToscaElement(eq(COMPONENT_ID), any(ComponentParametersView.class)))
 
 298                                 .thenReturn(getComponentRes);
 
 300                 Either<RequirementCapabilityRelDef, ResponseFormat> response = componentInstanceBusinessLogic
 
 301                                 .getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType());
 
 302                 assertTrue(response.isRight());
 
 305         private static void createMocks() {
 
 306                 componentsUtils = Mockito.mock(ComponentsUtils.class);
 
 307                 servletUtils = Mockito.mock(ServletUtils.class);
 
 308                 responseFormat = Mockito.mock(ResponseFormat.class);
 
 309                 toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
 
 310                 userAdmin = Mockito.mock(UserBusinessLogic.class);
 
 311                 user = Mockito.mock(User.class);
 
 312                 baseBusinessLogic = Mockito.mock(BaseBusinessLogic.class);
 
 313                 userValidations = Mockito.mock(UserValidations.class);
 
 314                 forwardingPathOperation = Mockito.mock(ForwardingPathOperation.class);
 
 315                 componentInstanceOperation = Mockito.mock(IComponentInstanceOperation.class);
 
 316                 artifactsBusinessLogic = Mockito.mock(ArtifactsBusinessLogic.class);
 
 317                 toscaDataDefinition = Mockito.mock(ToscaDataDefinition.class);
 
 320         private static void setMocks() {
 
 321                 componentInstanceBusinessLogic = new ComponentInstanceBusinessLogic();
 
 322                 componentInstanceBusinessLogic.setToscaOperationFacade(toscaOperationFacade);
 
 323                 componentInstanceBusinessLogic.setUserAdmin(userAdmin);
 
 324                 componentInstanceBusinessLogic.setComponentsUtils(componentsUtils);
 
 325                 componentInstanceBusinessLogic.setUserValidations(userValidations);
 
 326                 componentInstanceBusinessLogic.setForwardingPathOperation(forwardingPathOperation);
 
 329         private static void stubMethods() {
 
 330                 when(servletUtils.getComponentsUtils()).thenReturn(componentsUtils);
 
 331                 when(userValidations.validateUserExists(eq(USER_ID), eq("get relation by Id"), eq(false)))
 
 332                                 .thenReturn(Either.left(user));
 
 333                 when(componentsUtils.getResponseFormat(eq(ActionStatus.RELATION_NOT_FOUND), eq(RELATION_ID), eq(COMPONENT_ID)))
 
 334                                 .thenReturn(responseFormat);
 
 335                 Either<User, ActionStatus> eitherGetUser = Either.left(user);
 
 336                 when(userAdmin.getUser("jh0003", false)).thenReturn(eitherGetUser);
 
 337                 when(userValidations.validateUserExists(eq(user.getUserId()), anyString(), eq(false)))
 
 338                                 .thenReturn(Either.left(user));
 
 341         private static void createComponents() {
 
 348         private static Component createResource() {
 
 349                 resource = new Resource();
 
 350                 resource.setUniqueId(COMPONENT_ID);
 
 351                 resource.setComponentInstancesRelations(Lists.newArrayList(relation));
 
 352                 resource.setComponentInstances(Lists.newArrayList(toInstance, fromInstance));
 
 353                 resource.setCapabilities(toInstance.getCapabilities());
 
 354                 resource.setRequirements(fromInstance.getRequirements());
 
 355                 resource.setComponentType(ComponentTypeEnum.RESOURCE);
 
 359         private static Component createService() {
 
 360                 service = new Service();
 
 361                 service.setUniqueId(COMPONENT_ID);
 
 362                 service.setComponentInstancesRelations(Lists.newArrayList(relation));
 
 363                 service.setComponentInstances(Lists.newArrayList(toInstance, fromInstance));
 
 364                 service.setCapabilities(toInstance.getCapabilities());
 
 365                 service.setRequirements(fromInstance.getRequirements());
 
 366                 service.setComponentType(ComponentTypeEnum.SERVICE);
 
 370         private static ComponentInstance createInstances() {
 
 371                 toInstance = new ComponentInstance();
 
 372                 toInstance.setUniqueId(TO_INSTANCE_ID);
 
 373                 toInstance.setComponentUid("uuuiiid");
 
 374                 toInstance.setName("tests");
 
 376                 fromInstance = new ComponentInstance();
 
 377                 fromInstance.setUniqueId(FROM_INSTANCE_ID);
 
 379                 capability = new CapabilityDataDefinition();
 
 380                 capability.setOwnerId(CAPABILITY_OWNER_ID);
 
 381                 capability.setUniqueId(CAPABILITY_UID);
 
 382                 capability.setName(CAPABILITY_NAME);
 
 384                 Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
 
 385                 capabilities.put(capability.getName(), Lists.newArrayList(new CapabilityDefinition(capability)));
 
 387                 requirement = new RequirementDataDefinition();
 
 388                 requirement.setOwnerId(REQUIREMENT_OWNER_ID);
 
 389                 requirement.setUniqueId(REQUIREMENT_UID);
 
 390                 requirement.setName(REQUIREMENT_NAME);
 
 391                 requirement.setRelationship(RELATIONSHIP_TYPE);
 
 393                 Map<String, List<RequirementDefinition>> requirements = new HashMap<>();
 
 394                 requirements.put(requirement.getCapability(), Lists.newArrayList(new RequirementDefinition(requirement)));
 
 396                 toInstance.setCapabilities(capabilities);
 
 397                 fromInstance.setRequirements(requirements);
 
 401         private static void createRelation() {
 
 403                 relation = new RequirementCapabilityRelDef();
 
 404                 CapabilityRequirementRelationship relationship = new CapabilityRequirementRelationship();
 
 405                 RelationshipInfo relationInfo = new RelationshipInfo();
 
 406                 relationInfo.setId(RELATION_ID);
 
 407                 relationship.setRelation(relationInfo);
 
 409                 relation.setRelationships(Lists.newArrayList(relationship));
 
 410                 relation.setToNode(TO_INSTANCE_ID);
 
 411                 relation.setFromNode(FROM_INSTANCE_ID);
 
 413                 relationInfo.setCapabilityOwnerId(CAPABILITY_OWNER_ID);
 
 414                 relationInfo.setCapabilityUid(CAPABILITY_UID);
 
 415                 relationInfo.setCapability(CAPABILITY_NAME);
 
 416                 relationInfo.setRequirementOwnerId(REQUIREMENT_OWNER_ID);
 
 417                 relationInfo.setRequirementUid(REQUIREMENT_UID);
 
 418                 relationInfo.setRequirement(REQUIREMENT_NAME);
 
 419                 RelationshipImpl relationshipImpl = new RelationshipImpl();
 
 420                 relationshipImpl.setType(RELATIONSHIP_TYPE);
 
 421                 relationInfo.setRelationships(relationshipImpl);
 
 424         ///////////////////////////////////////////////////////////////////////////////
 
 425         /////////////////////////////new test//////////////////////////////////////////
 
 426         ///////////////////////////////////////////////////////////////////////////////
 
 429         private ComponentInstanceBusinessLogic createTestSubject() {
 
 430                         return componentInstanceBusinessLogic;
 
 438         public void testChangeServiceProxyVersion() throws Exception {
 
 439                 ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
 
 440                 String containerComponentType = "";
 
 441                 String containerComponentId = "";
 
 442                 String serviceProxyId = "";
 
 443                 String userId = user.getUserId();
 
 444                 Either<ComponentInstance, ResponseFormat> result;
 
 447                 componentInstanceBusinessLogic = createTestSubject();
 
 448                 result = componentInstanceBusinessLogic.changeServiceProxyVersion(containerComponentType, containerComponentId, serviceProxyId,
 
 459         public void testCreateServiceProxy() throws Exception {
 
 460                 ComponentInstanceBusinessLogic testSubject;
 
 461                 String containerComponentType = "";
 
 462                 String containerComponentId = "";
 
 463                 String userId = user.getUserId();
 
 464                 ComponentInstance componentInstance = createInstances();
 
 465                 Either<ComponentInstance, ResponseFormat> result;
 
 468                 testSubject = createTestSubject();
 
 469                 result = testSubject.createServiceProxy(containerComponentType, containerComponentId, userId,
 
 478         public void testDeleteForwardingPathsRelatedTobeDeletedComponentInstance() throws Exception {
 
 479                 ComponentInstanceBusinessLogic testSubject;
 
 480                 String containerComponentId = "";
 
 481                 String componentInstanceId = "";
 
 482                 ComponentTypeEnum containerComponentType = ComponentTypeEnum.RESOURCE;
 
 483                 Either<ComponentInstance, ResponseFormat> resultOp = null;
 
 484                 Either<ComponentInstance, ResponseFormat> result;
 
 487                 testSubject = createTestSubject();
 
 488                 result = testSubject.deleteForwardingPathsRelatedTobeDeletedComponentInstance(containerComponentId,
 
 489                                 componentInstanceId, containerComponentType, resultOp);
 
 494         public void testDeleteServiceProxy() throws Exception {
 
 495                 ComponentInstanceBusinessLogic testSubject;
 
 496                 String containerComponentType = "";
 
 497                 String containerComponentId = "";
 
 498                 String serviceProxyId = "";
 
 499                 String userId = user.getUserId();
 
 500                 Either<ComponentInstance, ResponseFormat> result;
 
 503                 testSubject = createTestSubject();
 
 504                 result = testSubject.deleteServiceProxy(containerComponentType, containerComponentId, serviceProxyId, userId);
 
 513         public void testGetComponentInstanceInputsByInputId() throws Exception {
 
 514                 ComponentInstanceBusinessLogic testSubject;
 
 515                 Component component = new Service();
 
 517                 List<ComponentInstanceInput> result;
 
 520                 testSubject = createTestSubject();
 
 521                 result = testSubject.getComponentInstanceInputsByInputId(component, inputId);
 
 527         public void testGetComponentInstancePropertiesByInputId() throws Exception {
 
 528                 ComponentInstanceBusinessLogic testSubject;
 
 529                 Component component = new Service();
 
 531                 List<ComponentInstanceProperty> result;
 
 534                 testSubject = createTestSubject();
 
 535                 result = testSubject.getComponentInstancePropertiesByInputId(component, inputId);
 
 540         public void testGetRelationById() throws Exception {
 
 541                 ComponentInstanceBusinessLogic testSubject;
 
 542                 String componentId = "";
 
 543                 String relationId = "";
 
 544                 String userId = user.getUserId();
 
 545                 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE_INSTANCE;
 
 546                 Either<RequirementCapabilityRelDef, ResponseFormat> result;
 
 549                 testSubject = createTestSubject();
 
 550                 result = testSubject.getRelationById(componentId, relationId, userId, componentTypeEnum);
 
 558         public void testCreateComponentInstance_1() throws Exception {
 
 559         ComponentInstanceBusinessLogic testSubject;String containerComponentParam = "";
 
 560         String containerComponentId = "";
 
 561         String userId = user.getUserId();
 
 562         ComponentInstance resourceInstance = null;
 
 563         boolean inTransaction = false;
 
 564         boolean needLock = false;
 
 565         Either<ComponentInstance,ResponseFormat> result;
 
 568         testSubject=createTestSubject();result=testSubject.createComponentInstance(containerComponentParam, containerComponentId, userId, resourceInstance, inTransaction, needLock);
 
 576         public void testCreateAndAssociateRIToRI() throws Exception {
 
 577         ComponentInstanceBusinessLogic testSubject;
 
 579         String containerComponentParam = "";
 
 580         String containerComponentId = "";
 
 581         String userId = user.getUserId();
 
 582         CreateAndAssotiateInfo createAndAssotiateInfo = new CreateAndAssotiateInfo(null, null);
 
 583         Either<CreateAndAssotiateInfo,ResponseFormat> result;
 
 586         testSubject=createTestSubject();result=testSubject.createAndAssociateRIToRI(containerComponentParam, containerComponentId, userId, createAndAssotiateInfo);
 
 590         public void testGetOriginComponentFromComponentInstance_1() throws Exception {
 
 591         ComponentInstanceBusinessLogic testSubject;
 
 592         Component compoent = createResource();
 
 593         String componentInstanceName = "";
 
 594         String origComponetId = compoent.getUniqueId();
 
 595         Either<Component, StorageOperationStatus> oldResourceRes = Either.left(compoent);
 
 596         when(toscaOperationFacade.getToscaFullElement(compoent.getUniqueId())).thenReturn(oldResourceRes);
 
 597         Either<Component,ResponseFormat> result;
 
 600         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getOriginComponentFromComponentInstance", new Object[]{componentInstanceName, origComponetId});
 
 605         public void testCreateComponentInstanceOnGraph() throws Exception {
 
 606         ComponentInstanceBusinessLogic testSubject;
 
 607         Component containerComponent = createResource();
 
 608         Component originComponent = null;
 
 609         ComponentInstance componentInstance = createInstances();
 
 610         Either<ComponentInstance,ResponseFormat> result;
 
 612         Either<ImmutablePair<Component, String>, StorageOperationStatus> result2 = Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND);
 
 613         when(toscaOperationFacade.addComponentInstanceToTopologyTemplate(containerComponent, containerComponent,componentInstance, false, user)).thenReturn(result2);
 
 616         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createComponentInstanceOnGraph", new Object[]{containerComponent, containerComponent, componentInstance, user});
 
 620         public void testCreateComponentInstanceOnGraph2() throws Exception {
 
 621         ComponentInstanceBusinessLogic testSubject;
 
 622         Component containerComponent = createResource();
 
 623         containerComponent.setName("name");
 
 624         ComponentInstance componentInstance = createInstances();
 
 625         Either<ComponentInstance,ResponseFormat> result;
 
 626         ImmutablePair<Component, String> pair =  new ImmutablePair<>(containerComponent,"");
 
 631         Either<ImmutablePair<Component, String>, StorageOperationStatus> result2 = Either.left(pair);
 
 632         when(toscaOperationFacade.addComponentInstanceToTopologyTemplate(containerComponent, containerComponent,componentInstance, false, user)).thenReturn(result2);
 
 635         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createComponentInstanceOnGraph", new Object[]{containerComponent, containerComponent, componentInstance, user});
 
 639         public void testUpdateComponentInstanceMetadata() throws Exception {
 
 640         ComponentInstanceBusinessLogic testSubject;
 
 641         String containerComponentParam = "";
 
 642         String containerComponentId = "";
 
 643         String componentInstanceId = "";
 
 644         String userId = user.getUserId();
 
 645         ComponentInstance componentInstance = createInstances();
 
 646         Either<ComponentInstance,ResponseFormat> result;
 
 649         testSubject=createTestSubject();result=testSubject.updateComponentInstanceMetadata(containerComponentParam, containerComponentId, componentInstanceId, userId, componentInstance);
 
 654         public void testUpdateComponentInstanceMetadata_1() throws Exception {
 
 655         ComponentInstanceBusinessLogic testSubject;String containerComponentParam = "";
 
 656         String containerComponentId = "";
 
 657         String componentInstanceId = "";
 
 658         String userId = user.getUserId();
 
 659         ComponentInstance componentInstance = createInstances();
 
 660         boolean inTransaction = false;
 
 661         boolean needLock = false;
 
 662         boolean createNewTransaction = false;
 
 663         Either<ComponentInstance,ResponseFormat> result;
 
 666         testSubject=createTestSubject();result=testSubject.updateComponentInstanceMetadata(containerComponentParam, containerComponentId, componentInstanceId, userId, componentInstance, inTransaction, needLock, createNewTransaction);
 
 674         public void testValidateParent() throws Exception {
 
 675         ComponentInstanceBusinessLogic testSubject;
 
 676         Component containerComponent = createResource();
 
 677         String nodeTemplateId = "";
 
 681         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateParent", new Object[]{containerComponent, nodeTemplateId});
 
 686         public void testGetComponentType() throws Exception {
 
 687         ComponentInstanceBusinessLogic testSubject;
 
 688         ComponentTypeEnum containerComponentType = ComponentTypeEnum.RESOURCE;
 
 689         ComponentTypeEnum result;
 
 692         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getComponentType", new Object[]{ComponentTypeEnum.class});
 
 698         public void testGetNewGroupName() throws Exception {
 
 699         ComponentInstanceBusinessLogic testSubject;String oldPrefix = "";
 
 700         String newNormailzedPrefix = "";
 
 701         String qualifiedGroupInstanceName = "";
 
 705         testSubject=createTestSubject();
 
 706         result=Deencapsulation.invoke(testSubject, "getNewGroupName", new Object[]{oldPrefix, newNormailzedPrefix, qualifiedGroupInstanceName});
 
 711         public void testUpdateComponentInstanceMetadata_3() throws Exception {
 
 712         ComponentInstanceBusinessLogic testSubject;
 
 713         ComponentInstance oldComponentInstance = createInstances();
 
 714         ComponentInstance newComponentInstance = null;
 
 715         ComponentInstance result;
 
 718         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "updateComponentInstanceMetadata", new Object[]{oldComponentInstance, oldComponentInstance});
 
 723         public void testDeleteComponentInstance() throws Exception {
 
 724         ComponentInstanceBusinessLogic testSubject;String containerComponentParam = "";
 
 725         String containerComponentId = "";
 
 726         String componentInstanceId = "";
 
 727         String userId = user.getUserId();
 
 728         Either<ComponentInstance,ResponseFormat> result;
 
 731         testSubject=createTestSubject();result=testSubject.deleteComponentInstance(containerComponentParam, containerComponentId, componentInstanceId, userId);
 
 736         public void testDeleteForwardingPaths() throws Exception {
 
 737         ComponentInstanceBusinessLogic testSubject;
 
 738         Component service = createService();
 
 739         String serviceId = service.getUniqueId();
 
 740         List<String> pathIdsToDelete = new ArrayList<>();
 
 741         Either<Set<String>,ResponseFormat> result;
 
 743 //      Either<Service, StorageOperationStatus> storageStatus = toscaOperationFacade.getToscaElement(serviceId);
 
 744         when(toscaOperationFacade.getToscaElement(serviceId)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
 
 747         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "deleteForwardingPaths", new Object[]{serviceId, pathIdsToDelete});
 
 752         public void testAssociateRIToRIOnGraph() throws Exception {
 
 753         ComponentInstanceBusinessLogic testSubject;
 
 754         Component containerComponent = createResource();
 
 755         RequirementCapabilityRelDef requirementDef = new RequirementCapabilityRelDef();
 
 756         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
 
 757         boolean inTransaction = false;
 
 758         Either<RequirementCapabilityRelDef,ResponseFormat> result;
 
 762         Either<RequirementCapabilityRelDef, StorageOperationStatus> getResourceResult = Either.left(requirementDef);
 
 763         when(toscaOperationFacade.associateResourceInstances(containerComponent.getUniqueId(), requirementDef)).thenReturn(getResourceResult);
 
 766         testSubject=createTestSubject();result=testSubject.associateRIToRIOnGraph(containerComponent, requirementDef, componentTypeEnum, inTransaction);
 
 772         public void testFindRelation() throws Exception {
 
 773         ComponentInstanceBusinessLogic testSubject;
 
 774         String relationId = "";
 
 775         List<RequirementCapabilityRelDef> requirementCapabilityRelations = new ArrayList<>();
 
 776         RequirementCapabilityRelDef result;
 
 779         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "findRelation", new Object[]{relationId, requirementCapabilityRelations});
 
 784         public void testIsNetworkRoleServiceProperty() throws Exception {
 
 785         ComponentInstanceBusinessLogic testSubject;
 
 786         ComponentInstanceProperty property = new ComponentInstanceProperty();
 
 787         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
 
 791         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "isNetworkRoleServiceProperty", new Object[]{property, componentTypeEnum});
 
 796         public void testConcatServiceNameToVLINetworkRolePropertiesValues() throws Exception {
 
 797         ComponentInstanceBusinessLogic testSubject;
 
 798         ToscaOperationFacade toscaOperationFacade = new ToscaOperationFacade();
 
 799         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
 
 800         String componentId = "";
 
 801         String resourceInstanceId = "";
 
 802         List<ComponentInstanceProperty> properties = new ArrayList<>();
 
 803         StorageOperationStatus result;
 
 806         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "concatServiceNameToVLINetworkRolePropertiesValues", new Object[]{toscaOperationFacade, componentTypeEnum, componentId, resourceInstanceId, properties});
 
 811         public void testCreateOrUpdatePropertiesValues() throws Exception {
 
 812         ComponentInstanceBusinessLogic testSubject;
 
 813         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
 
 814         Component component = createResource();
 
 815         String componentId = component.getUniqueId();
 
 816         String resourceInstanceId = "";
 
 817         List<ComponentInstanceProperty> properties = new ArrayList<>();
 
 818         String userId = user.getUserId();
 
 819         Either<List<ComponentInstanceProperty>,ResponseFormat> result;
 
 821 //      Either<Component, StorageOperationStatus> getResourceResult = toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll);
 
 822         when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(component));
 
 825         testSubject=createTestSubject();
 
 826         result=testSubject.createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties, userId);
 
 828         componentTypeEnum =null;
 
 829         result=testSubject.createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties, userId);
 
 831         when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
 
 832         result=testSubject.createOrUpdatePropertiesValues(componentTypeEnum, componentId, resourceInstanceId, properties, userId);
 
 838         public void testUpdateCapabilityPropertyOnContainerComponent() throws Exception {
 
 839         ComponentInstanceBusinessLogic testSubject;
 
 840         ComponentInstanceProperty property = new ComponentInstanceProperty();
 
 841         String newValue = "";
 
 842         Component containerComponent = createResource();
 
 843         ComponentInstance foundResourceInstance = createInstances();
 
 844         String capabilityType = "";
 
 845         String capabilityName = "";
 
 846         ResponseFormat result;
 
 849         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "updateCapabilityPropertyOnContainerComponent", new Object[]{property, newValue, containerComponent, foundResourceInstance, capabilityType, capabilityName});
 
 855         public void testCreateOrUpdateInstanceInputValues() throws Exception {
 
 856         ComponentInstanceBusinessLogic testSubject;
 
 857         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
 
 858         Component resource = createResource();
 
 859         String componentId = resource.getUniqueId();
 
 860         String resourceInstanceId = "";
 
 861         List<ComponentInstanceInput> inputs = new ArrayList<>();
 
 862         String userId = user.getUserId();
 
 863         Either<List<ComponentInstanceInput>,ResponseFormat> result;
 
 865          when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.left(resource));
 
 868         testSubject=createTestSubject();
 
 869         result=testSubject.createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs, userId);
 
 870         componentTypeEnum =null;
 
 871         result=testSubject.createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs, userId);
 
 874          when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseAll)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
 
 875          result=testSubject.createOrUpdateInstanceInputValues(componentTypeEnum, componentId, resourceInstanceId, inputs, userId);
 
 881         public void testCreateOrUpdateGroupInstancePropertyValue() throws Exception {
 
 882         ComponentInstanceBusinessLogic testSubject;
 
 883         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
 
 884         Component resource = createResource();
 
 885         String componentId = resource.getUniqueId();
 
 886         String resourceInstanceId = "";
 
 887         String groupInstanceId = "";
 
 888         ComponentInstanceProperty property = new ComponentInstanceProperty();
 
 889         String userId = user.getUserId();
 
 890         Either<ComponentInstanceProperty,ResponseFormat> result;
 
 893          when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.left(resource));
 
 896         testSubject=createTestSubject();
 
 897         result=testSubject.createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId, groupInstanceId, property, userId);
 
 898         componentTypeEnum = null;
 
 899         result=testSubject.createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId, groupInstanceId, property, userId);
 
 901          when(toscaOperationFacade.getToscaElement(componentId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
 
 902          result=testSubject.createOrUpdateGroupInstancePropertyValue(componentTypeEnum, componentId, resourceInstanceId, groupInstanceId, property, userId);
 
 907         public void testCreateOrUpdateInputValue() throws Exception {
 
 908         ComponentInstanceBusinessLogic testSubject;
 
 909         Component component = createResource();
 
 910         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
 
 911         String componentId = component.getUniqueId();
 
 912         String resourceInstanceId = component.getUniqueId();
 
 913         ComponentInstanceInput inputProperty = new ComponentInstanceInput();
 
 914         String userId = user.getUserId();
 
 915         Either<ComponentInstanceInput,ResponseFormat> result;
 
 918         Either<Component, StorageOperationStatus> getResourceResult = Either.left(component);
 
 919         when(toscaOperationFacade.getToscaElement(component.getUniqueId(), JsonParseFlagEnum.ParseMetadata)).thenReturn(getResourceResult);
 
 922         testSubject=createTestSubject();
 
 923         result=testSubject.createOrUpdateInputValue(componentTypeEnum, componentId, resourceInstanceId, inputProperty, userId);
 
 925         componentTypeEnum = null;
 
 926         result=testSubject.createOrUpdateInputValue(componentTypeEnum, componentId, resourceInstanceId, inputProperty, userId);
 
 928         when(toscaOperationFacade.getToscaElement(component.getUniqueId(), JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
 
 929         result=testSubject.createOrUpdateInputValue(componentTypeEnum, componentId, resourceInstanceId, inputProperty, userId);                 
 
 934         public void testDeletePropertyValue() throws Exception {
 
 935         ComponentInstanceBusinessLogic testSubject;
 
 936         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
 
 937         Component service = createService();
 
 938         String serviceId = service.getUniqueId();
 
 939         String resourceInstanceId = "";
 
 940         String propertyValueId = "";
 
 941         String userId = user.getUserId();
 
 942         Either<ComponentInstanceProperty,ResponseFormat> result;
 
 944          when(toscaOperationFacade.getToscaElement(serviceId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.left(service));
 
 947         testSubject=createTestSubject();
 
 948         result=testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId, userId);
 
 949         componentTypeEnum= null;
 
 950         result=testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId, userId);
 
 952          when(toscaOperationFacade.getToscaElement(serviceId, JsonParseFlagEnum.ParseMetadata)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
 
 953         result=testSubject.deletePropertyValue(componentTypeEnum, serviceId, resourceInstanceId, propertyValueId, userId);
 
 958         public void testGetAndValidateOriginComponentOfComponentInstance() throws Exception {
 
 959         ComponentInstanceBusinessLogic testSubject;
 
 960         ComponentTypeEnum containerComponentType = ComponentTypeEnum.RESOURCE;
 
 961         Component resource = createResource();
 
 962         ComponentInstance componentInstance = createInstances();
 
 963         Either<Component,ResponseFormat> result;
 
 965          when(toscaOperationFacade.getToscaFullElement(componentInstance.getComponentUid())).thenReturn(Either.left(resource));
 
 968         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getAndValidateOriginComponentOfComponentInstance", new Object[]{containerComponentType, componentInstance});
 
 976         public void testGetComponentParametersViewForForwardingPath() throws Exception {
 
 977         ComponentInstanceBusinessLogic testSubject;
 
 978         ComponentParametersView result;
 
 981         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getComponentParametersViewForForwardingPath");
 
 986         public void testChangeComponentInstanceVersion() throws Exception {
 
 987         ComponentInstanceBusinessLogic testSubject;
 
 988         String containerComponentParam = "";
 
 989         String containerComponentId = "";
 
 990         String componentInstanceId = "";
 
 991         String userId = user.getUserId();
 
 992         ComponentInstance newComponentInstance = createInstances();
 
 993         Either<ComponentInstance,ResponseFormat> result;
 
 996         testSubject=createTestSubject();result=testSubject.changeComponentInstanceVersion(containerComponentParam, containerComponentId, componentInstanceId, userId, newComponentInstance);
 
 997         newComponentInstance = null;
 
 998         testSubject=createTestSubject();result=testSubject.changeComponentInstanceVersion(containerComponentParam, containerComponentId, componentInstanceId, userId, newComponentInstance);
 
1003         public void testValidateInstanceNameUniquenessUponUpdate() throws Exception {
 
1004         ComponentInstanceBusinessLogic testSubject;
 
1005         Component containerComponent = createResource();
 
1006         ComponentInstance oldComponentInstance = createInstances();
 
1007         String newInstanceName = oldComponentInstance.getName();
 
1011         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateInstanceNameUniquenessUponUpdate", new Object[]{containerComponent, oldComponentInstance, newInstanceName});
 
1016         public void testGetResourceInstanceById() throws Exception {
 
1017         ComponentInstanceBusinessLogic testSubject;
 
1018         Component containerComponent = createResource();
 
1019         String instanceId = "";
 
1020         Either<ComponentInstance,StorageOperationStatus> result;
 
1023         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getResourceInstanceById", new Object[]{containerComponent, instanceId});
 
1028         public void testBuildComponentInstance() throws Exception {
 
1029         ComponentInstanceBusinessLogic testSubject;
 
1030         ComponentInstance resourceInstanceForUpdate = createInstances();
 
1031         ComponentInstance origInstanceForUpdate = null;
 
1032         ComponentInstance result;
 
1035         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "buildComponentInstance", new Object[]{resourceInstanceForUpdate, resourceInstanceForUpdate});
 
1043         public void testFindCapabilityOfInstance() throws Exception {
 
1044         ComponentInstanceBusinessLogic testSubject;String componentId = "";
 
1045         String instanceId = "";
 
1046         String capabilityType = "";
 
1047         String capabilityName = "";
 
1048         String ownerId = "";
 
1049         Map<String,List<CapabilityDefinition>> instanceCapabilities = new HashMap<>();
 
1050         Either<List<ComponentInstanceProperty>,ResponseFormat> result;
 
1053         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "findCapabilityOfInstance", new Object[]{componentId, instanceId, capabilityType, capabilityName, ownerId, instanceCapabilities});
 
1058         public void testFetchComponentInstanceCapabilityProperties() throws Exception {
 
1059         ComponentInstanceBusinessLogic testSubject;String componentId = "";
 
1060         String instanceId = "";
 
1061         String capabilityType = "";
 
1062         String capabilityName = "";
 
1063         String ownerId = "";
 
1064         Either<List<ComponentInstanceProperty>,ResponseFormat> result;
 
1067         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "fetchComponentInstanceCapabilityProperties", new Object[]{componentId, instanceId, capabilityType, capabilityName, ownerId});
 
1072         public void testUpdateCapabilityPropertyOnContainerComponent_1() throws Exception {
 
1073         ComponentInstanceBusinessLogic testSubject;
 
1074         ComponentInstanceProperty property = new ComponentInstanceProperty();
 
1075         String newValue = "";
 
1076         Component containerComponent = createResource();
 
1077         ComponentInstance foundResourceInstance = createInstances();
 
1078         String capabilityType = "";
 
1079         String capabilityName = "";
 
1080         String ownerId = "";
 
1081         ResponseFormat result;
 
1084         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "updateCapabilityPropertyOnContainerComponent", new Object[]{property, newValue, containerComponent, foundResourceInstance, capabilityType, capabilityName, ownerId});
 
1089         public void testUpdateInstanceCapabilityProperties() throws Exception {
 
1090         ComponentInstanceBusinessLogic testSubject;
 
1091         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
 
1092         Component resource = createResource();
 
1093         String containerComponentId = resource.getUniqueId();
 
1094         String componentInstanceUniqueId = "";
 
1095         String capabilityType = "";
 
1096         String capabilityName = "";
 
1097         String ownerId = "";
 
1098         List<ComponentInstanceProperty> properties = new ArrayList<>();
 
1099         String userId = user.getUserId();
 
1100         Either<List<ComponentInstanceProperty>,ResponseFormat> result;
 
1103          when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.left(resource));
 
1108         testSubject=createTestSubject();
 
1109         result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, ownerId, properties, userId);
 
1110         when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND));
 
1111         result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, ownerId, properties, userId);
 
1112         componentTypeEnum = null;
 
1113         result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, ownerId, properties, userId);
 
1120         public void testUpdateInstanceCapabilityProperties_1() throws Exception {
 
1121         ComponentInstanceBusinessLogic testSubject;
 
1122         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
 
1123         Component component = createResource();
 
1124         String containerComponentId = component.getUniqueId();
 
1125         String componentInstanceUniqueId = "";
 
1126         String capabilityType = "";
 
1127         String capabilityName = "";
 
1128         List<ComponentInstanceProperty> properties = new ArrayList<>();
 
1129         String userId = user.getUserId();
 
1130         Either<List<ComponentInstanceProperty>,ResponseFormat> result;
 
1133          when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
 
1135         testSubject=createTestSubject();
 
1136         result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, properties, userId);
 
1137          when(toscaOperationFacade.getToscaFullElement(containerComponentId)).thenReturn(Either.left(component));
 
1138          result=testSubject.updateInstanceCapabilityProperties(componentTypeEnum, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, properties, userId);