Catalog-be dead code removal
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / impl / ResourceBusinessLogicTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.components.impl;
22
23 import fj.data.Either;
24 import mockit.Deencapsulation;
25 import org.apache.commons.lang3.tuple.ImmutablePair;
26 import org.junit.Assert;
27 import org.junit.Before;
28 import org.junit.Ignore;
29 import org.junit.Test;
30 import org.mockito.InjectMocks;
31 import org.mockito.Mockito;
32 import org.mockito.MockitoAnnotations;
33 import org.openecomp.sdc.ElementOperationMock;
34 import org.openecomp.sdc.be.auditing.impl.AuditingManager;
35 import org.openecomp.sdc.be.components.InterfaceOperationTestUtils;
36 import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
37 import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo;
38 import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
39 import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
40 import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
41 import org.openecomp.sdc.be.components.validation.UserValidations;
42 import org.openecomp.sdc.be.config.ConfigurationManager;
43 import org.openecomp.sdc.be.dao.api.ActionStatus;
44 import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
45 import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
46 import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
47 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
48 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
49 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
50 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
51 import org.openecomp.sdc.be.impl.ComponentsUtils;
52 import org.openecomp.sdc.be.impl.WebAppContextWrapper;
53 import org.openecomp.sdc.be.model.ArtifactDefinition;
54 import org.openecomp.sdc.be.model.CapabilityDefinition;
55 import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
56 import org.openecomp.sdc.be.model.Component;
57 import org.openecomp.sdc.be.model.ComponentInstance;
58 import org.openecomp.sdc.be.model.ComponentInstanceInput;
59 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
60 import org.openecomp.sdc.be.model.CsarInfo;
61 import org.openecomp.sdc.be.model.DataTypeDefinition;
62 import org.openecomp.sdc.be.model.GroupDefinition;
63 import org.openecomp.sdc.be.model.InputDefinition;
64 import org.openecomp.sdc.be.model.InterfaceDefinition;
65 import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
66 import org.openecomp.sdc.be.model.LifecycleStateEnum;
67 import org.openecomp.sdc.be.model.NodeTypeInfo;
68 import org.openecomp.sdc.be.model.PropertyDefinition;
69 import org.openecomp.sdc.be.model.RequirementDefinition;
70 import org.openecomp.sdc.be.model.Resource;
71 import org.openecomp.sdc.be.model.UploadCapInfo;
72 import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
73 import org.openecomp.sdc.be.model.UploadPropInfo;
74 import org.openecomp.sdc.be.model.UploadReqInfo;
75 import org.openecomp.sdc.be.model.UploadResourceInfo;
76 import org.openecomp.sdc.be.model.User;
77 import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
78 import org.openecomp.sdc.be.model.category.CategoryDefinition;
79 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
80 import org.openecomp.sdc.be.model.jsontitan.operations.InterfaceOperation;
81 import org.openecomp.sdc.be.model.jsontitan.operations.NodeTemplateOperation;
82 import org.openecomp.sdc.be.model.jsontitan.operations.NodeTypeOperation;
83 import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
84 import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
85 import org.openecomp.sdc.be.model.operations.api.ICacheMangerOperation;
86 import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation;
87 import org.openecomp.sdc.be.model.operations.api.IElementOperation;
88 import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
89 import org.openecomp.sdc.be.model.operations.api.IPropertyOperation;
90 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
91 import org.openecomp.sdc.be.model.operations.impl.CacheMangerOperation;
92 import org.openecomp.sdc.be.model.operations.impl.CsarOperation;
93 import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation;
94 import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
95 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
96 import org.openecomp.sdc.be.tosca.CsarUtils.NonMetaArtifactInfo;
97 import org.openecomp.sdc.be.user.IUserBusinessLogic;
98 import org.openecomp.sdc.be.user.Role;
99 import org.openecomp.sdc.be.user.UserBusinessLogic;
100 import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
101 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
102 import org.openecomp.sdc.common.api.ConfigurationSource;
103 import org.openecomp.sdc.common.api.Constants;
104 import org.openecomp.sdc.common.datastructure.Wrapper;
105 import org.openecomp.sdc.common.impl.ExternalConfiguration;
106 import org.openecomp.sdc.common.impl.FSConfigurationSource;
107 import org.openecomp.sdc.common.util.GeneralUtility;
108 import org.openecomp.sdc.common.util.ValidationUtils;
109 import org.openecomp.sdc.exception.ResponseFormat;
110 import org.slf4j.Logger;
111 import org.slf4j.LoggerFactory;
112 import org.springframework.web.context.WebApplicationContext;
113
114 import javax.servlet.ServletContext;
115 import java.lang.reflect.Method;
116 import java.util.ArrayList;
117 import java.util.Collection;
118 import java.util.EnumMap;
119 import java.util.HashMap;
120 import java.util.HashSet;
121 import java.util.List;
122 import java.util.Map;
123 import java.util.Set;
124 import java.util.regex.Pattern;
125 import java.util.stream.Collectors;
126 import java.util.stream.Stream;
127
128 import static org.junit.Assert.assertEquals;
129 import static org.junit.Assert.assertFalse;
130 import static org.junit.Assert.assertNotNull;
131 import static org.junit.Assert.assertTrue;
132 import static org.mockito.ArgumentMatchers.any;
133 import static org.mockito.ArgumentMatchers.anyObject;
134 import static org.mockito.ArgumentMatchers.anyString;
135 import static org.mockito.ArgumentMatchers.eq;
136 import static org.mockito.Mockito.when;
137
138 public class ResourceBusinessLogicTest implements InterfaceOperationTestUtils {
139
140         private static final Logger log = LoggerFactory.getLogger(ResourceBusinessLogicTest.class);
141         public static final String RESOURCE_CATEGORY = "Network Layer 2-3/Router";
142         public static final String RESOURCE_CATEGORY1 = "Network Layer 2-3";
143         public static final String RESOURCE_SUBCATEGORY = "Router";
144
145         public static final String UPDATED_CATEGORY = "Network Layer 2-3/Gateway";
146         public static final String UPDATED_SUBCATEGORY = "Gateway";
147
148         private String resourceId = "resourceId1";
149         private String operationId = "uniqueId1";
150         Resource resourceUpdate;
151
152         public static final String RESOURCE_NAME = "My-Resource_Name with   space";
153         private static final String GENERIC_VF_NAME = "org.openecomp.resource.abstract.nodes.VF";
154         private static final String GENERIC_CR_NAME = "org.openecomp.resource.abstract.nodes.CR";
155         private static final String GENERIC_VFC_NAME = "org.openecomp.resource.abstract.nodes.VFC";
156         private static final String GENERIC_PNF_NAME = "org.openecomp.resource.abstract.nodes.PNF";
157
158         final ServletContext servletContext = Mockito.mock(ServletContext.class);
159         IElementOperation mockElementDao;
160         TitanDao mockTitanDao = Mockito.mock(TitanDao.class);
161         UserBusinessLogic mockUserAdmin = Mockito.mock(UserBusinessLogic.class);
162         ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
163         NodeTypeOperation nodeTypeOperation = Mockito.mock(NodeTypeOperation.class);
164         NodeTemplateOperation nodeTemplateOperation = Mockito.mock(NodeTemplateOperation.class);
165         TopologyTemplateOperation topologyTemplateOperation = Mockito.mock(TopologyTemplateOperation.class);
166         final LifecycleBusinessLogic lifecycleBl = Mockito.mock(LifecycleBusinessLogic.class);
167         final ICapabilityTypeOperation capabilityTypeOperation = Mockito.mock(ICapabilityTypeOperation.class);
168         final IPropertyOperation propertyOperation = Mockito.mock(IPropertyOperation.class);
169         final ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
170         WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class);
171         UserValidations userValidations = Mockito.mock(UserValidations.class);
172         WebApplicationContext webAppContext = Mockito.mock(WebApplicationContext.class);
173         IInterfaceLifecycleOperation interfaceTypeOperation = Mockito.mock(IInterfaceLifecycleOperation.class);
174         InterfaceOperation interfaceOperation = Mockito.mock(InterfaceOperation.class);
175
176         @InjectMocks
177         ResourceBusinessLogic bl = new ResourceBusinessLogic();
178         ResponseFormatManager responseManager = null;
179         GraphLockOperation graphLockOperation = Mockito.mock(GraphLockOperation.class);
180         User user = null;
181         Resource resourceResponse = null;
182         Resource genericVF = null;
183         Resource genericCR = null;
184         Resource genericVFC = null;
185         Resource genericPNF = null;
186         ComponentsUtils componentsUtils;
187         ArtifactsBusinessLogic artifactManager = new ArtifactsBusinessLogic();
188         CsarOperation csarOperation = Mockito.mock(CsarOperation.class);
189         Map<String, DataTypeDefinition> emptyDataTypes = new HashMap<String, DataTypeDefinition>();
190         private GenericTypeBusinessLogic genericTypeBusinessLogic = Mockito.mock(GenericTypeBusinessLogic.class);
191         CacheMangerOperation cacheManager = Mockito.mock(CacheMangerOperation.class);
192
193         public ResourceBusinessLogicTest() {
194
195         }
196
197         @Before
198         public void setup() {
199                 MockitoAnnotations.initMocks(this);
200                 Mockito.reset(propertyOperation);
201
202                 ExternalConfiguration.setAppName("catalog-be");
203
204                 // init Configuration
205                 String appConfigDir = "src/test/resources/config/catalog-be";
206                 ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
207                                 appConfigDir);
208                 ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
209                 componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
210
211                 // Elements
212                 mockElementDao = new ElementOperationMock();
213
214                 // User data and management
215                 user = new User();
216                 user.setUserId("jh0003");
217                 user.setFirstName("Jimmi");
218                 user.setLastName("Hendrix");
219                 user.setRole(Role.ADMIN.name());
220
221                 Either<User, ActionStatus> eitherGetUser = Either.left(user);
222                 when(mockUserAdmin.getUser("jh0003", false)).thenReturn(eitherGetUser);
223                 when(userValidations.validateUserExists(eq(user.getUserId()), anyString(), eq(false)))
224                                 .thenReturn(Either.left(user));
225                 when(userValidations.validateUserNotEmpty(eq(user), anyString())).thenReturn(Either.left(user));
226                 // Servlet Context attributes
227                 when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager);
228                 when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
229                                 .thenReturn(webAppContextWrapper);
230                 when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webAppContext);
231                 when(webAppContext.getBean(IElementOperation.class)).thenReturn(mockElementDao);
232
233                 Either<Integer, StorageOperationStatus> eitherCountRoot = Either.left(1);
234                 Either<Boolean, StorageOperationStatus> eitherFalse = Either.left(true);
235                 when(toscaOperationFacade.validateComponentNameExists("Root", ResourceTypeEnum.VFC, ComponentTypeEnum.RESOURCE))
236                                 .thenReturn(eitherFalse);
237
238                 Either<Boolean, StorageOperationStatus> eitherCountExist = Either.left(true);
239                 when(toscaOperationFacade.validateComponentNameExists("alreadyExists", ResourceTypeEnum.VFC,
240                                 ComponentTypeEnum.RESOURCE)).thenReturn(eitherCountExist);
241
242                 Either<Boolean, StorageOperationStatus> eitherCount = Either.left(false);
243                 when(toscaOperationFacade.validateComponentNameExists(eq(RESOURCE_NAME), any(ResourceTypeEnum.class),
244                                 eq(ComponentTypeEnum.RESOURCE))).thenReturn(eitherCount);
245                 when(interfaceOperation.updateInterface(anyString(), anyObject()))
246                                 .thenReturn(Either.left(mockInterfaceDefinitionToReturn(RESOURCE_NAME)));
247                 Either<Boolean, StorageOperationStatus> validateDerivedExists = Either.left(true);
248                 when(toscaOperationFacade.validateToscaResourceNameExists("Root")).thenReturn(validateDerivedExists);
249
250                 Either<Boolean, StorageOperationStatus> validateDerivedNotExists = Either.left(false);
251                 when(toscaOperationFacade.validateToscaResourceNameExists("kuku")).thenReturn(validateDerivedNotExists);
252                 when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Resource)))
253                                 .thenReturn(StorageOperationStatus.OK);
254                 when(graphLockOperation.lockComponentByName(Mockito.anyString(), eq(NodeTypeEnum.Resource)))
255                                 .thenReturn(StorageOperationStatus.OK);
256
257                 // createResource
258                 resourceResponse = createResourceObject(true);
259                 Either<Resource, StorageOperationStatus> eitherCreate = Either.left(resourceResponse);
260                 Either<Integer, StorageOperationStatus> eitherValidate = Either.left(null);
261                 when(toscaOperationFacade.createToscaComponent(any(Resource.class))).thenReturn(eitherCreate);
262                 when(toscaOperationFacade.validateCsarUuidUniqueness(Mockito.anyString())).thenReturn(eitherValidate);
263                 Map<String, DataTypeDefinition> emptyDataTypes = new HashMap<String, DataTypeDefinition>();
264                 when(applicationDataTypeCache.getAll()).thenReturn(Either.left(emptyDataTypes));
265                 when(mockTitanDao.commit()).thenReturn(TitanOperationStatus.OK);
266
267                 // BL object
268                 artifactManager.setNodeTemplateOperation(nodeTemplateOperation);
269                 bl = new ResourceBusinessLogic();
270                 bl.setElementDao(mockElementDao);
271                 bl.setUserAdmin(mockUserAdmin);
272                 bl.setCapabilityTypeOperation(capabilityTypeOperation);
273                 bl.setComponentsUtils(componentsUtils);
274                 bl.setLifecycleManager(lifecycleBl);
275                 bl.setGraphLockOperation(graphLockOperation);
276                 bl.setArtifactsManager(artifactManager);
277                 bl.setPropertyOperation(propertyOperation);
278                 bl.setTitanGenericDao(mockTitanDao);
279                 bl.setApplicationDataTypeCache(applicationDataTypeCache);
280                 bl.setCsarOperation(csarOperation);
281                 bl.setCacheManagerOperation(cacheManager);
282                 bl.setGenericTypeBusinessLogic(genericTypeBusinessLogic);
283                 toscaOperationFacade.setNodeTypeOperation(nodeTypeOperation);
284                 toscaOperationFacade.setTopologyTemplateOperation(topologyTemplateOperation);
285                 bl.setToscaOperationFacade(toscaOperationFacade);
286                 bl.setUserValidations(userValidations);
287                 bl.setInterfaceTypeOperation(interfaceTypeOperation);
288                 bl.setInterfaceOperation(interfaceOperation);
289
290                 Resource resourceCsar = createResourceObjectCsar(true);
291                 setCanWorkOnResource(resourceCsar);
292                 Either<Component, StorageOperationStatus> oldResourceRes = Either.left(resourceCsar);
293                 when(toscaOperationFacade.getToscaFullElement(resourceCsar.getUniqueId())).thenReturn(oldResourceRes);
294                 responseManager = ResponseFormatManager.getInstance();
295
296         }
297
298         private Resource createResourceObject(boolean afterCreate) {
299                 Resource resource = new Resource();
300                 resource.setName(RESOURCE_NAME);
301                 resource.addCategory(RESOURCE_CATEGORY1, RESOURCE_SUBCATEGORY);
302                 resource.setDescription("My short description");
303                 List<String> tgs = new ArrayList<String>();
304                 tgs.add("test");
305                 tgs.add(resource.getName());
306                 resource.setTags(tgs);
307                 List<String> template = new ArrayList<String>();
308                 template.add("Root");
309                 resource.setDerivedFrom(template);
310                 resource.setVendorName("Motorola");
311                 resource.setVendorRelease("1.0.0");
312                 resource.setContactId("ya5467");
313                 resource.setIcon("MyIcon");
314
315                 if (afterCreate) {
316                         resource.setName(resource.getName());
317                         resource.setVersion("0.1");
318                         resource.setUniqueId(resource.getName().toLowerCase() + ":" + resource.getVersion());
319                         resource.setCreatorUserId(user.getUserId());
320                         resource.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
321                         resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
322                 }
323                 return resource;
324         }
325
326         private Resource createResourceObjectCsar(boolean afterCreate) {
327                 Resource resource = new Resource();
328                 resource.setName(RESOURCE_NAME);
329                 resource.addCategory(RESOURCE_CATEGORY1, RESOURCE_SUBCATEGORY);
330                 resource.setDescription("My short description");
331                 List<String> tgs = new ArrayList<String>();
332                 tgs.add("test");
333                 tgs.add(resource.getName());
334                 resource.setTags(tgs);
335                 List<String> template = new ArrayList<String>();
336                 template.add("Root");
337                 resource.setDerivedFrom(template);
338                 resource.setVendorName("Motorola");
339                 resource.setVendorRelease("1.0.0");
340                 resource.setResourceVendorModelNumber("");
341                 resource.setContactId("ya5467");
342                 resource.setIcon("MyIcon");
343                 resource.setCsarUUID("valid_vf.csar");
344                 resource.setCsarVersion("1");
345
346                 if (afterCreate) {
347                         resource.setName(resource.getName());
348                         resource.setVersion("0.1");
349
350                         resource.setUniqueId(resource.getName().toLowerCase() + ":" + resource.getVersion());
351                         resource.setCreatorUserId(user.getUserId());
352                         resource.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
353                         resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
354                 }
355                 return resource;
356         }
357
358         private Resource setCanWorkOnResource(Resource resource) {
359                 resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
360                 resource.setLastUpdaterUserId(user.getUserId());
361                 return resource;
362         }
363
364         @Test
365         public void testHappyScenario() {
366                 validateUserRoles(Role.ADMIN, Role.DESIGNER);
367                 Resource resource = createResourceObject(false);
368                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
369                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
370
371                 if (createResponse.isRight()) {
372                         assertEquals(new Integer(200), createResponse.right().value().getStatus());
373                 }
374                 assertEquals(createResourceObject(true), createResponse.left().value());
375         }
376
377         @Test
378         public void testCsarUUIDnotEmpty() {
379                 validateUserRoles(Role.ADMIN, Role.DESIGNER);
380                 Resource resource = createResourceObject(false);
381                 resource.setCsarUUID("asasaas");
382                 Either<Integer, StorageOperationStatus> eitherUpdate = Either.left(2);
383                 when(toscaOperationFacade.validateCsarUuidUniqueness("asasaas")).thenReturn(eitherUpdate);
384                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
385                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
386
387         }
388
389         @Test
390         public void testUpdateHappyScenario() {
391                 Resource resource = createResourceObjectCsar(true);
392                 setCanWorkOnResource(resource);
393                 validateUserRoles(Role.ADMIN, Role.DESIGNER);
394                 Either<Resource, StorageOperationStatus> resourceLinkedToCsarRes = Either.left(resource);
395                 when(toscaOperationFacade.getLatestComponentByCsarOrName(ComponentTypeEnum.RESOURCE, resource.getCsarUUID(),
396                                 resource.getSystemName())).thenReturn(resourceLinkedToCsarRes);
397                 Either<Boolean, StorageOperationStatus> validateDerivedExists = Either.left(true);
398                 when(toscaOperationFacade.validateToscaResourceNameExists("Root")).thenReturn(validateDerivedExists);
399                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
400                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
401                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
402                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
403                 Either<Resource, ResponseFormat> updateResponse = bl.validateAndUpdateResourceFromCsar(resource, user, null,
404                                 null, resource.getUniqueId());
405                 if (updateResponse.isRight()) {
406                         assertEquals(new Integer(200), updateResponse.right().value().getStatus());
407                 }
408                 assertEquals(resource.getUniqueId(), updateResponse.left().value().getUniqueId());
409         }
410
411
412         @Test
413         public void testFailedResourceValidations() {
414                 testResourceNameExist();
415                 testResourceNameEmpty();
416                 // testResourceNameExceedsLimit();
417                 testResourceNameWrongFormat();
418                 testResourceDescExceedsLimitCreate();
419                 testResourceDescNotEnglish();
420                 testResourceDescriptionEmpty();
421                 testResourceDescriptionMissing();
422                 testResourceIconMissing();
423                 testResourceIconInvalid();
424                 testResourceIconExceedsLimit();
425                 testResourceTagNotExist();
426                 testResourceTagEmpty();
427                 testTagsExceedsLimitCreate();
428                 testTagsNoServiceName();
429                 testInvalidTag();
430
431                 testContactIdTooLong();
432                 testContactIdWrongFormatCreate();
433                 testResourceContactIdEmpty();
434                 testResourceContactIdMissing();
435                 testVendorNameExceedsLimit();
436                 testVendorNameWrongFormatCreate();
437                 testVendorReleaseWrongFormat();
438                 testVendorReleaseExceedsLimitCreate();
439                 testResourceVendorModelNumberExceedsLimit();
440                 testResourceVendorNameMissing();
441                 testResourceVendorReleaseMissing();
442                 testResourceCategoryExist();
443                 testResourceBadCategoryCreate();
444                 testHappyScenarioCostLicenseType();
445                 testCostWrongFormatCreate();
446                 testLicenseTypeWrongFormatCreate();
447                 testResourceTemplateNotExist();
448                 testResourceTemplateEmpty();
449                 testResourceTemplateInvalid();
450         }
451
452         private void testResourceNameExist() {
453                 String resourceName = "alreadyExists";
454                 Resource resourceExist = createResourceObject(false);
455                 resourceExist.setName(resourceName);
456                 resourceExist.getTags().add(resourceName);
457                 validateUserRoles(Role.ADMIN, Role.DESIGNER);
458                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
459                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
460                 assertResponse(createResponse, ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(),
461                                 resourceName);
462         }
463
464         private void testResourceNameEmpty() {
465                 Resource resourceExist = createResourceObject(false);
466                 resourceExist.setName(null);
467
468                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
469                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
470                 assertResponse(createResponse, ActionStatus.MISSING_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue());
471         }
472
473         private void testResourceNameExceedsLimit() {
474                 Resource resourceExccedsNameLimit = createResourceObject(false);
475                 // 51 chars, the limit is 50
476                 String tooLongResourceName = "zCRCAWjqte0DtgcAAMmcJcXeNubeX1p1vOZNTShAHOYNAHvV3iK";
477                 resourceExccedsNameLimit.setName(tooLongResourceName);
478
479                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit,
480                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
481                 assertTrue(createResponse.isRight());
482                 assertResponse(createResponse, ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(),
483                                 "" + ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
484         }
485
486         private void testResourceNameWrongFormat() {
487                 Resource resource = createResourceObject(false);
488                 // contains :
489                 String nameWrongFormat = "ljg?fd";
490                 resource.setName(nameWrongFormat);
491
492                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
493                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
494                 assertTrue(createResponse.isRight());
495                 assertResponse(createResponse, ActionStatus.INVALID_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue());
496         }
497
498         // Resource name - end
499         // Resource description - start
500         private void testResourceDescExceedsLimitCreate() {
501                 Resource resourceExccedsDescLimit = createResourceObject(false);
502                 // 1025 chars, the limit is 1024
503                 String tooLongResourceDesc = "1GUODojQ0sGzKR4NP7e5j82ADQ3KHTVOaezL95qcbuaqDtjZhAQGQ3iFwKAy580K4WiiXs3u3zq7RzXcSASl5fm0RsWtCMOIDP"
504                                 + "AOf9Tf2xtXxPCuCIMCR5wOGnNTaFxgnJEHAGxilBhZDgeMNHmCN1rMK5B5IRJOnZxcpcL1NeG3APTCIMP1lNAxngYulDm9heFSBc8TfXAADq7703AvkJT0QPpGq2z2P"
505                                 + "tlikcAnIjmWgfC5Tm7UH462BAlTyHg4ExnPPL4AO8c92VrD7kZSgSqiy73cN3gLT8uigkKrUgXQFGVUFrXVyyQXYtVM6bLBeuCGQf4C2j8lkNg6M0J3PC0PzMRoinOxk"
506                                 + "Ae2teeCtVcIj4A1KQo3210j8q2v7qQU69Mabsa6DT9FgE4rcrbiFWrg0Zto4SXWD3o1eJA9o29lTg6kxtklH3TuZTmpi5KVp1NFhS1RpnqF83tzv4mZLKsx7Zh1fEgYvRFwx1"
507                                 + "ar3RolyDfNoZiGBGTMsZzz7RPFBf2hTnLmNqVGQnHKhhGj0Y5s8t2cbqbO2nmHiJb9uaUVrCGypgbAcJL3KPOBfAVW8PcpmNj4yVjI3L4x5zHjmGZbp9vKshEQODcrmcgsYAoKqe"
508                                 + "uu5u7jk8XVxEfQ0m5qL8UOErXPlJovSmKUmP5B5T0w299zIWDYCzSoNasHpHjOMDLAiDDeHbozUOn9t3Qou00e9POq4RMM0VnIx1H38nJoJZz2XH8CI5YMQe7oTagaxgQTF2aa0qaq2"
509                                 + "V6nJsfRGRklGjNhFFYP2cS4Xv2IJO9DSX6LTXOmENrGVJJvMOZcvnBaZPfoAHN0LU4i1SoepLzulIxnZBfkUWFJgZ5wQ0Bco2GC1HMqzW21rwy4XHRxXpXbmW8LVyoA1KbnmVmROycU4"
510                                 + "scTZ62IxIcIWCVeMjBIcTviXULbPUyqlfEPXWr8IMJtpAaELWgyquPClAREMDs2b9ztKmUeXlMccFES1XWbFTrhBHhmmDyVReEgCwfokrUFR13LTUK1k8I6OEHOs";
511
512                 resourceExccedsDescLimit.setDescription(tooLongResourceDesc);
513
514                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsDescLimit,
515                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
516                 assertTrue(createResponse.isRight());
517                 assertResponse(createResponse, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT,
518                                 ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
519         }
520
521         private void testResourceDescNotEnglish() {
522                 Resource notEnglish = createResourceObject(false);
523                 // Not english
524                 String notEnglishDesc = "\uC2B5";
525                 notEnglish.setDescription(notEnglishDesc);
526
527                 Either<Resource, ResponseFormat> createResponse = bl.createResource(notEnglish,
528                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
529                 assertTrue(createResponse.isRight());
530                 assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_DESCRIPTION,
531                                 ComponentTypeEnum.RESOURCE.getValue());
532         }
533
534         private void testResourceDescriptionEmpty() {
535                 Resource resourceExist = createResourceObject(false);
536                 resourceExist.setDescription("");
537
538                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
539                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
540                 assertTrue(createResponse.isRight());
541
542                 assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_DESCRIPTION,
543                                 ComponentTypeEnum.RESOURCE.getValue());
544         }
545
546         private void testResourceDescriptionMissing() {
547                 Resource resourceExist = createResourceObject(false);
548                 resourceExist.setDescription(null);
549
550                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
551                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
552                 assertTrue(createResponse.isRight());
553
554                 assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_DESCRIPTION,
555                                 ComponentTypeEnum.RESOURCE.getValue());
556         }
557         // Resource description - end
558         // Resource icon start
559
560         private void testResourceIconMissing() {
561                 Resource resourceExist = createResourceObject(false);
562                 resourceExist.setIcon(null);
563
564                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
565                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
566                 assertTrue(createResponse.isRight());
567
568                 assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_ICON, ComponentTypeEnum.RESOURCE.getValue());
569         }
570
571         private void testResourceIconInvalid() {
572                 Resource resourceExist = createResourceObject(false);
573                 resourceExist.setIcon("kjk3453^&");
574
575                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
576                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
577                 assertTrue(createResponse.isRight());
578
579                 assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_ICON, ComponentTypeEnum.RESOURCE.getValue());
580         }
581
582         private void testResourceIconExceedsLimit() {
583                 Resource resourceExist = createResourceObject(false);
584                 resourceExist.setIcon("dsjfhskdfhskjdhfskjdhkjdhfkshdfksjsdkfhsdfsdfsdfsfsdfsf");
585
586                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
587                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
588                 assertTrue(createResponse.isRight());
589
590                 assertResponse(createResponse, ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(),
591                                 "" + ValidationUtils.ICON_MAX_LENGTH);
592         }
593
594         // Resource icon end
595         // Resource tags - start
596         private void testResourceTagNotExist() {
597                 Resource resourceExist = createResourceObject(false);
598                 resourceExist.setTags(null);
599
600                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
601                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
602                 assertTrue(createResponse.isRight());
603
604                 assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_TAGS);
605         }
606
607         private void testResourceTagEmpty() {
608                 Resource resourceExist = createResourceObject(false);
609                 resourceExist.setTags(new ArrayList<String>());
610
611                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
612                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
613                 assertTrue(createResponse.isRight());
614
615                 assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_TAGS);
616         }
617
618         private void testTagsExceedsLimitCreate() {
619                 Resource resourceExccedsNameLimit = createResourceObject(false);
620                 String tag1 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjQ";
621                 String tag2 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjW";
622                 String tag3 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjE";
623                 String tag4 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjb";
624                 String tag5 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjr";
625                 String tag6 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjf";
626                 String tag7 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjg";
627                 String tag8 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjd";
628                 String tag9 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjf";
629                 String tag10 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjg";
630                 String tag11 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjh";
631                 String tag12 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjj";
632                 String tag13 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjk";
633                 String tag14 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjs";
634                 String tag15 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjz";
635                 String tag16 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjx";
636                 String tag17 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBj2";
637                 String tag18 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBj3";
638                 String tag19 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBj4";
639                 String tag20 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBj5";
640                 String tag21 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBj0";
641
642                 List<String> tagsList = new ArrayList<String>();
643                 tagsList.add(tag1);
644                 tagsList.add(tag2);
645                 tagsList.add(tag3);
646                 tagsList.add(tag4);
647                 tagsList.add(tag5);
648                 tagsList.add(tag6);
649                 tagsList.add(tag7);
650                 tagsList.add(tag8);
651                 tagsList.add(tag9);
652                 tagsList.add(tag10);
653                 tagsList.add(tag11);
654                 tagsList.add(tag12);
655                 tagsList.add(tag13);
656                 tagsList.add(tag14);
657                 tagsList.add(tag15);
658                 tagsList.add(tag16);
659                 tagsList.add(tag17);
660                 tagsList.add(tag18);
661                 tagsList.add(tag19);
662                 tagsList.add(tag20);
663                 tagsList.add(tag21);
664                 tagsList.add(resourceExccedsNameLimit.getName());
665
666                 resourceExccedsNameLimit.setTags(tagsList);
667
668                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit,
669                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
670                 assertTrue(createResponse.isRight());
671                 assertResponse(createResponse, ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT,
672                                 "" + ValidationUtils.TAG_LIST_MAX_LENGTH);
673
674         }
675
676         private void testTagsNoServiceName() {
677                 Resource serviceExccedsNameLimit = createResourceObject(false);
678                 String tag1 = "afzs2qLBb";
679                 List<String> tagsList = new ArrayList<String>();
680                 tagsList.add(tag1);
681                 serviceExccedsNameLimit.setTags(tagsList);
682
683                 Either<Resource, ResponseFormat> createResponse = bl.createResource(serviceExccedsNameLimit,
684                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
685                 assertTrue(createResponse.isRight());
686                 assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME);
687
688         }
689
690         private void testInvalidTag() {
691                 Resource serviceExccedsNameLimit = createResourceObject(false);
692                 String tag1 = "afzs2qLBb%#%";
693                 List<String> tagsList = new ArrayList<String>();
694                 tagsList.add(tag1);
695                 serviceExccedsNameLimit.setTags(tagsList);
696
697                 Either<Resource, ResponseFormat> createResponse = bl.createResource(serviceExccedsNameLimit,
698                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
699                 assertTrue(createResponse.isRight());
700                 assertResponse(createResponse, ActionStatus.INVALID_FIELD_FORMAT, new String[] { "Resource", "tag" });
701
702         }
703
704         // Resource tags - stop
705         // Resource contact start
706
707         private void testContactIdTooLong() {
708                 Resource resourceContactId = createResourceObject(false);
709                 // 59 chars instead of 50
710                 String contactIdTooLong = "thisNameIsVeryLongAndExeccedsTheNormalLengthForContactId";
711                 resourceContactId.setContactId(contactIdTooLong);
712
713                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceContactId,
714                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
715                 assertTrue(createResponse.isRight());
716                 assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
717         }
718
719         private void testContactIdWrongFormatCreate() {
720                 Resource resourceContactId = createResourceObject(false);
721                 // 3 letters and 3 digits and special characters
722                 String contactIdFormatWrong = "yrt134!!!";
723                 resourceContactId.setContactId(contactIdFormatWrong);
724
725                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceContactId,
726                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
727                 assertTrue(createResponse.isRight());
728                 assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
729         }
730
731         private void testResourceContactIdEmpty() {
732                 Resource resourceExist = createResourceObject(false);
733                 resourceExist.setContactId("");
734
735                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
736                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
737                 assertTrue(createResponse.isRight());
738
739                 assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
740         }
741
742         private void testResourceContactIdMissing() {
743                 Resource resourceExist = createResourceObject(false);
744                 resourceExist.setContactId(null);
745
746                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
747                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
748                 assertTrue(createResponse.isRight());
749
750                 assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
751         }
752
753         private void testVendorNameExceedsLimit() {
754                 Resource resourceExccedsVendorNameLimit = createResourceObject(false);
755                 String tooLongVendorName = "h1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9E";
756                 resourceExccedsVendorNameLimit.setVendorName(tooLongVendorName);
757
758                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsVendorNameLimit,
759                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
760                 assertTrue(createResponse.isRight());
761                 assertResponse(createResponse, ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT,
762                                 "" + ValidationUtils.VENDOR_NAME_MAX_LENGTH);
763         }
764
765         private void testResourceVendorModelNumberExceedsLimit() {
766                 Resource resourceExccedsVendorModelNumberLimit = createResourceObject(false);
767                 String tooLongVendorModelNumber = "h1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9E";
768                 resourceExccedsVendorModelNumberLimit.setResourceVendorModelNumber(tooLongVendorModelNumber);
769
770                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsVendorModelNumberLimit,
771                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
772                 assertTrue(createResponse.isRight());
773                 assertResponse(createResponse, ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT,
774                                 "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH);
775         }
776
777         private void testVendorNameWrongFormatCreate() {
778                 Resource resource = createResourceObject(false);
779                 // contains *
780                 String nameWrongFormat = "ljg*fd";
781                 resource.setVendorName(nameWrongFormat);
782
783                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
784                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
785                 assertTrue(createResponse.isRight());
786                 assertResponse(createResponse, ActionStatus.INVALID_VENDOR_NAME);
787         }
788
789         private void testVendorReleaseWrongFormat() {
790                 Resource resource = createResourceObject(false);
791                 // contains >
792                 String nameWrongFormat = "1>2";
793                 resource.setVendorRelease(nameWrongFormat);
794
795                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
796                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
797                 assertTrue(createResponse.isRight());
798                 assertResponse(createResponse, ActionStatus.INVALID_VENDOR_RELEASE);
799
800         }
801
802         private void testVendorReleaseExceedsLimitCreate() {
803                 Resource resourceExccedsNameLimit = createResourceObject(false);
804                 String tooLongVendorRelease = "h1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9E";
805                 resourceExccedsNameLimit.setVendorRelease(tooLongVendorRelease);
806
807                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit,
808                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
809                 assertTrue(createResponse.isRight());
810                 assertResponse(createResponse, ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT,
811                                 "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
812         }
813
814         private void testResourceVendorNameMissing() {
815                 Resource resourceExist = createResourceObject(false);
816                 resourceExist.setVendorName(null);
817
818                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
819                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
820                 assertTrue(createResponse.isRight());
821
822                 assertResponse(createResponse, ActionStatus.MISSING_VENDOR_NAME);
823         }
824
825         private void testResourceVendorReleaseMissing() {
826                 Resource resourceExist = createResourceObject(false);
827                 resourceExist.setVendorRelease(null);
828
829                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
830                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
831                 assertTrue(createResponse.isRight());
832
833                 assertResponse(createResponse, ActionStatus.MISSING_VENDOR_RELEASE);
834         }
835
836         // Resource vendor name/release stop
837         // Category start
838         private void testResourceCategoryExist() {
839                 Resource resourceExist = createResourceObject(false);
840                 resourceExist.setCategories(null);
841
842                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
843                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
844                 assertTrue(createResponse.isRight());
845
846                 assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.RESOURCE.getValue());
847         }
848
849         private void testResourceBadCategoryCreate() {
850
851                 Resource resourceExist = createResourceObject(false);
852                 resourceExist.setCategories(null);
853                 resourceExist.addCategory("koko", "koko");
854
855                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
856                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
857                 assertTrue(createResponse.isRight());
858
859                 assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CATEGORY, ComponentTypeEnum.RESOURCE.getValue());
860         }
861
862         // Category stop
863         // Cost start
864         private void testHappyScenarioCostLicenseType() {
865                 Resource createResourceObject = createResourceObject(false);
866                 Resource createResourceObjectAfterCreate = createResourceObject(true);
867                 // Adding cost and licenseType to basic mock
868                 Either<Resource, StorageOperationStatus> eitherCreate = Either.left(createResourceObjectAfterCreate);
869                 when(toscaOperationFacade.createToscaComponent(any(Resource.class))).thenReturn(eitherCreate);
870
871                 String cost = "123.456";
872                 String licenseType = "User";
873                 createResourceObject.setCost(cost);
874                 createResourceObject.setLicenseType(licenseType);
875                 Either<Resource, ResponseFormat> createResponse = bl.createResource(createResourceObject,
876                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
877
878                 if (createResponse.isRight()) {
879                         assertEquals(new Integer(200), createResponse.right().value().getStatus());
880                 }
881                 createResourceObjectAfterCreate.setCost(cost);
882                 createResourceObjectAfterCreate.setLicenseType(licenseType);
883                 assertEquals(createResourceObjectAfterCreate, createResponse.left().value());
884         }
885
886         private void testCostWrongFormatCreate() {
887                 Resource resourceCost = createResourceObject(false);
888                 // Comma instead of fullstop
889                 String cost = "12356,464";
890                 resourceCost.setCost(cost);
891
892                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceCost,
893                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
894                 assertTrue(createResponse.isRight());
895                 assertResponse(createResponse, ActionStatus.INVALID_CONTENT);
896         }
897
898         // Cost stop
899         // License type start
900         private void testLicenseTypeWrongFormatCreate() {
901                 Resource resourceLicenseType = createResourceObject(false);
902                 // lowcase
903                 String licenseType = "cpu";
904                 resourceLicenseType.setLicenseType(licenseType);
905
906                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceLicenseType,
907                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
908                 assertTrue(createResponse.isRight());
909                 assertResponse(createResponse, ActionStatus.INVALID_CONTENT);
910         }
911
912         // License type stop
913         // Derived from start
914         private void testResourceTemplateNotExist() {
915                 Resource resourceExist = createResourceObject(false);
916                 List<String> list = null;
917                 resourceExist.setDerivedFrom(list);
918
919                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
920                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
921                 assertTrue(createResponse.isRight());
922
923                 assertResponse(createResponse, ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
924         }
925
926         private void testResourceTemplateEmpty() {
927                 Resource resourceExist = createResourceObject(false);
928                 resourceExist.setDerivedFrom(new ArrayList<String>());
929
930                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
931                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
932                 assertTrue(createResponse.isRight());
933
934                 assertResponse(createResponse, ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
935         }
936
937         private void testResourceTemplateInvalid() {
938                 Resource resourceExist = createResourceObject(false);
939                 ArrayList<String> derivedFrom = new ArrayList<String>();
940                 derivedFrom.add("kuku");
941                 resourceExist.setDerivedFrom(derivedFrom);
942
943                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
944                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
945                 assertTrue(createResponse.isRight());
946
947                 assertResponse(createResponse, ActionStatus.PARENT_RESOURCE_NOT_FOUND);
948         }
949         // Derived from stop
950
951         private void assertResponse(Either<Resource, ResponseFormat> createResponse, ActionStatus expectedStatus,
952                         String... variables) {
953                 ResponseFormat expectedResponse = responseManager.getResponseFormat(expectedStatus, variables);
954                 ResponseFormat actualResponse = createResponse.right().value();
955                 assertEquals(expectedResponse.getStatus(), actualResponse.getStatus());
956                 assertEquals("assert error description", expectedResponse.getFormattedMessage(),
957                                 actualResponse.getFormattedMessage());
958         }
959
960         // UPDATE tests - start
961         // Resource name
962         @Test
963         public void testResourceNameWrongFormat_UPDATE() {
964                 Resource resource = createResourceObject(true);
965                 resource.setInterfaces(createMockInterfaceDefinition(RESOURCE_NAME));
966                 Resource updatedResource = createResourceObject(true);
967
968                 // this is in order to prevent failing with 403 earlier
969                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
970                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
971                 // contains *
972                 String nameWrongFormat = "ljg*fd";
973                 updatedResource.setName(nameWrongFormat);
974
975                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
976                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
977
978                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
979                                 updatedResource, null, user, false);
980                 assertTrue(createResponse.isRight());
981                 assertResponse(createResponse, ActionStatus.INVALID_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue());
982
983         }
984
985         @Test
986         public void testResourceNameAfterCertify_UPDATE() {
987                 Resource resource = createResourceObject(true);
988                 resource.setInterfaces(createMockInterfaceDefinition(RESOURCE_NAME));
989                 Resource updatedResource = createResourceObject(true);
990
991                 // this is in order to prevent failing with 403 earlier
992                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
993                 // when(resourceOperation.getResource_tx(resource.getUniqueId(),false)).thenReturn(eitherUpdate);
994                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
995
996                 String name = "ljg";
997                 updatedResource.setName(name);
998                 resource.setVersion("1.0");
999
1000                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1001                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1002
1003                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
1004                                 updatedResource, null, user, false);
1005                 assertTrue(createResponse.isRight());
1006                 assertResponse(createResponse, ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED);
1007
1008         }
1009
1010         @Ignore
1011         public void testResourceNameExceedsLimit_UPDATE() {
1012                 Resource resource = createResourceObject(true);
1013                 Resource updatedResource = createResourceObject(true);
1014
1015                 // this is in order to prevent failing with 403 earlier
1016                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1017                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1018
1019                 // 51 chars, the limit is 50
1020                 String tooLongResourceName = "zCRCAWjqte0DtgcAAMmcJcXeNubeX1p1vOZNTShAHOYNAHvV3iK";
1021                 updatedResource.setName(tooLongResourceName);
1022                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1023                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1024
1025                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
1026                                 updatedResource, null, user, false);
1027                 assertTrue(createResponse.isRight());
1028                 assertResponse(createResponse, ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(),
1029                                 "" + ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
1030         }
1031
1032         @Test
1033         public void testResourceNameAlreadyExist_UPDATE() {
1034                 Resource resource = createResourceObject(true);
1035                 resource.setInterfaces(createMockInterfaceDefinition(RESOURCE_NAME));
1036
1037                 Resource updatedResource = createResourceObject(true);
1038
1039                 // this is in order to prevent failing with 403 earlier
1040                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1041                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1042
1043                 String resourceName = "alreadyExists";
1044                 updatedResource.setName(resourceName);
1045                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(updatedResource);
1046                 when(toscaOperationFacade.updateToscaElement(updatedResource)).thenReturn(dataModelResponse);
1047                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
1048                                 updatedResource, null, user, false);
1049                 assertTrue(createResponse.isRight());
1050                 assertResponse(createResponse, ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(),
1051                                 resourceName);
1052         }
1053
1054         //
1055
1056         @Test
1057         public void testResourceDescExceedsLimit_UPDATE() {
1058                 Resource resource = createResourceObject(true);
1059                 Resource updatedResource = createResourceObject(true);
1060
1061                 // this is in order to prevent failing with 403 earlier
1062                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1063                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1064
1065                 // 1025 chars, the limit is 1024
1066                 String tooLongResourceDesc = "1GUODojQ0sGzKR4NP7e5j82ADQ3KHTVOaezL95qcbuaqDtjZhAQGQ3iFwKAy580K4WiiXs3u3zq7RzXcSASl5fm0RsWtCMOIDP"
1067                                 + "AOf9Tf2xtXxPCuCIMCR5wOGnNTaFxgnJEHAGxilBhZDgeMNHmCN1rMK5B5IRJOnZxcpcL1NeG3APTCIMP1lNAxngYulDm9heFSBc8TfXAADq7703AvkJT0QPpGq2z2P"
1068                                 + "tlikcAnIjmWgfC5Tm7UH462BAlTyHg4ExnPPL4AO8c92VrD7kZSgSqiy73cN3gLT8uigkKrUgXQFGVUFrXVyyQXYtVM6bLBeuCGQf4C2j8lkNg6M0J3PC0PzMRoinOxk"
1069                                 + "Ae2teeCtVcIj4A1KQo3210j8q2v7qQU69Mabsa6DT9FgE4rcrbiFWrg0Zto4SXWD3o1eJA9o29lTg6kxtklH3TuZTmpi5KVp1NFhS1RpnqF83tzv4mZLKsx7Zh1fEgYvRFwx1"
1070                                 + "ar3RolyDfNoZiGBGTMsZzz7RPFBf2hTnLmNqVGQnHKhhGj0Y5s8t2cbqbO2nmHiJb9uaUVrCGypgbAcJL3KPOBfAVW8PcpmNj4yVjI3L4x5zHjmGZbp9vKshEQODcrmcgsYAoKqe"
1071                                 + "uu5u7jk8XVxEfQ0m5qL8UOErXPlJovSmKUmP5B5T0w299zIWDYCzSoNasHpHjOMDLAiDDeHbozUOn9t3Qou00e9POq4RMM0VnIx1H38nJoJZz2XH8CI5YMQe7oTagaxgQTF2aa0qaq2"
1072                                 + "V6nJsfRGRklGjNhFFYP2cS4Xv2IJO9DSX6LTXOmENrGVJJvMOZcvnBaZPfoAHN0LU4i1SoepLzulIxnZBfkUWFJgZ5wQ0Bco2GC1HMqzW21rwy4XHRxXpXbmW8LVyoA1KbnmVmROycU4"
1073                                 + "scTZ62IxIcIWCVeMjBIcTviXULbPUyqlfEPXWr8IMJtpAaELWgyquPClAREMDs2b9ztKmUeXlMccFES1XWbFTrhBHhmmDyVReEgCwfokrUFR13LTUK1k8I6OEHOs";
1074                 updatedResource.setDescription(tooLongResourceDesc);
1075                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1076                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1077                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
1078                                 updatedResource, null, user, false);
1079                 assertTrue(createResponse.isRight());
1080                 assertResponse(createResponse, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT,
1081                                 ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
1082
1083         }
1084
1085         @Test
1086         public void testIconWrongFormat_UPDATE() {
1087                 Resource resource = createResourceObject(true);
1088                 Resource updatedResource = createResourceObject(true);
1089
1090                 // this is in order to prevent failing with 403 earlier
1091                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1092                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1093
1094                 // contains .
1095                 String icon = "icon.jpg";
1096                 updatedResource.setIcon(icon);
1097                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1098                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1099
1100                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
1101                                 updatedResource, null, user, false);
1102                 assertTrue(createResponse.isRight());
1103                 assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_ICON, ComponentTypeEnum.RESOURCE.getValue());
1104
1105         }
1106
1107         @Test
1108         public void testIconAfterCertify_UPDATE() {
1109                 Resource resource = createResourceObject(true);
1110                 Resource updatedResource = createResourceObject(true);
1111
1112                 // this is in order to prevent failing with 403 earlier
1113                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1114                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1115
1116                 // contains
1117                 String icon = "icon";
1118                 updatedResource.setIcon(icon);
1119
1120                 resource.setVersion("1.0");
1121                 ;
1122                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1123                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1124                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
1125                                 updatedResource, null, user, false);
1126                 assertTrue(createResponse.isRight());
1127                 assertResponse(createResponse, ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED);
1128
1129         }
1130
1131         @Test
1132         public void testTagsExceedsLimit_UPDATE() {
1133                 Resource resource = createResourceObject(true);
1134                 Resource updatedResource = createResourceObject(true);
1135
1136                 // this is in order to prevent failing with 403 earlier
1137                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1138                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1139
1140                 String tag1 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjQ";
1141                 String tag2 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjW";
1142                 String tag3 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjE";
1143                 String tag4 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjb";
1144                 String tag5 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjr";
1145                 String tag6 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjf";
1146                 String tag7 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjg";
1147                 String tag8 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjd";
1148                 String tag9 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjf";
1149                 String tag10 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjg";
1150                 String tag11 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjh";
1151                 String tag12 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjj";
1152                 String tag13 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjk";
1153                 String tag14 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjs";
1154                 String tag15 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjz";
1155                 String tag16 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBjx";
1156                 String tag17 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBj2";
1157                 String tag18 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBj3";
1158                 String tag19 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBj4";
1159                 String tag20 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBj5";
1160                 String tag21 = "I63llMSEF12FntTwpMt64JhopkjQZzv5KS7mBoRku42PYLrBj0";
1161
1162                 List<String> tagsList = new ArrayList<String>();
1163                 tagsList.add(tag1);
1164                 tagsList.add(tag2);
1165                 tagsList.add(tag3);
1166                 tagsList.add(tag4);
1167                 tagsList.add(tag5);
1168                 tagsList.add(tag6);
1169                 tagsList.add(tag7);
1170                 tagsList.add(tag8);
1171                 tagsList.add(tag9);
1172                 tagsList.add(tag10);
1173                 tagsList.add(tag11);
1174                 tagsList.add(tag12);
1175                 tagsList.add(tag13);
1176                 tagsList.add(tag14);
1177                 tagsList.add(tag15);
1178                 tagsList.add(tag16);
1179                 tagsList.add(tag17);
1180                 tagsList.add(tag18);
1181                 tagsList.add(tag19);
1182                 tagsList.add(tag20);
1183                 tagsList.add(tag21);
1184                 tagsList.add(resource.getName());
1185
1186                 updatedResource.setTags(tagsList);
1187                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1188                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1189                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
1190                                 updatedResource, null, user, false);
1191                 assertTrue(createResponse.isRight());
1192
1193                 assertResponse(createResponse, ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT,
1194                                 "" + ValidationUtils.TAG_LIST_MAX_LENGTH);
1195         }
1196
1197         @Test
1198         public void testVendorNameWrongFormat_UPDATE() {
1199                 Resource resource = createResourceObject(true);
1200                 Resource updatedResource = createResourceObject(true);
1201
1202                 // this is in order to prevent failing with 403 earlier
1203                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1204                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1205
1206                 // contains *
1207                 String nameWrongFormat = "ljg*fd";
1208                 updatedResource.setVendorName(nameWrongFormat);
1209                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1210                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1211                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
1212                                 updatedResource, null, user, false);
1213                 assertTrue(createResponse.isRight());
1214                 assertResponse(createResponse, ActionStatus.INVALID_VENDOR_NAME);
1215
1216         }
1217
1218         @Test
1219         public void testVendorNameWrongFormat() {
1220                 Resource resource = createResourceObject(true);
1221                 Resource updatedResource = createResourceObject(true);
1222
1223                 // this is in order to prevent failing with 403 earlier
1224                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1225                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1226
1227                 // contains *
1228                 String nameWrongFormat = "ljg*fd";
1229                 updatedResource.setVendorName(nameWrongFormat);
1230                 resource.setVersion("1.0");
1231                 ;
1232                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1233                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1234                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
1235                                 updatedResource, null, user, false);
1236                 assertTrue(createResponse.isRight());
1237                 assertResponse(createResponse, ActionStatus.INVALID_VENDOR_NAME);
1238
1239         }
1240
1241         @Test
1242         public void testVendorReleaseExceedsLimit_UPDATE() {
1243                 Resource resource = createResourceObject(true);
1244                 Resource updatedResource = createResourceObject(true);
1245
1246                 // this is in order to prevent failing with 403 earlier
1247                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1248                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1249                 // 129 chars, the limit is 128
1250                 String tooLongVendorRelease = "h1KSyJh9EspI8SPwAGu4VETfqWejeanuB1PCJBxJmJncYnrW0lnsEFFVRIukRJkwlOVnZCy8p38tjhANeZq3BGMHIawWR6ICl8Wi9mikRYALWgvJug00JrlQ0iPVKPLxy";
1251                 updatedResource.setVendorRelease(tooLongVendorRelease);
1252                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1253                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1254                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
1255                                 updatedResource, null, user, false);
1256                 assertTrue(createResponse.isRight());
1257                 assertResponse(createResponse, ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT,
1258                                 "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
1259         }
1260
1261         @Ignore
1262         public void testContactIdWrongFormat_UPDATE() {
1263                 Resource resource = createResourceObject(true);
1264                 Resource updatedResource = createResourceObject(true);
1265
1266                 // this is in order to prevent failing with 403 earlier
1267                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1268                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1269
1270                 String resourceId = resource.getUniqueId();
1271                 // 3 letters and 3 digits
1272                 String contactIdTooLong = "yrt134";
1273                 updatedResource.setContactId(contactIdTooLong);
1274                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1275                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1276                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
1277                                 user, false);
1278                 assertTrue(createResponse.isRight());
1279
1280                 assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
1281         }
1282
1283         @Test
1284         public void testResourceBadCategory_UPDATE() {
1285                 Resource resource = createResourceObject(true);
1286                 Resource updatedResource = createResourceObject(true);
1287
1288                 // this is in order to prevent failing with 403 earlier
1289                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1290                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1291
1292                 String resourceId = resource.getUniqueId();
1293                 String badCategory = "ddfds";
1294                 updatedResource.setCategories(null);
1295                 updatedResource.addCategory(badCategory, "fikt");
1296                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1297                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1298                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
1299                                 user, false);
1300                 assertTrue(createResponse.isRight());
1301
1302                 assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CATEGORY, ComponentTypeEnum.RESOURCE.getValue());
1303         }
1304
1305         @Test
1306         public void testResourceCategoryAfterCertify_UPDATE() {
1307                 Resource resource = createResourceObject(true);
1308                 Resource updatedResource = createResourceObject(true);
1309
1310                 // this is in order to prevent failing with 403 earlier
1311                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1312                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1313
1314                 String resourceId = resource.getUniqueId();
1315                 updatedResource.setCategories(null);
1316                 updatedResource.addCategory(RESOURCE_CATEGORY1, UPDATED_SUBCATEGORY);
1317                 resource.setVersion("1.0");
1318                 ;
1319                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1320                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1321                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
1322                                 user, false);
1323                 assertTrue(createResponse.isRight());
1324
1325                 assertResponse(createResponse, ActionStatus.RESOURCE_CATEGORY_CANNOT_BE_CHANGED);
1326         }
1327
1328         // Derived from start
1329         @Test
1330         public void testResourceTemplateNotExist_UPDATE() {
1331                 Resource resource = createResourceObject(true);
1332                 Resource updatedResource = createResourceObject(true);
1333
1334                 // this is in order to prevent failing with 403 earlier
1335                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1336                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1337                 String resourceId = resource.getUniqueId();
1338
1339                 List<String> list = null;
1340                 updatedResource.setDerivedFrom(list);
1341                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1342                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1343                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
1344                                 user, false);
1345                 assertTrue(createResponse.isRight());
1346
1347                 assertResponse(createResponse, ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
1348         }
1349
1350         @Test
1351         public void testResourceTemplateEmpty_UPDATE() {
1352                 Resource resource = createResourceObject(true);
1353                 Resource updatedResource = createResourceObject(true);
1354                 String resourceId = resource.getUniqueId();
1355
1356                 // this is in order to prevent failing with 403 earlier
1357                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1358                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1359
1360                 updatedResource.setDerivedFrom(new ArrayList<String>());
1361                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1362                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1363                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
1364                                 user, false);
1365                 assertTrue(createResponse.isRight());
1366
1367                 assertResponse(createResponse, ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
1368         }
1369
1370         @Test
1371         public void testResourceTemplateInvalid_UPDATE() {
1372                 Resource resource = createResourceObject(true);
1373                 Resource updatedResource = createResourceObject(true);
1374                 String resourceId = resource.getUniqueId();
1375
1376                 // this is in order to prevent failing with 403 earlier
1377                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1378                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1379
1380                 ArrayList<String> derivedFrom = new ArrayList<String>();
1381                 derivedFrom.add("kuku");
1382                 updatedResource.setDerivedFrom(derivedFrom);
1383                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1384                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1385                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
1386                                 user, false);
1387                 assertTrue(createResponse.isRight());
1388
1389                 assertResponse(createResponse, ActionStatus.PARENT_RESOURCE_NOT_FOUND);
1390         }
1391
1392         @Test
1393         public void testResourceTemplateCertify_UPDATE_HAPPY() {
1394                 Resource resource = createResourceObject(true);
1395                 Resource updatedResource = createResourceObject(true);
1396                 String resourceId = resource.getUniqueId();
1397
1398                 // this is in order to prevent failing with 403 earlier
1399                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1400                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1401
1402                 Either<Boolean, StorageOperationStatus> isToscaNameExtending = Either.left(true);
1403                 when(toscaOperationFacade.validateToscaResourceNameExtends(Mockito.anyString(), Mockito.anyString()))
1404                                 .thenReturn(isToscaNameExtending);
1405
1406                 Either<Map<String, PropertyDefinition>, StorageOperationStatus> findPropertiesOfNode = Either
1407                                 .left(new HashMap<>());
1408                 when(propertyOperation.deleteAllPropertiesAssociatedToNode(any(NodeTypeEnum.class), Mockito.anyString()))
1409                                 .thenReturn(findPropertiesOfNode);
1410
1411                 resource.setVersion("1.0");
1412
1413                 ArrayList<String> derivedFrom = new ArrayList<String>();
1414                 derivedFrom.add("tosca.nodes.Root");
1415                 updatedResource.setDerivedFrom(derivedFrom);
1416                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(updatedResource);
1417                 when(toscaOperationFacade.updateToscaElement(updatedResource)).thenReturn(dataModelResponse);
1418                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
1419                                 user, false);
1420                 assertTrue(createResponse.isLeft());
1421         }
1422
1423         @Test
1424         public void testResourceTemplateCertify_UPDATE_SAD() {
1425                 Resource resource = createResourceObject(true);
1426                 Resource updatedResource = createResourceObject(true);
1427                 String resourceId = resource.getUniqueId();
1428
1429                 // this is in order to prevent failing with 403 earlier
1430                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
1431                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
1432
1433                 Either<Boolean, StorageOperationStatus> isToscaNameExtending = Either.left(false);
1434                 when(toscaOperationFacade.validateToscaResourceNameExtends(Mockito.anyString(), Mockito.anyString()))
1435                                 .thenReturn(isToscaNameExtending);
1436
1437                 resource.setVersion("1.0");
1438
1439                 ArrayList<String> derivedFrom = new ArrayList<String>();
1440                 derivedFrom.add("tosca.nodes.Root");
1441                 updatedResource.setDerivedFrom(derivedFrom);
1442                 Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
1443                 when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
1444                 Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
1445                                 user, false);
1446                 assertTrue(createResponse.isRight());
1447
1448                 assertResponse(createResponse, ActionStatus.PARENT_RESOURCE_DOES_NOT_EXTEND);
1449         }
1450         // Derived from stop
1451
1452         @Test
1453         public void createOrUpdateResourceAlreadyCheckout() {
1454                 Resource resourceExist = createResourceObject(false);
1455                 validateUserRoles(Role.ADMIN, Role.DESIGNER);
1456                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
1457                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
1458
1459                 createResponse.left().value().setLastUpdaterUserId(user.getUserId());
1460                 assertTrue(createResponse.isLeft());
1461
1462                 Either<Resource, StorageOperationStatus> getLatestResult = Either.left(createResponse.left().value());
1463                 Either<Component, StorageOperationStatus> getCompLatestResult = Either.left(createResponse.left().value());
1464                 when(toscaOperationFacade.getLatestByName(resourceExist.getName())).thenReturn(getCompLatestResult);
1465                 when(toscaOperationFacade.overrideComponent(any(Resource.class), any(Resource.class)))
1466                                 .thenReturn(getLatestResult);
1467
1468                 Resource resourceToUpdtae = createResourceObject(false);
1469
1470                 Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl
1471                                 .createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null, null, false);
1472                 assertTrue(createOrUpdateResource.isLeft());
1473
1474                 Mockito.verify(toscaOperationFacade, Mockito.times(1)).overrideComponent(any(Resource.class),
1475                                 any(Resource.class));
1476                 Mockito.verify(lifecycleBl, Mockito.times(0)).changeState(Mockito.anyString(), eq(user),
1477                                 eq(LifeCycleTransitionEnum.CHECKOUT), any(LifecycleChangeInfoWithAction.class), Mockito.anyBoolean(),
1478                                 Mockito.anyBoolean());
1479
1480         }
1481
1482         @Test
1483         public void createOrUpdateResourceCertified() {
1484                 Resource resourceExist = createResourceObject(false);
1485                 validateUserRoles(Role.ADMIN, Role.DESIGNER);
1486                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
1487                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
1488
1489                 assertTrue(createResponse.isLeft());
1490                 Resource certifiedResource = createResponse.left().value();
1491                 certifiedResource.setLifecycleState(LifecycleStateEnum.CERTIFIED);
1492                 certifiedResource.setVersion("1.0");
1493
1494                 Either<Resource, StorageOperationStatus> getLatestResult = Either.left(certifiedResource);
1495                 Either<Component, StorageOperationStatus> getCompLatestResult = Either.left(createResponse.left().value());
1496                 when(toscaOperationFacade.getLatestByName(resourceExist.getName())).thenReturn(getCompLatestResult);
1497                 when(toscaOperationFacade.overrideComponent(any(Resource.class), any(Resource.class)))
1498                                 .thenReturn(getLatestResult);
1499
1500                 when(lifecycleBl.changeState(Mockito.anyString(), eq(user), eq(LifeCycleTransitionEnum.CHECKOUT),
1501                                 any(LifecycleChangeInfoWithAction.class), Mockito.anyBoolean(), Mockito.anyBoolean()))
1502                                                 .thenReturn(createResponse);
1503
1504                 Resource resourceToUpdtae = createResourceObject(false);
1505
1506                 Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl
1507                                 .createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null, null, false);
1508                 assertTrue(createOrUpdateResource.isLeft());
1509
1510                 Mockito.verify(toscaOperationFacade, Mockito.times(1)).overrideComponent(any(Resource.class),
1511                                 any(Resource.class));
1512                 Mockito.verify(lifecycleBl, Mockito.times(1)).changeState(Mockito.anyString(), eq(user),
1513                                 eq(LifeCycleTransitionEnum.CHECKOUT), any(LifecycleChangeInfoWithAction.class), Mockito.anyBoolean(),
1514                                 Mockito.anyBoolean());
1515
1516         }
1517
1518         @Test
1519         public void createOrUpdateResourceNotExist() {
1520                 Resource resourceToUpdtae = createResourceObject(false);
1521
1522                 Either<Component, StorageOperationStatus> getLatestResult = Either.right(StorageOperationStatus.NOT_FOUND);
1523                 when(toscaOperationFacade.getLatestByName(resourceToUpdtae.getName())).thenReturn(getLatestResult);
1524
1525                 Either<Component, StorageOperationStatus> getLatestToscaNameResult = Either
1526                                 .right(StorageOperationStatus.NOT_FOUND);
1527                 when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdtae.getToscaResourceName()))
1528                                 .thenReturn(getLatestToscaNameResult);
1529
1530                 Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl
1531                                 .createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null, null, false);
1532                 assertTrue(createOrUpdateResource.isLeft());
1533
1534                 Mockito.verify(toscaOperationFacade, Mockito.times(0)).overrideComponent(any(Resource.class),
1535                                 any(Resource.class));
1536                 Mockito.verify(lifecycleBl, Mockito.times(0)).changeState(Mockito.anyString(), eq(user),
1537                                 eq(LifeCycleTransitionEnum.CHECKOUT), any(LifecycleChangeInfoWithAction.class), Mockito.anyBoolean(),
1538                                 Mockito.anyBoolean());
1539
1540         }
1541
1542         @Test
1543         public void testValidatePropertiesDefaultValues_SuccessfullWithoutProperties() {
1544                 Resource basic = createResourceObject(true);
1545
1546                 Either<Boolean, ResponseFormat> validatePropertiesDefaultValues = bl.validatePropertiesDefaultValues(basic);
1547                 assertTrue(validatePropertiesDefaultValues.isLeft());
1548         }
1549
1550         @Test
1551         public void testValidatePropertiesDefaultValues_SuccessfullWithProperties() {
1552                 Resource basic = createResourceObject(true);
1553                 PropertyDefinition property = new PropertyDefinition();
1554                 property.setName("myProperty");
1555                 property.setType(ToscaPropertyType.INTEGER.getType());
1556                 property.setDefaultValue("1");
1557                 List<PropertyDefinition> properties = new ArrayList<>();
1558                 properties.add(property);
1559                 basic.setProperties(properties);
1560                 when(propertyOperation.isPropertyTypeValid(property)).thenReturn(true);
1561                 when(propertyOperation.isPropertyDefaultValueValid(property, emptyDataTypes)).thenReturn(true);
1562                 Either<Boolean, ResponseFormat> validatePropertiesDefaultValues = bl.validatePropertiesDefaultValues(basic);
1563                 assertTrue(validatePropertiesDefaultValues.isLeft());
1564         }
1565
1566         @Test
1567         public void testValidatePropertiesDefaultValues_FailedWithProperties() {
1568                 Resource basic = createResourceObject(true);
1569                 PropertyDefinition property = new PropertyDefinition();
1570                 property.setName("myProperty");
1571                 property.setType(ToscaPropertyType.INTEGER.getType());
1572                 property.setDefaultValue("1.5");
1573                 List<PropertyDefinition> properties = new ArrayList<>();
1574                 properties.add(property);
1575                 basic.setProperties(properties);
1576
1577                 when(propertyOperation.isPropertyDefaultValueValid(property, emptyDataTypes)).thenReturn(false);
1578                 Either<Boolean, ResponseFormat> validatePropertiesDefaultValues = bl.validatePropertiesDefaultValues(basic);
1579                 assertTrue(validatePropertiesDefaultValues.isRight());
1580         }
1581
1582
1583         @SuppressWarnings("unchecked")
1584         @Test
1585         public void testFindVfCsarArtifactsToHandle() {
1586
1587                 Class<ResourceBusinessLogic> targetClass = ResourceBusinessLogic.class;
1588                 String methodName = "findVfCsarArtifactsToHandle";
1589                 Resource resource = new Resource();
1590                 String deploymentArtifactToUpdateFileName = "deploymentArtifactToUpdate.yaml";
1591                 String deploymentArtifactToDeleteFileName = "deploymentArtifactToDelete.yaml";
1592                 String deploymentArtifactToCreateFileName = "deploymentArtifactToCreate.yaml";
1593
1594                 String artifactInfoToUpdateFileName = "infoArtifactToUpdate.yaml";
1595                 String artifactInfoToDeleteFileName = "infoArtifactToDelete.yaml";
1596                 String artifactInfoToNotDeleteFileName = "infoArtifactNotToDelete.yaml";
1597                 String artifactInfoToCreateFileName = "infoArtifactToCreate.yaml";
1598
1599                 byte[] oldPayloadData = "oldPayloadData".getBytes();
1600                 byte[] newPayloadData = "newPayloadData".getBytes();
1601                 Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>();
1602
1603                 ArtifactDefinition deploymentArtifactToUpdate = new ArtifactDefinition();
1604                 deploymentArtifactToUpdate.setMandatory(false);
1605                 deploymentArtifactToUpdate.setArtifactName(deploymentArtifactToUpdateFileName);
1606                 deploymentArtifactToUpdate.setArtifactType("SNMP_POLL");
1607                 deploymentArtifactToUpdate.setPayload(oldPayloadData);
1608                 deploymentArtifactToUpdate
1609                                 .setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
1610
1611                 ArtifactDefinition deploymentArtifactToDelete = new ArtifactDefinition();
1612                 deploymentArtifactToDelete.setMandatory(false);
1613                 deploymentArtifactToDelete.setArtifactName(deploymentArtifactToDeleteFileName);
1614                 deploymentArtifactToDelete.setArtifactType("SNMP_TRAP");
1615                 deploymentArtifactToDelete.setPayload(oldPayloadData);
1616                 deploymentArtifactToDelete
1617                                 .setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
1618
1619                 ArtifactDefinition deploymentArtifactToIgnore = new ArtifactDefinition();
1620
1621                 deploymentArtifacts.put(ValidationUtils.normalizeArtifactLabel(deploymentArtifactToUpdate.getArtifactName()),
1622                                 deploymentArtifactToUpdate);
1623                 deploymentArtifacts.put(ValidationUtils.normalizeArtifactLabel(deploymentArtifactToDelete.getArtifactName()),
1624                                 deploymentArtifactToDelete);
1625                 deploymentArtifacts.put("ignore", deploymentArtifactToIgnore);
1626
1627                 Map<String, ArtifactDefinition> artifacts = new HashMap<>();
1628
1629                 ArtifactDefinition artifactToUpdate = new ArtifactDefinition();
1630                 artifactToUpdate.setMandatory(false);
1631                 artifactToUpdate.setArtifactName(artifactInfoToUpdateFileName);
1632                 artifactToUpdate.setArtifactType("SNMP_POLL");
1633                 artifactToUpdate.setPayload(oldPayloadData);
1634                 artifactToUpdate.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
1635
1636                 ArtifactDefinition artifactToDelete = new ArtifactDefinition();
1637                 artifactToDelete.setMandatory(false);
1638                 artifactToDelete.setArtifactName(artifactInfoToDeleteFileName);
1639                 artifactToDelete.setArtifactType("SNMP_TRAP");
1640                 artifactToDelete.setPayload(oldPayloadData);
1641                 artifactToDelete.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
1642                 artifactToDelete.setIsFromCsar(true);
1643
1644                 ArtifactDefinition artifactToNotDelete = new ArtifactDefinition();
1645                 artifactToNotDelete.setMandatory(false);
1646                 artifactToNotDelete.setArtifactName(artifactInfoToNotDeleteFileName);
1647                 artifactToNotDelete.setArtifactType("SNMP_TRAP");
1648                 artifactToNotDelete.setPayload(oldPayloadData);
1649                 artifactToNotDelete.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
1650                 artifactToNotDelete.setIsFromCsar(false);
1651
1652                 ArtifactDefinition artifactToIgnore = new ArtifactDefinition();
1653
1654                 artifacts.put(ValidationUtils.normalizeArtifactLabel(artifactToUpdate.getArtifactName()), artifactToUpdate);
1655                 artifacts.put(ValidationUtils.normalizeArtifactLabel(artifactToDelete.getArtifactName()), artifactToDelete);
1656                 artifacts.put(ValidationUtils.normalizeArtifactLabel(artifactToNotDelete.getArtifactName()),
1657                                 artifactToNotDelete);
1658                 artifacts.put("ignore", artifactToIgnore);
1659
1660                 resource.setDeploymentArtifacts(deploymentArtifacts);
1661                 resource.setArtifacts(artifacts);
1662
1663                 List<NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>();
1664                 NonMetaArtifactInfo deploymentArtifactInfoToUpdate = new NonMetaArtifactInfo(
1665                                 deploymentArtifactToUpdate.getArtifactName(), null,
1666                                 ArtifactTypeEnum.findType(deploymentArtifactToUpdate.getArtifactType()),
1667                                 ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, deploymentArtifactToUpdate.getArtifactName(), false);
1668
1669                 NonMetaArtifactInfo informationalArtifactInfoToUpdate = new NonMetaArtifactInfo(
1670                                 artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()),
1671                                 ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, artifactToUpdate.getArtifactName(), false);
1672
1673                 NonMetaArtifactInfo informationalArtifactInfoToUpdateFromCsar = new NonMetaArtifactInfo(
1674                                 artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()),
1675                                 ArtifactGroupTypeEnum.INFORMATIONAL, newPayloadData, artifactToUpdate.getArtifactName(), true);
1676
1677                 NonMetaArtifactInfo deploymentArtifactInfoToUpdateFromCsar = new NonMetaArtifactInfo(
1678                                 artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()),
1679                                 ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, artifactToUpdate.getArtifactName(), true);
1680
1681                 NonMetaArtifactInfo deploymentArtifactInfoToCreate = new NonMetaArtifactInfo(deploymentArtifactToCreateFileName,
1682                                 null, ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData,
1683                                 deploymentArtifactToCreateFileName, false);
1684
1685                 NonMetaArtifactInfo informationalArtifactInfoToCreate = new NonMetaArtifactInfo(artifactInfoToCreateFileName,
1686                                 null, ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.INFORMATIONAL, newPayloadData,
1687                                 artifactInfoToCreateFileName, false);
1688
1689                 artifactPathAndNameList.add(deploymentArtifactInfoToUpdate);
1690                 artifactPathAndNameList.add(informationalArtifactInfoToUpdate);
1691                 artifactPathAndNameList.add(deploymentArtifactInfoToCreate);
1692                 artifactPathAndNameList.add(informationalArtifactInfoToCreate);
1693                 artifactPathAndNameList.add(informationalArtifactInfoToUpdateFromCsar);
1694                 artifactPathAndNameList.add(deploymentArtifactInfoToUpdateFromCsar);
1695
1696                 Object[] argObjects = { resource, artifactPathAndNameList, user };
1697                 Class[] argClasses = { Resource.class, List.class, User.class };
1698                 try {
1699                         Method method = targetClass.getDeclaredMethod(methodName, argClasses);
1700                         method.setAccessible(true);
1701                         Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat> findVfCsarArtifactsToHandleRes = (Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat>) method
1702                                         .invoke(bl, argObjects);
1703                         assertTrue(findVfCsarArtifactsToHandleRes.isLeft());
1704                         EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>> foundVfArtifacts = findVfCsarArtifactsToHandleRes
1705                                         .left().value();
1706                         assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.CREATE).size() == 4);
1707                         assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.UPDATE).size() == 4);
1708                         assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.DELETE).size() == 1);
1709
1710                 } catch (Exception e) {
1711                         e.printStackTrace();
1712                 }
1713         }
1714
1715         @Test
1716         public void testVFGeneratedInputs() {
1717                 validateUserRoles(Role.ADMIN, Role.DESIGNER);
1718                 Resource resource = createVF();
1719                 List<InputDefinition> inputs = resource.getInputs();
1720                 assertTrue(8 == inputs.size());
1721                 for (InputDefinition input : inputs) {
1722                         assertNotNull(input.getOwnerId());
1723                 }
1724                 assertTrue(resource.getDerivedFromGenericType().equals(genericVF.getToscaResourceName()));
1725                 assertTrue(resource.getDerivedFromGenericVersion().equals(genericVF.getVersion()));
1726         }
1727
1728         @Test
1729         public void testCRGeneratedInputs() {
1730                 validateUserRoles(Role.ADMIN, Role.DESIGNER);
1731                 Resource resource = createCR();
1732                 List<InputDefinition> inputs = resource.getInputs();
1733                 assertTrue(5 == inputs.size());
1734                 for (InputDefinition input : inputs) {
1735                         assertNotNull(input.getOwnerId());
1736                 }
1737                 assertTrue(resource.getDerivedFromGenericType().equals(genericCR.getToscaResourceName()));
1738                 assertTrue(resource.getDerivedFromGenericVersion().equals(genericCR.getVersion()));
1739         }
1740
1741         @Test
1742         public void testVFUpdateGenericInputsToLatestOnCheckout() {
1743                 validateUserRoles(Role.ADMIN, Role.DESIGNER);
1744                 // create a VF that is derived from generic version 1.0
1745                 Resource resource = createVF();
1746                 // create a new generic version without properties
1747                 genericVF.setVersion("2.0");
1748                 genericVF.setProperties(null);
1749                 String currentDerivedFromVersion = resource.getDerivedFromGenericVersion();
1750                 List<InputDefinition> currentInputs = resource.getInputs();
1751                 // verify previous inputs ownerId fields exist - user may not delete
1752                 // generated inputs
1753                 assertTrue(8 == currentInputs.stream().filter(p -> null != p.getOwnerId()).collect(Collectors.toList()).size());
1754                 Either<Boolean, ResponseFormat> upgradeToLatestGeneric = bl.shouldUpgradeToLatestGeneric(resource);
1755                 // verify success
1756                 assertTrue(upgradeToLatestGeneric.isLeft());
1757                 // verify update required and valid
1758                 assertTrue(upgradeToLatestGeneric.left().value());
1759                 // verify version was upgraded
1760                 assertFalse(resource.getDerivedFromGenericVersion().equals(currentDerivedFromVersion));
1761                 // verify inputs were not deleted
1762                 assertTrue(8 == resource.getInputs().size());
1763                 // verify inputs ownerId fields were removed - user may delete/edit
1764                 // inputs
1765                 assertTrue(8 == resource.getInputs().stream().filter(p -> null == p.getOwnerId()).collect(Collectors.toList())
1766                                 .size());
1767         }
1768
1769         @Test
1770         public void testVFUpdateGenericInputsToLatestOnCheckoutNotPerformed() {
1771
1772                 // create a VF that is derived from generic version 1.0
1773                 validateUserRoles(Role.ADMIN, Role.DESIGNER);
1774                 Resource resource = createVF();
1775
1776                 // add an input to the VF
1777                 PropertyDefinition newProp = new PropertyDefinition();
1778                 newProp.setType("integer");
1779                 newProp.setName("newProp");
1780                 resource.getInputs().add(new InputDefinition(newProp));
1781
1782                 // create a new generic version with a new property which has the same
1783                 // name as a user defined input on the VF with a different type
1784                 genericVF.setVersion("2.0");
1785                 newProp.setType("string");
1786                 genericVF.setProperties(new ArrayList<PropertyDefinition>());
1787                 genericVF.getProperties().add(newProp);
1788                 when(genericTypeBusinessLogic.fetchDerivedFromGenericType(resource)).thenReturn(Either.left(genericVF));
1789                 when(genericTypeBusinessLogic.convertGenericTypePropertiesToInputsDefintion(genericVF.getProperties(),
1790                                 genericVF.getUniqueId())).thenCallRealMethod();
1791                 String currentDerivedFromVersion = resource.getDerivedFromGenericVersion();
1792                 assertTrue(8 == resource.getInputs().stream().filter(p -> null != p.getOwnerId()).collect(Collectors.toList())
1793                                 .size());
1794                 Either<Boolean, ResponseFormat> upgradeToLatestGeneric = bl.shouldUpgradeToLatestGeneric(resource);
1795                 // verify success
1796                 assertTrue(upgradeToLatestGeneric.isLeft());
1797                 // verify update is invalid an void
1798                 assertFalse(upgradeToLatestGeneric.left().value());
1799                 // verify version was not upgraded
1800                 assertTrue(resource.getDerivedFromGenericVersion().equals(currentDerivedFromVersion));
1801                 // verify inputs were not removed
1802                 assertTrue(9 == resource.getInputs().size());
1803                 // verify user defined input exists
1804                 assertTrue(1 == resource.getInputs().stream().filter(p -> null == p.getOwnerId()).collect(Collectors.toList())
1805                                 .size());
1806                 assertTrue(resource.getInputs().stream().filter(p -> null == p.getOwnerId()).findAny().get().getType()
1807                                 .equals("integer"));
1808         }
1809
1810         @Test
1811         public void testPNFGeneratedInputsNoGeneratedInformationalArtifacts() {
1812                 validateUserRoles(Role.ADMIN, Role.DESIGNER);
1813                 Resource resource = createPNF();
1814                 List<InputDefinition> inputs = resource.getInputs();
1815                 assertTrue(3 == inputs.size());
1816                 for (InputDefinition input : inputs) {
1817                         assertNotNull(input.getOwnerId());
1818                 }
1819                 assertTrue(resource.getDerivedFromGenericType().equals(genericPNF.getToscaResourceName()));
1820                 assertTrue(resource.getDerivedFromGenericVersion().equals(genericPNF.getVersion()));
1821                 assertTrue(0 == resource.getArtifacts().size());
1822         }
1823
1824         private Resource createVF() {
1825
1826                 genericVF = setupGenericTypeMock(GENERIC_VF_NAME);
1827                 when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_VF_NAME))
1828                                 .thenReturn(Either.left(genericVF));
1829                 Resource resource = createResourceObject(true);
1830                 resource.setDerivedFrom(null);
1831                 resource.setResourceType(ResourceTypeEnum.VF);
1832                 when(toscaOperationFacade.createToscaComponent(resource)).thenReturn(Either.left(resource));
1833                 when(genericTypeBusinessLogic.fetchDerivedFromGenericType(resource)).thenReturn(Either.left(genericVF));
1834                 when(genericTypeBusinessLogic.generateInputsFromGenericTypeProperties(genericVF)).thenCallRealMethod();
1835                 when(genericTypeBusinessLogic.convertGenericTypePropertiesToInputsDefintion(genericVF.getProperties(),
1836                                 resource.getUniqueId())).thenCallRealMethod();
1837                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
1838                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
1839                 assertTrue(createResponse.isLeft());
1840                 return createResponse.left().value();
1841         }
1842
1843         private Resource createCR() {
1844
1845                 genericCR = setupGenericTypeMock(GENERIC_CR_NAME);
1846                 when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_CR_NAME))
1847                                 .thenReturn(Either.left(genericCR));
1848                 Resource resource = createResourceObject(true);
1849                 resource.setDerivedFrom(null);
1850                 resource.setResourceType(ResourceTypeEnum.CR);
1851                 when(toscaOperationFacade.createToscaComponent(resource)).thenReturn(Either.left(resource));
1852                 when(genericTypeBusinessLogic.fetchDerivedFromGenericType(resource)).thenReturn(Either.left(genericCR));
1853                 when(genericTypeBusinessLogic.generateInputsFromGenericTypeProperties(genericCR)).thenCallRealMethod();
1854                 when(genericTypeBusinessLogic.convertGenericTypePropertiesToInputsDefintion(genericCR.getProperties(),
1855                                 resource.getUniqueId())).thenCallRealMethod();
1856                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
1857                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
1858                 assertTrue(createResponse.isLeft());
1859                 return createResponse.left().value();
1860         }
1861
1862         private Resource createPNF() {
1863
1864                 genericPNF = setupGenericTypeMock(GENERIC_PNF_NAME);
1865                 when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_PNF_NAME))
1866                                 .thenReturn(Either.left(genericPNF));
1867                 Resource resource = createResourceObject(true);
1868                 resource.setDerivedFrom(null);
1869                 resource.setResourceType(ResourceTypeEnum.PNF);
1870                 when(toscaOperationFacade.createToscaComponent(resource)).thenReturn(Either.left(resource));
1871                 when(genericTypeBusinessLogic.fetchDerivedFromGenericType(resource)).thenReturn(Either.left(genericPNF));
1872                 when(genericTypeBusinessLogic.generateInputsFromGenericTypeProperties(genericPNF)).thenCallRealMethod();
1873                 when(genericTypeBusinessLogic.convertGenericTypePropertiesToInputsDefintion(genericPNF.getProperties(),
1874                                 resource.getUniqueId())).thenCallRealMethod();
1875                 Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
1876                                 AuditingActionEnum.CREATE_RESOURCE, user, null, null);
1877                 assertTrue(createResponse.isLeft());
1878                 return createResponse.left().value();
1879         }
1880
1881         private Map<String, String> getGenericPropertiesByToscaName(String toscaName) {
1882                 HashMap<String, String> PNFProps = new HashMap<String, String>() {
1883                         {
1884                                 put("nf_function", "string");
1885                                 put("nf_role", "string");
1886                                 put("nf_type", "string");
1887                         }
1888                 };
1889
1890                 HashMap<String, String> CRProps = new HashMap<String, String>() {
1891                         {
1892                                 putAll(PNFProps);
1893                                 put("nf_naming_code", "string");
1894                                 put("nf_naming", "org.openecomp.datatypes.Naming");
1895                         }
1896                 };
1897
1898                 HashMap<String, String> VFProps = new HashMap<String, String>() {
1899                         {
1900                                 putAll(CRProps);
1901                                 put("availability_zone_max_count", "integer");
1902                                 put("min_instances", "integer");
1903                                 put("max_instances", "integer");
1904                         }
1905                 };
1906
1907                 if (toscaName.contains("PNF"))
1908                         return PNFProps;
1909                 if (toscaName.contains("CR"))
1910                         return CRProps;
1911                 if (toscaName.contains("VF"))
1912                         return VFProps;
1913
1914                 return new HashMap<>();
1915         }
1916
1917         private Resource setupGenericTypeMock(String toscaName) {
1918
1919                 Resource genericType = createResourceObject(true);
1920                 genericType.setVersion("1.0");
1921                 genericType.setToscaResourceName(toscaName);
1922                 List<PropertyDefinition> genericProps = new ArrayList<>();
1923                 Map<String, String> genericPropsMap = getGenericPropertiesByToscaName(toscaName);
1924                 genericPropsMap.forEach((name, type) -> {
1925                         PropertyDefinition prop = new PropertyDefinition();
1926                         prop.setName(name);
1927                         prop.setType(type);
1928                         genericProps.add(prop);
1929                 });
1930
1931                 genericType.setProperties(genericProps);
1932                 return genericType;
1933         }
1934
1935         private void validateUserRoles(Role... roles) {
1936                 List<Role> listOfRoles = Stream.of(roles).collect(Collectors.toList());
1937                 when(userValidations.validateUserRole(user, listOfRoles)).thenReturn(Either.left(true));
1938         }
1939
1940         private ResourceBusinessLogic createTestSubject() {
1941                 return bl;
1942         }
1943
1944         @Test
1945         public void testGetAllCertifiedResources() throws Exception {
1946                 ResourceBusinessLogic testSubject;
1947                 boolean getAbstract = false;
1948                 HighestFilterEnum highestFilter = HighestFilterEnum.HIGHEST_ONLY;
1949                 String userId = user.getUserId();
1950                 Either<List<Resource>, ResponseFormat> result;
1951                 Resource resource = createResourceObject(true);
1952
1953                 // default test
1954
1955                 Either<List<Resource>, StorageOperationStatus> getLatestResult = Either.right(StorageOperationStatus.OK);
1956
1957                 when(toscaOperationFacade.getAllCertifiedResources(false, true)).thenReturn(getLatestResult);
1958                 testSubject = createTestSubject();
1959                 result = testSubject.getAllCertifiedResources(getAbstract, highestFilter, userId);
1960         }
1961
1962         @Test
1963         public void testGetApplicationDataTypeCache() throws Exception {
1964                 ResourceBusinessLogic testSubject;
1965                 ApplicationDataTypeCache result;
1966
1967                 // default test
1968                 testSubject = createTestSubject();
1969                 result = testSubject.getApplicationDataTypeCache();
1970         }
1971
1972         @Test
1973         public void testGetArtifactsManager() throws Exception {
1974                 ResourceBusinessLogic testSubject;
1975                 ArtifactsBusinessLogic result;
1976
1977                 // default test
1978                 testSubject = createTestSubject();
1979                 result = testSubject.getArtifactsManager();
1980         }
1981
1982         @Test
1983         public void testGetCacheManagerOperation() throws Exception {
1984                 ResourceBusinessLogic testSubject;
1985                 ICacheMangerOperation result;
1986
1987                 // default test
1988                 testSubject = createTestSubject();
1989                 result = testSubject.getCacheManagerOperation();
1990         }
1991
1992         @Test
1993         public void testGetCapabilityTypeOperation() throws Exception {
1994                 ResourceBusinessLogic testSubject;
1995                 ICapabilityTypeOperation result;
1996
1997                 // default test
1998                 testSubject = createTestSubject();
1999                 result = testSubject.getCapabilityTypeOperation();
2000         }
2001
2002         @Test
2003         public void testGetComponentInstanceBL() throws Exception {
2004                 ResourceBusinessLogic testSubject;
2005                 ComponentInstanceBusinessLogic result;
2006
2007                 // default test
2008                 testSubject = createTestSubject();
2009                 result = testSubject.getComponentInstanceBL();
2010         }
2011
2012         @Test
2013         public void testGetComponentInstancesFilteredByPropertiesAndInputs() throws Exception {
2014                 ResourceBusinessLogic testSubject;
2015                 String componentId = "";
2016                 ComponentTypeEnum componentTypeEnum = null;
2017                 String userId = "";
2018                 String searchText = "";
2019                 Either<List<ComponentInstance>, ResponseFormat> result;
2020
2021                 // default test
2022                 testSubject = createTestSubject();
2023                 result = testSubject.getComponentInstancesFilteredByPropertiesAndInputs(componentId, componentTypeEnum, userId,
2024                                 searchText);
2025         }
2026
2027         @Test
2028         public void testGetComponentsUtils() throws Exception {
2029                 ResourceBusinessLogic testSubject;
2030                 ComponentsUtils result;
2031
2032                 // default test
2033                 testSubject = createTestSubject();
2034                 result = testSubject.getComponentsUtils();
2035         }
2036
2037         @Test
2038         public void testGetElementDao() throws Exception {
2039                 ResourceBusinessLogic testSubject;
2040                 IElementOperation result;
2041
2042                 // default test
2043                 testSubject = createTestSubject();
2044                 result = testSubject.getElementDao();
2045         }
2046
2047         @Test
2048         public void testGetCsarOperation() throws Exception {
2049                 ResourceBusinessLogic testSubject;
2050                 CsarOperation result;
2051
2052                 // default test
2053                 testSubject = createTestSubject();
2054                 result = testSubject.getCsarOperation();
2055         }
2056
2057         @Test
2058         public void testGetLatestResourceFromCsarUuid() throws Exception {
2059                 ResourceBusinessLogic testSubject;
2060                 Resource resource = createResourceObject(true);
2061                 String csarUuid = "";
2062                 Either<Resource, ResponseFormat> result;
2063
2064                 Either<Resource, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
2065                 when(toscaOperationFacade.getLatestComponentByCsarOrName(ComponentTypeEnum.RESOURCE, csarUuid, ""))
2066                                 .thenReturn(eitherUpdate);
2067
2068                 // test 1
2069                 testSubject = createTestSubject();
2070                 result = testSubject.getLatestResourceFromCsarUuid(csarUuid, user);
2071         }
2072
2073         @Test
2074         public void testGetLifecycleBusinessLogic() throws Exception {
2075                 ResourceBusinessLogic testSubject;
2076                 LifecycleBusinessLogic result;
2077
2078                 // default test
2079                 testSubject = createTestSubject();
2080                 result = testSubject.getLifecycleBusinessLogic();
2081         }
2082
2083         @Test
2084         public void testGetResource() throws Exception {
2085                 ResourceBusinessLogic testSubject;
2086                 Resource resource = createResourceObject(true);
2087                 String resourceId = resource.getUniqueId();
2088                 Either<Resource, ResponseFormat> result;
2089
2090                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
2091                 when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
2092
2093                 // test 1
2094                 testSubject = createTestSubject();
2095                 result = testSubject.getResource(resourceId, user);
2096         }
2097
2098         @Test
2099         public void testGetResourceByNameAndVersion() throws Exception {
2100                 ResourceBusinessLogic testSubject;
2101                 Resource resource = createResourceObject(true);
2102                 String resourceName = resource.getName();
2103                 String resourceVersion = resource.getVersion();
2104                 String userId = user.getUserId();
2105                 Either<Resource, ResponseFormat> result;
2106
2107                 when(toscaOperationFacade.getComponentByNameAndVersion(ComponentTypeEnum.RESOURCE, resourceName,
2108                                 resourceVersion)).thenReturn(Either.left(resource));
2109
2110                 // default test
2111                 testSubject = createTestSubject();
2112                 result = testSubject.getResourceByNameAndVersion(resourceName, resourceVersion, userId);
2113         }
2114
2115         @Test
2116         public void testGetUserAdmin() throws Exception {
2117                 ResourceBusinessLogic testSubject;
2118                 IUserBusinessLogic result;
2119
2120                 // default test
2121                 testSubject = createTestSubject();
2122                 result = testSubject.getUserAdmin();
2123         }
2124
2125         @Test
2126         public void testHandleNodeTypeArtifacts() throws Exception {
2127                 ResourceBusinessLogic testSubject;
2128                 Resource nodeTypeResource = null;
2129                 Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle = null;
2130                 List<ArtifactDefinition> createdArtifacts = null;
2131                 User user = null;
2132                 boolean inTransaction = false;
2133                 boolean ignoreLifecycleState = false;
2134                 Either<List<ArtifactDefinition>, ResponseFormat> result;
2135
2136                 // default test
2137                 testSubject = createTestSubject();
2138                 result = testSubject.handleNodeTypeArtifacts(nodeTypeResource, nodeTypeArtifactsToHandle, createdArtifacts,
2139                                 user, inTransaction, ignoreLifecycleState);
2140         }
2141
2142         
2143         @Test
2144         public void testIsResourceExist() throws Exception {
2145                 ResourceBusinessLogic testSubject;
2146                 Resource resource = createResourceObject(true);
2147                 String resourceName = resource.getName();
2148                 boolean result;
2149
2150                 // default test
2151                 Either<Component, StorageOperationStatus> getLatestResult = Either.right(StorageOperationStatus.NOT_FOUND);
2152                 when(toscaOperationFacade.getLatestByName(resource.getName())).thenReturn(getLatestResult);
2153                 testSubject = createTestSubject();
2154                 result = testSubject.isResourceExist(resourceName);
2155         }
2156
2157         @Test
2158         public void testPropagateStateToCertified() throws Exception {
2159                 ResourceBusinessLogic testSubject;
2160                 Resource resource = createResourceObject(true);
2161                 ;
2162                 LifecycleChangeInfoWithAction lifecycleChangeInfo = null;
2163                 boolean inTransaction = false;
2164                 boolean needLock = false;
2165                 boolean forceCertificationAllowed = false;
2166                 Either<Resource, ResponseFormat> result;
2167
2168                 // default test
2169                 testSubject = createTestSubject();
2170                 result = testSubject.propagateStateToCertified(user, resource, lifecycleChangeInfo, inTransaction, needLock,
2171                                 forceCertificationAllowed);
2172         }
2173
2174         @Test
2175         public void testSetApplicationDataTypeCache() throws Exception {
2176                 ResourceBusinessLogic testSubject;
2177                 ApplicationDataTypeCache applicationDataTypeCache = null;
2178
2179                 // default test
2180                 testSubject = createTestSubject();
2181                 testSubject.setApplicationDataTypeCache(applicationDataTypeCache);
2182         }
2183
2184         @Test
2185         public void testSetArtifactsManager() throws Exception {
2186                 ResourceBusinessLogic testSubject;
2187                 ArtifactsBusinessLogic artifactsManager = null;
2188
2189                 // default test
2190                 testSubject = createTestSubject();
2191                 testSubject.setArtifactsManager(artifactsManager);
2192         }
2193
2194         @Test
2195         public void testSetCacheManagerOperation() throws Exception {
2196                 ResourceBusinessLogic testSubject;
2197                 ICacheMangerOperation cacheManagerOperation = null;
2198
2199                 // default test
2200                 testSubject = createTestSubject();
2201                 testSubject.setCacheManagerOperation(cacheManagerOperation);
2202         }
2203
2204         @Test
2205         public void testSetCapabilityTypeOperation() throws Exception {
2206                 ResourceBusinessLogic testSubject;
2207                 ICapabilityTypeOperation capabilityTypeOperation = null;
2208
2209                 // default test
2210                 testSubject = createTestSubject();
2211                 testSubject.setCapabilityTypeOperation(capabilityTypeOperation);
2212         }
2213
2214         @Test
2215         public void testSetComponentsUtils() throws Exception {
2216                 ResourceBusinessLogic testSubject;
2217                 ComponentsUtils componentsUtils = null;
2218
2219                 // default test
2220                 testSubject = createTestSubject();
2221                 testSubject.setComponentsUtils(componentsUtils);
2222         }
2223
2224         @Test
2225         public void testSetDeploymentArtifactsPlaceHolder() throws Exception {
2226                 ResourceBusinessLogic testSubject;
2227                 Component component = createResourceObject(true);
2228                 ;
2229
2230                 // default test
2231                 testSubject = createTestSubject();
2232                 testSubject.setDeploymentArtifactsPlaceHolder(component, user);
2233         }
2234
2235         @Test
2236         public void testSetCsarOperation() throws Exception {
2237                 ResourceBusinessLogic testSubject;
2238                 CsarOperation csarOperation = null;
2239
2240                 // default test
2241                 testSubject = createTestSubject();
2242                 testSubject.setCsarOperation(csarOperation);
2243         }
2244
2245         @Test
2246         public void testSetElementDao() throws Exception {
2247                 ResourceBusinessLogic testSubject;
2248                 IElementOperation elementDao = null;
2249
2250                 // default test
2251                 testSubject = createTestSubject();
2252                 testSubject.setElementDao(elementDao);
2253         }
2254
2255         @Test
2256         public void testSetInterfaceOperation() throws Exception {
2257                 ResourceBusinessLogic testSubject;
2258                 InterfaceOperation interfaceOperation = null;
2259
2260                 // default test
2261                 testSubject = createTestSubject();
2262                 testSubject.setInterfaceOperation(interfaceOperation);
2263         }
2264
2265         @Test
2266         public void testSetInterfaceTypeOperation() throws Exception {
2267                 ResourceBusinessLogic testSubject;
2268                 IInterfaceLifecycleOperation interfaceTypeOperation = null;
2269
2270                 // default test
2271                 testSubject = createTestSubject();
2272                 testSubject.setInterfaceTypeOperation(interfaceTypeOperation);
2273         }
2274
2275         @Test
2276         public void testSetLifecycleManager() throws Exception {
2277                 ResourceBusinessLogic testSubject;
2278                 LifecycleBusinessLogic lifecycleBusinessLogic = null;
2279
2280                 // default test
2281                 testSubject = createTestSubject();
2282                 testSubject.setLifecycleManager(lifecycleBusinessLogic);
2283         }
2284
2285         @Test
2286         public void testSetPropertyOperation() throws Exception {
2287                 ResourceBusinessLogic testSubject;
2288                 IPropertyOperation propertyOperation = null;
2289
2290                 // default test
2291                 testSubject = createTestSubject();
2292                 testSubject.setPropertyOperation(propertyOperation);
2293         }
2294
2295         @Test
2296         public void testSetUserAdmin() throws Exception {
2297                 ResourceBusinessLogic testSubject;
2298                 UserBusinessLogic userAdmin = null;
2299
2300                 // default test
2301                 testSubject = createTestSubject();
2302                 testSubject.setUserAdmin(userAdmin);
2303         }
2304
2305         @Test
2306         public void testShouldUpgradeToLatestDerived() throws Exception {
2307                 ResourceBusinessLogic testSubject;
2308                 Resource clonedComponent = createResourceObject(true);
2309                 ;
2310                 Either<Component, ActionStatus> result;
2311
2312                 Either<Component, StorageOperationStatus> getLatestResult = Either.right(StorageOperationStatus.OK);
2313                 when(toscaOperationFacade.shouldUpgradeToLatestDerived(clonedComponent)).thenReturn(getLatestResult);
2314
2315                 // default test
2316                 testSubject = createTestSubject();
2317                 result = testSubject.shouldUpgradeToLatestDerived(clonedComponent);
2318         }
2319
2320         @Test
2321         public void testUpdateResourceMetadata() throws Exception {
2322                 ResourceBusinessLogic testSubject;
2323                 String resourceIdToUpdate = "";
2324                 Resource newResource = createResourceObject(true);
2325                 Resource currentResource = createResourceObject(true);
2326                 boolean inTransaction = false;
2327                 Either<Resource, ResponseFormat> result;
2328
2329                 // default test
2330                 Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(newResource));
2331                 when(toscaOperationFacade.getToscaElement(newResource.getUniqueId())).thenReturn(eitherUpdate);
2332                 testSubject = createTestSubject();
2333                 result = testSubject.updateResourceMetadata(resourceIdToUpdate, newResource, currentResource, user,
2334                                 inTransaction);
2335         }
2336
2337         @Test
2338         public void testValidateAndUpdateResourceFromCsar() throws Exception {
2339                 ResourceBusinessLogic testSubject;
2340                 Resource resource = createResourceObject(true);
2341                 ;
2342                 Map<String, byte[]> csarUIPayload = null;
2343                 String payloadName = "";
2344                 String resourceUniqueId = "";
2345                 Either<Resource, ResponseFormat> result;
2346
2347                 // test 1
2348                 testSubject = createTestSubject();
2349                 payloadName = null;
2350                 result = testSubject.validateAndUpdateResourceFromCsar(resource, user, csarUIPayload, payloadName,
2351                                 resourceUniqueId);
2352
2353                 // test 2
2354                 testSubject = createTestSubject();
2355                 payloadName = "";
2356                 result = testSubject.validateAndUpdateResourceFromCsar(resource, user, csarUIPayload, payloadName,
2357                                 resourceUniqueId);
2358         }
2359
2360         @Test
2361         public void testValidateDerivedFromNotEmpty() throws Exception {
2362                 ResourceBusinessLogic testSubject;
2363                 Resource resource = createResourceObject(true);
2364                 AuditingActionEnum actionEnum = AuditingActionEnum.ADD_ECOMP_USER_CREDENTIALS;
2365                 Either<Boolean, ResponseFormat> result;
2366
2367                 // default test
2368                 testSubject = createTestSubject();
2369                 result = testSubject.validateDerivedFromNotEmpty(user, resource, actionEnum);
2370         }
2371
2372         @Test
2373         public void testValidateResourceBeforeCreate() throws Exception {
2374                 ResourceBusinessLogic testSubject;
2375                 Resource resource = createResourceObject(true);
2376                 ;
2377                 AuditingActionEnum actionEnum = AuditingActionEnum.ADD_CATEGORY;
2378                 boolean inTransaction = false;
2379                 CsarInfo csarInfo = null;
2380                 Either<Resource, ResponseFormat> result;
2381
2382                 // default test
2383                 testSubject = createTestSubject();
2384                 result = testSubject.validateResourceBeforeCreate(resource, user, actionEnum, inTransaction, csarInfo);
2385         }
2386
2387         @Test
2388         public void testValidateResourceCreationFromNodeType() throws Exception {
2389                 ResourceBusinessLogic testSubject;
2390                 Resource resource = createResourceObject(true);
2391                 ;
2392                 User creator = user;
2393                 Either<Boolean, ResponseFormat> result;
2394
2395                 // default test
2396                 testSubject = createTestSubject();
2397                 result = testSubject.validateResourceCreationFromNodeType(resource, creator);
2398         }
2399
2400         @Test
2401         public void testValidatePropertiesDefaultValues() throws Exception {
2402                 ResourceBusinessLogic testSubject;
2403                 Resource resource = createResourceObject(true);
2404                 Either<Boolean, ResponseFormat> result;
2405
2406                 // default test
2407                 testSubject = createTestSubject();
2408                 result = testSubject.validatePropertiesDefaultValues(resource);
2409         }
2410
2411         @Test
2412         public void testValidateResourceNameExists() throws Exception {
2413                 ResourceBusinessLogic testSubject;
2414                 Resource recource = createResourceObject(true);
2415                 String resourceName = recource.getName();
2416                 ResourceTypeEnum resourceTypeEnum = ResourceTypeEnum.VF;
2417                 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.RESOURCE;
2418                 String userId = user.getUserId();
2419                 Either<Map<String, Boolean>, ResponseFormat> result;
2420
2421                 // default test
2422
2423                 Either<Boolean, StorageOperationStatus> dataModelResponse = Either.left(true);
2424                 when(toscaOperationFacade.validateComponentNameUniqueness(resourceName, resourceTypeEnum, componentTypeEnum))
2425                                 .thenReturn(dataModelResponse);
2426                 testSubject = createTestSubject();
2427                 result = testSubject.validateResourceNameExists(resourceName, resourceTypeEnum, userId);
2428         }
2429
2430         @Test
2431         public void testValidateVendorReleaseName() throws Exception {
2432                 ResourceBusinessLogic testSubject;
2433                 String vendorRelease = "";
2434                 Either<Boolean, ResponseFormat> result;
2435
2436                 // test 1
2437                 testSubject = createTestSubject();
2438                 vendorRelease = null;
2439                 result = testSubject.validateVendorReleaseName(vendorRelease);
2440
2441                 // test 2
2442                 testSubject = createTestSubject();
2443                 vendorRelease = "";
2444                 result = testSubject.validateVendorReleaseName(vendorRelease);
2445         }
2446
2447         @Test
2448         public void testValidateVendorReleaseName_1() throws Exception {
2449                 ResourceBusinessLogic testSubject;
2450                 Resource resource = createResourceObject(true);
2451                 AuditingActionEnum actionEnum = null;
2452                 Either<Boolean, ResponseFormat> result;
2453
2454                 // default test
2455                 testSubject = createTestSubject();
2456                 result = testSubject.validateVendorReleaseName(user, resource, actionEnum);
2457         }
2458
2459         @Test
2460         public void testIsResourceNameEquals() throws Exception {
2461                 ResourceBusinessLogic testSubject;
2462                 Resource currentResource = createResourceObject(true);
2463                 Resource updateInfoResource = createResourceObject(true);
2464                 updateInfoResource.setName("name");
2465                 boolean result;
2466
2467                 // default test
2468                 testSubject = createTestSubject();
2469                 result = Deencapsulation.invoke(testSubject, "isResourceNameEquals",
2470                                 new Object[] { currentResource, updateInfoResource });
2471         }
2472
2473         @Test
2474         public void testAddCvfcSuffixToResourceName() throws Exception {
2475                 ResourceBusinessLogic testSubject;
2476                 Resource currentResource = createResourceObject(true);
2477                 String resourceName = currentResource.getName();
2478                 String result;
2479
2480                 // default test
2481                 testSubject = createTestSubject();
2482                 result = Deencapsulation.invoke(testSubject, "addCvfcSuffixToResourceName", new Object[] { resourceName });
2483         }
2484
2485         
2486         @Test
2487         public void testCreateResource() throws Exception {
2488         ResourceBusinessLogic testSubject;
2489         Resource resource = createResourceObject(true);
2490         AuditingActionEnum auditingAction = null;
2491         Map<String,byte[]> csarUIPayload = null;
2492         String payloadName = "";
2493         Either<Resource,ResponseFormat> result;
2494         
2495         // test 1 1
2496         testSubject=createTestSubject();
2497     
2498     List<Role> listOfRoles = new ArrayList<>();
2499     listOfRoles.add(Role.ADMIN);
2500     listOfRoles.add(Role.DESIGNER);
2501     Either<Boolean, ResponseFormat> validationResult = Either.left(true);
2502         when(userValidations.validateUserRole(user, listOfRoles)).thenReturn(validationResult);
2503         
2504         
2505         
2506         result=testSubject.createResource(resource, auditingAction, user, csarUIPayload, payloadName);
2507         
2508         // test 2 2
2509         testSubject=createTestSubject();payloadName = "";
2510         result=testSubject.createResource(resource, auditingAction, user, csarUIPayload, payloadName);
2511         
2512         // test 3
2513         testSubject=createTestSubject();payloadName = null;
2514         result=testSubject.createResource(resource, auditingAction, user, csarUIPayload, payloadName);
2515         
2516         // test 4
2517         testSubject=createTestSubject();payloadName = "";
2518         result=testSubject.createResource(resource, auditingAction, user, csarUIPayload, payloadName);
2519         }
2520
2521         
2522         @Test
2523         public void testGetElementDao_1() throws Exception {
2524         ResourceBusinessLogic testSubject;IElementOperation result;
2525         
2526         // default test
2527         testSubject=createTestSubject();result=testSubject.getElementDao();
2528         }
2529
2530         @Test(expected=UnsupportedOperationException.class)
2531         public void testCreateResource_1() throws Exception {
2532         ResourceBusinessLogic testSubject;
2533         Resource resource = createResourceObject(true);;
2534         AuditingActionEnum auditingAction = AuditingActionEnum.ADD_CATEGORY;
2535         Map<String,byte[]> csarUIPayload = new HashMap<>();
2536         String payloadName = "";
2537         Either<Resource,ResponseFormat> result;
2538         
2539            List<Role> listOfRoles = new ArrayList<>();
2540             listOfRoles.add(Role.ADMIN);
2541             listOfRoles.add(Role.DESIGNER);
2542             Either<Boolean, ResponseFormat> validationResult = Either.left(true);
2543                 when(userValidations.validateUserRole(user, listOfRoles)).thenReturn(validationResult);
2544         
2545         // test 1 1
2546         testSubject=createTestSubject();
2547         result=testSubject.createResource(resource, auditingAction, user, csarUIPayload, payloadName);
2548         
2549         }
2550
2551         
2552         @Test
2553         public void testValidateCsarIsNotAlreadyUsed() throws Exception {
2554         ResourceBusinessLogic testSubject;
2555         Wrapper<ResponseFormat> responseWrapper = new Wrapper<ResponseFormat>();
2556         Resource oldResource = createResourceObject(true);
2557         Resource resource = createResourceObject(true);
2558         String csarUUID = "";
2559     
2560     Either<Resource, StorageOperationStatus> resourceLinkedToCsarRes = Either.right(StorageOperationStatus.BAD_REQUEST);
2561         when(toscaOperationFacade.getLatestComponentByCsarOrName(ComponentTypeEnum.RESOURCE, csarUUID, resource.getSystemName()))
2562                         .thenReturn(resourceLinkedToCsarRes);
2563     
2564         // default test
2565         testSubject=createTestSubject();Deencapsulation.invoke(testSubject, "validateCsarIsNotAlreadyUsed", new Object[]{responseWrapper, resource, oldResource, csarUUID, user});
2566         }
2567
2568         
2569         @Test
2570         public void testValidateCsarUuidMatching() throws Exception {
2571         ResourceBusinessLogic testSubject;
2572         Wrapper<ResponseFormat> responseWrapper = new Wrapper<ResponseFormat>();
2573         Resource resource = createResourceObject(true);
2574         Resource oldResource = createResourceObject(true);
2575         String csarUUID = "";
2576         String resourceUniqueId = "";
2577         
2578         
2579         
2580         // default test
2581         testSubject=createTestSubject();Deencapsulation.invoke(testSubject, "validateCsarUuidMatching", new Object[]{responseWrapper, resource, oldResource, csarUUID, resourceUniqueId, user});
2582         }
2583
2584         
2585         @Test
2586         public void testGetResourceByUniqueId() throws Exception {
2587         ResourceBusinessLogic testSubject;
2588         Wrapper<ResponseFormat> responseWrapper = new Wrapper<ResponseFormat>();
2589         Resource resource = createResourceObject(true);
2590         String resourceUniqueId = resource.getUniqueId();
2591         Resource result;
2592         
2593         // default test
2594         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getResourceByUniqueId", new Object[]{responseWrapper, resourceUniqueId});
2595         }
2596
2597         
2598         @Test
2599         public void testOverrideImmutableMetadata() throws Exception {
2600         ResourceBusinessLogic testSubject;
2601         Resource oldRresource = createResourceObject(true);
2602         Resource resource = createResourceObject(true);
2603         
2604         
2605         // default test
2606         testSubject=createTestSubject();Deencapsulation.invoke(testSubject, "overrideImmutableMetadata", new Object[]{oldRresource, resource});
2607         }
2608
2609         
2610         @Test
2611         public void testFindNodeTypesArtifactsToHandle() throws Exception {
2612         ResourceBusinessLogic testSubject;
2613         NodeTypeInfo nodeTypeInfos = new NodeTypeInfo();
2614         Map<String,NodeTypeInfo> nodeTypesInfo = new HashMap<>();
2615         nodeTypesInfo.put("key", nodeTypeInfos);
2616         
2617         CsarInfo csarInfo = new CsarInfo("", new User(), "", null, "", false);
2618         Resource oldResource = createResourceObject(true);
2619         Either<Map<String,EnumMap<ArtifactOperationEnum,List<ArtifactDefinition>>>,ResponseFormat> result;
2620         
2621         // default test
2622         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "findNodeTypesArtifactsToHandle", new Object[]{nodeTypesInfo, csarInfo, oldResource});
2623         }
2624
2625         
2626         @Test(expected=IllegalArgumentException.class)
2627         public void testFindNodeTypeArtifactsToHandle() throws Exception {
2628         ResourceBusinessLogic testSubject;
2629         Resource curNodeType = createResourceObject(true);
2630         ArtifactDefinition artifactDefinition = new ArtifactDefinition();
2631         List<ArtifactDefinition> extractedArtifacts = new ArrayList<>();
2632         extractedArtifacts.add(artifactDefinition);
2633         Either<EnumMap<ArtifactOperationEnum,List<ArtifactDefinition>>,ResponseFormat> result;
2634         
2635         // default test
2636         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "findNodeTypeArtifactsToHandle", new Object[]{curNodeType, artifactDefinition});
2637         }
2638
2639         
2640         @Test
2641         public void testCheckoutResource() throws Exception {
2642         ResourceBusinessLogic testSubject;
2643         Resource resource = createResourceObject(true);
2644         
2645         boolean inTransaction = false;
2646         Either<Resource,ResponseFormat> result;
2647         
2648         // default test
2649         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "checkoutResource", new Object[]{resource, user, inTransaction});
2650         }
2651
2652         
2653
2654
2655         
2656
2657         
2658         @Test
2659         public void testExtractNodeTypes() throws Exception {
2660         ResourceBusinessLogic testSubject;
2661         Map<String,Object> nodes = new HashMap<>();
2662
2663         Map<String,Object> mappedToscaTemplate = new HashMap<>();
2664         mappedToscaTemplate.put("node_types", new Object());
2665         
2666         
2667         // default test
2668         testSubject=createTestSubject();Deencapsulation.invoke(testSubject, "extractNodeTypes", new Object[]{nodes, mappedToscaTemplate});
2669         }
2670
2671         @Test
2672         public void testMarkNestedVfc() throws Exception {
2673         ResourceBusinessLogic testSubject;
2674         Map<String,Object> mappedToscaTemplate = new HashMap<>();
2675         Map<String,NodeTypeInfo> nodeTypesInfo = new HashMap<>();
2676         
2677         
2678         // default test
2679         testSubject=createTestSubject();Deencapsulation.invoke(testSubject, "markNestedVfc", new Object[]{mappedToscaTemplate, nodeTypesInfo});
2680         }
2681
2682         
2683         @Test
2684         public void testIsGlobalSubstitute() throws Exception {
2685         ResourceBusinessLogic testSubject;String fileName = "";
2686         boolean result;
2687         
2688         // default test
2689         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "isGlobalSubstitute", new Object[]{fileName});
2690         }
2691
2692         
2693         @Test
2694         public void testValidateAndParseCsar() throws Exception {
2695         ResourceBusinessLogic testSubject;
2696         Resource resource = createResourceObject(true);
2697         
2698         String csarUUID = "";
2699         Either<Map<String,byte[]>,StorageOperationStatus> csar = Either.right(StorageOperationStatus.BAD_REQUEST);
2700         Either<ImmutablePair<String,String>,ResponseFormat> result;
2701         
2702         // default test
2703         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateAndParseCsar", new Object[]{resource, user, csarUUID, csar});
2704         }
2705
2706         
2707         @Test
2708         public void testValidateResourceBeforeCreate_1() throws Exception {
2709         ResourceBusinessLogic testSubject;
2710         Resource resource = createResourceObject(true);
2711         
2712         boolean inTransaction = false;
2713         Either<Resource,ResponseFormat> result;
2714         
2715            List<Role> listOfRoles = new ArrayList<>();
2716             listOfRoles.add(Role.ADMIN);
2717             listOfRoles.add(Role.DESIGNER);
2718             Either<Boolean, ResponseFormat> validationResult = Either.left(true);
2719                 when(userValidations.validateUserRole(user, listOfRoles)).thenReturn(validationResult);
2720         
2721         // default test
2722         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateResourceBeforeCreate", new Object[]{resource, user, inTransaction});
2723         }
2724
2725         
2726
2727         
2728         @Test
2729         public void testCreateResourcesFromYamlNodeTypesList() throws Exception {
2730         ResourceBusinessLogic testSubject;
2731         String yamlName = "";
2732         Resource resource = createResourceObject(true);
2733         Map<String,Object> mappedToscaTemplate = new HashMap<>();
2734         boolean needLock = false;
2735         Map<String,EnumMap<ArtifactOperationEnum,List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
2736         List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
2737         Map<String,NodeTypeInfo> nodeTypesInfo = new HashMap<>();
2738         CsarInfo csarInfo = new CsarInfo("", new User(), "", null, "", false);
2739         Either<Map<String,Resource>,ResponseFormat> result;
2740         
2741         // default test
2742         testSubject=createTestSubject();result=testSubject.createResourcesFromYamlNodeTypesList(yamlName, resource, mappedToscaTemplate, needLock, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo);
2743         }
2744
2745
2746         
2747         @Test
2748         public void testFillResourceMetadata() throws Exception {
2749         ResourceBusinessLogic testSubject;
2750         String yamlName = "";
2751         Resource resourceVf = createResourceObject(true);;
2752         String nodeName = "";
2753         
2754         Either<UploadResourceInfo,ResponseFormat> result;
2755         
2756         // default test
2757         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "fillResourceMetadata", new Object[]{yamlName, resourceVf, nodeName, user});
2758         }
2759
2760
2761
2762         
2763         @Test
2764         public void testBuildCvfcName() throws Exception {
2765         ResourceBusinessLogic testSubject;
2766         Resource resource = createResourceObject(true);
2767         String resourceVfName = "ResourceResource12";
2768         String nodeName ="org.openecomp.resource.VF.ResourceResource12";
2769         String result;
2770         
2771         // default test
2772         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "buildCvfcName", new Object[]{resourceVfName, nodeName});
2773         }
2774
2775         @Test
2776         public void testUpdateGroupMembersUsingResource() throws Exception {
2777         ResourceBusinessLogic testSubject;
2778         GroupDefinition groupDefinition = new GroupDefinition();
2779         Map<String,GroupDefinition> groups = new HashMap<>();
2780         groups.put("key", groupDefinition);
2781         Resource component = createResourceObject(true);
2782         Either<List<GroupDefinition>,ResponseFormat> result;
2783         
2784         // test 1
2785         testSubject=createTestSubject();
2786         result=Deencapsulation.invoke(testSubject, "updateGroupMembersUsingResource", new Object[]{groups, component});
2787         }
2788
2789         
2790         @Test
2791         public void testValidateCyclicGroupsDependencies() throws Exception {
2792         ResourceBusinessLogic testSubject;
2793         GroupDefinition groupDefinition = new GroupDefinition();
2794         Map<String,GroupDefinition> groups = new HashMap<>();
2795         groups.put("key", groupDefinition);
2796         Either<Boolean,ResponseFormat> result;
2797         
2798         // default test
2799         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateCyclicGroupsDependencies", new Object[]{groups});
2800         }
2801
2802         
2803         @Test
2804         public void testFillAllGroupMemebersRecursivly() throws Exception {
2805         ResourceBusinessLogic testSubject;
2806         String groupName = "";
2807         GroupDefinition groupDefinition = new GroupDefinition();
2808         Map<String,GroupDefinition> groups = new HashMap<>();
2809         groups.put("key", groupDefinition);
2810         Set<String> allGroupMembers = new HashSet<String>();
2811         allGroupMembers.add("aaa");
2812         
2813         // default test
2814         testSubject=createTestSubject();Deencapsulation.invoke(testSubject, "fillAllGroupMemebersRecursivly", new Object[]{groupName, groups, allGroupMembers});
2815         }
2816
2817         
2818         @Test
2819         public void testIsfillGroupMemebersRecursivlyStopCondition() throws Exception {
2820         ResourceBusinessLogic testSubject;
2821         String groupName = "";
2822         GroupDefinition groupDefinition = new GroupDefinition();
2823         Map<String,GroupDefinition> groups = new HashMap<>();
2824         groups.put("key", groupDefinition);
2825         Set<String> allGroupMembers = new HashSet<String>();
2826         allGroupMembers.add("aaa");
2827         boolean result;
2828         
2829         // default test
2830         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "isfillGroupMemebersRecursivlyStopCondition", new Object[]{groupName, groups, allGroupMembers});
2831         }
2832
2833         
2834
2835
2836         
2837         @Test
2838         public void testHandleAndAddExtractedVfcsArtifacts() throws Exception {
2839         ResourceBusinessLogic testSubject;
2840         ArtifactDefinition artifactDefinition = new ArtifactDefinition();
2841         
2842         List<ArtifactDefinition> vfcArtifacts = new ArrayList<>();
2843         vfcArtifacts.add(artifactDefinition);
2844         List<ArtifactDefinition> artifactsToAdd = new ArrayList<>();
2845         artifactsToAdd.add(artifactDefinition);
2846         
2847         // default test
2848         testSubject=createTestSubject();Deencapsulation.invoke(testSubject, "handleAndAddExtractedVfcsArtifacts", new Object[]{vfcArtifacts, artifactsToAdd});
2849         }
2850
2851         
2852
2853         
2854         @Test
2855         public void testHandleVfCsarArtifacts() throws Exception {
2856         ResourceBusinessLogic testSubject;
2857         Resource resource = createResourceObject(true);
2858         CsarInfo csarInfo = new CsarInfo("", new User(), "", null, "", false);
2859         ArtifactOperationEnum download = ArtifactOperationEnum.CREATE;
2860         ArtifactsBusinessLogic artb = new ArtifactsBusinessLogic();
2861         
2862         ArtifactOperationInfo operation = artb.new ArtifactOperationInfo(false, false, download);
2863         List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
2864         boolean shouldLock = false;
2865         boolean inTransaction = false;
2866         Either<Resource,ResponseFormat> result;
2867         
2868         // default test
2869         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "handleVfCsarArtifacts", new Object[]{resource, csarInfo, createdArtifacts, operation, shouldLock, inTransaction});
2870         }
2871
2872         
2873
2874         @Test
2875         public void testIsArtifactDeletionRequired() throws Exception {
2876         ResourceBusinessLogic testSubject;
2877         String artifactId = "";
2878         byte[] artifactFileBytes = new byte[]{' '};
2879         boolean isFromCsar = false;
2880         boolean result;
2881         
2882         // default test
2883         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "isArtifactDeletionRequired", new Object[]{artifactId, artifactFileBytes, isFromCsar});
2884         }
2885
2886         
2887         
2888
2889         @Test
2890         public void testValidateArtifactNames() throws Exception {
2891         ResourceBusinessLogic testSubject;
2892         NonMetaArtifactInfo nonMetaArtifactInfo = new NonMetaArtifactInfo(operationId, operationId, null, null, null, operationId, false);
2893         List<NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>();
2894         artifactPathAndNameList.add(nonMetaArtifactInfo);
2895         Either<Boolean,String> result;
2896         
2897         // default test
2898         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateArtifactNames", new Object[]{artifactPathAndNameList});
2899         }
2900
2901         
2902         @Test
2903         public void testIsNonMetaArtifact() throws Exception {
2904         ResourceBusinessLogic testSubject;
2905         ArtifactDefinition artifact = new ArtifactDefinition();
2906         boolean result;
2907         
2908         // default test
2909         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "isNonMetaArtifact", new Object[]{artifact});
2910         }
2911
2912         
2913         @Test
2914         public void testIsValidArtifactType() throws Exception {
2915         ResourceBusinessLogic testSubject;
2916         ArtifactDefinition artifact = new ArtifactDefinition();
2917         boolean result;
2918         
2919         // default test
2920         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "isValidArtifactType", new Object[]{artifact});
2921         }
2922
2923         
2924         @Test
2925         public void testCreateResourceInstancesRelations() throws Exception {
2926         ResourceBusinessLogic testSubject;
2927         String yamlName = "";
2928         Resource resource = createResourceObject(true);
2929         UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
2930         
2931         Map<String,UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
2932         uploadResInstancesMap.put("key", uploadComponentInstanceInfo);
2933         Either<Resource,ResponseFormat> result;
2934         
2935         // test 1
2936         testSubject=createTestSubject();
2937         result=Deencapsulation.invoke(testSubject, "createResourceInstancesRelations", new Object[]{user, yamlName, resource, uploadResInstancesMap});
2938         }
2939
2940         
2941         @Test
2942         public void testUpdatePropertyValues() throws Exception {
2943         ResourceBusinessLogic testSubject;
2944         List<ComponentInstanceProperty> properties = new ArrayList<>();
2945         Map<String,UploadPropInfo> newProperties = new HashMap<>();
2946         Map<String,DataTypeDefinition> allDataTypes = new HashMap<>();;
2947         Either<Boolean,ResponseFormat> result;
2948         
2949         // default test
2950         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "updatePropertyValues", new Object[]{properties, newProperties, allDataTypes});
2951         }
2952
2953         
2954         @Test
2955         public void testUpdatePropertyValue() throws Exception {
2956         ResourceBusinessLogic testSubject;
2957         ComponentInstanceProperty property = new ComponentInstanceProperty();
2958         UploadPropInfo propertyInfo = new UploadPropInfo();
2959         Map<String,DataTypeDefinition> allDataTypes = new HashMap<>();
2960         Either<String,StorageOperationStatus> result;
2961         
2962         // test 1
2963         testSubject=createTestSubject();
2964         result=Deencapsulation.invoke(testSubject, "updatePropertyValue", new Object[]{property, propertyInfo, allDataTypes});
2965         }
2966
2967         
2968         @Test
2969         public void testUpdateCalculatedCapReqWithSubstitutionMappings() throws Exception {
2970         ResourceBusinessLogic testSubject;
2971         Resource resource = createResourceObject(true);
2972         UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
2973         Map<String,UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
2974         uploadResInstancesMap.put("key", uploadComponentInstanceInfo);
2975         
2976         Either<Resource,StorageOperationStatus> result;
2977         
2978         // default test
2979         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "updateCalculatedCapReqWithSubstitutionMappings", new Object[]{resource, uploadResInstancesMap});
2980         }
2981
2982         
2983         @Test
2984         public void testFillUpdatedInstCapabilitiesRequirements() throws Exception {
2985         ResourceBusinessLogic testSubject;
2986         List<ComponentInstance> componentInstances = new ArrayList<>();
2987         Map<String,UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
2988         Map<ComponentInstance,Map<String,List<CapabilityDefinition>>> updatedInstCapabilities = new HashMap<>();
2989         Map<ComponentInstance,Map<String,List<RequirementDefinition>>> updatedInstRequirements = new HashMap<>();
2990         
2991         
2992         // default test
2993         testSubject=createTestSubject();Deencapsulation.invoke(testSubject, "fillUpdatedInstCapabilitiesRequirements", new Object[]{componentInstances, uploadResInstancesMap, updatedInstCapabilities, updatedInstRequirements});
2994         }
2995         
2996         @Test
2997         public void testAddInputsValuesToRi() throws Exception {
2998         ResourceBusinessLogic testSubject;
2999         UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo();
3000         Resource resource = createResourceObject(true);
3001         Resource originResource = createResourceObject(true);;
3002         ComponentInstance currentCompInstance = new ComponentInstance();
3003         String yamlName = "aaa";
3004         Map<String,List<ComponentInstanceInput>> instInputs = new HashMap<>();
3005         Map<String,DataTypeDefinition> allDataTypes = new HashMap<>();
3006         ResponseFormat result;
3007         
3008         // default test
3009         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "addInputsValuesToRi", new Object[]{uploadComponentInstanceInfo, resource, originResource, currentCompInstance, yamlName, instInputs, allDataTypes});
3010         }
3011
3012         
3013
3014
3015         
3016         @Test
3017         public void testFindAvailableCapabilityByTypeOrName() throws Exception {
3018         ResourceBusinessLogic testSubject;
3019         RequirementDefinition validReq = new RequirementDefinition();
3020         validReq.setCapability(RESOURCE_NAME);
3021         validReq.setToscaPresentationValue(JsonPresentationFields.CAPAPILITY, null);
3022         ComponentInstance currentCapCompInstance = new ComponentInstance();
3023         Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
3024         currentCapCompInstance.setCapabilities(capabilities);
3025         UploadReqInfo uploadReqInfo = new UploadReqInfo();
3026         CapabilityDefinition result;
3027         
3028         // default test
3029         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "findAvailableCapabilityByTypeOrName", new Object[]{validReq, currentCapCompInstance, uploadReqInfo});
3030         }
3031
3032         
3033         @Test
3034         public void testFindAvailableCapability() throws Exception {
3035         ResourceBusinessLogic testSubject;
3036         RequirementDefinition validReq = new RequirementDefinition();
3037         validReq.setCapability(RESOURCE_NAME);
3038         validReq.setToscaPresentationValue(JsonPresentationFields.CAPAPILITY, null);
3039         ComponentInstance currentCapCompInstance = new ComponentInstance();
3040         Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
3041         currentCapCompInstance.setCapabilities(capabilities);
3042         UploadReqInfo uploadReqInfo = new UploadReqInfo();
3043         CapabilityDefinition result;
3044         
3045         // default test
3046         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "findAvailableCapability", new Object[]{validReq, currentCapCompInstance, uploadReqInfo});
3047         }
3048
3049         
3050         @Test
3051         public void testFindAviableCapability() throws Exception {
3052         ResourceBusinessLogic testSubject;
3053         RequirementDefinition validReq = new RequirementDefinition();
3054         validReq.setCapability(RESOURCE_NAME);
3055         validReq.setToscaPresentationValue(JsonPresentationFields.CAPAPILITY, null);
3056         ComponentInstance currentCapCompInstance = new ComponentInstance();
3057         Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
3058         currentCapCompInstance.setCapabilities(capabilities);
3059         CapabilityDefinition result;
3060         
3061         // default test
3062         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "findAviableCapability", new Object[]{validReq, currentCapCompInstance});
3063         }
3064
3065         
3066
3067
3068         
3069
3070
3071         
3072         @Test
3073         public void testCreateResourceInstances() throws Exception {
3074         ResourceBusinessLogic testSubject;
3075         String yamlName = "aa";
3076         Resource resource = createResourceObject(true);
3077         Map<String,UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
3078         boolean inTransaction = false;
3079         boolean needLock = false;
3080         Map<String,Resource> nodeNamespaceMap = new HashMap<>();
3081         Either<Resource,ResponseFormat> result;
3082         
3083         // test 1
3084         testSubject=createTestSubject();
3085         result=Deencapsulation.invoke(testSubject, "createResourceInstances", new Object[]{user, yamlName, resource,uploadResInstancesMap, inTransaction, needLock, nodeNamespaceMap});
3086         }
3087
3088         
3089         @Test
3090         public void testGetNamesToUpdate() throws Exception {
3091         ResourceBusinessLogic testSubject;
3092         UploadComponentInstanceInfo nodeTemplateInfo = new UploadComponentInstanceInfo();
3093         Map<String,List<String>> elements = new HashMap<>();
3094         Either<Map<String,String>,ResponseFormat> result;
3095         
3096         // default test
3097         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getNamesToUpdate", new Object[]{nodeTemplateInfo, elements});
3098         }
3099
3100         
3101         @Test
3102         public void testCreateInputPropList() throws Exception {
3103         ResourceBusinessLogic testSubject;
3104         UploadPropInfo propertyDef = new UploadPropInfo();
3105         List<Object> propValueList = new ArrayList<>();
3106         
3107         
3108         // default test
3109         testSubject=createTestSubject();Deencapsulation.invoke(testSubject, "createInputPropList", new Object[]{propertyDef, propValueList});
3110         }
3111
3112         
3113         @Test
3114         public void testCreateGetInputModuleFromMap() throws Exception {
3115         ResourceBusinessLogic testSubject;
3116         String propName = "aaa";
3117         Map<String,Object> propValue = new HashMap<>();;
3118         UploadPropInfo propertyDef = new UploadPropInfo();
3119         
3120         
3121         // default test
3122         testSubject=createTestSubject();Deencapsulation.invoke(testSubject, "createGetInputModuleFromMap", new Object[]{propName, propValue, propertyDef});
3123         }
3124
3125         
3126         @Test
3127         public void testValueContainsPattern() throws Exception {
3128         ResourceBusinessLogic testSubject;
3129         Pattern pattern = null;
3130         Object propValue = null;
3131         boolean result;
3132         
3133         // test 1
3134         testSubject=createTestSubject();propValue = null;
3135         result=Deencapsulation.invoke(testSubject, "valueContainsPattern", new Object[]{Pattern.class, Object.class});
3136         Assert.assertEquals(false, result);
3137         }
3138
3139
3140
3141         @Test
3142         public void testCreateCapModuleFromYaml() throws Exception {
3143         ResourceBusinessLogic testSubject;
3144         UploadComponentInstanceInfo nodeTemplateInfo = new UploadComponentInstanceInfo();
3145         Map<String,Object> nodeTemplateJsonMap = new HashMap<>();
3146         Either<Map<String,List<UploadCapInfo>>,ResponseFormat> result;
3147         
3148         // default test
3149         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createCapModuleFromYaml", new Object[]{nodeTemplateInfo, nodeTemplateJsonMap});
3150         }
3151
3152         
3153
3154
3155         
3156         @Test
3157         public void testCreateModuleNodeTemplateCap() throws Exception {
3158         ResourceBusinessLogic testSubject;Object capObject = null;
3159         Either<UploadCapInfo,ResponseFormat> result;
3160         
3161         // default test
3162         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createModuleNodeTemplateCap", new Object[]{Object.class});
3163         }
3164
3165         
3166         @Test
3167         public void testCreateModuleNodeTemplateReg() throws Exception {
3168         ResourceBusinessLogic testSubject;Object regObject = null;
3169         Either<UploadReqInfo,ResponseFormat> result;
3170         
3171         // default test
3172         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createModuleNodeTemplateReg", new Object[]{Object.class});
3173         }
3174
3175         
3176         
3177         @Test
3178         public void testNodeForceCertification() throws Exception {
3179         ResourceBusinessLogic testSubject;Resource resource = createResourceObject(true);
3180         
3181         LifecycleChangeInfoWithAction lifecycleChangeInfo = null;
3182         boolean inTransaction = false;
3183         boolean needLock = false;
3184         Either<Resource,ResponseFormat> result;
3185         
3186         // default test
3187         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "nodeForceCertification", new Object[]{Resource.class, user, LifecycleChangeInfoWithAction.class, inTransaction, needLock});
3188         }
3189
3190         
3191         @Test
3192         public void testCreateResourceByImport() throws Exception {
3193         ResourceBusinessLogic testSubject;
3194         Resource resource = createResourceObject(true);
3195         
3196         boolean isNormative = false;
3197         boolean isInTransaction = false;
3198         CsarInfo csarInfo = null;
3199         Either<ImmutablePair<Resource,ActionStatus>,ResponseFormat> result;
3200         
3201         // default test
3202         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createResourceByImport", new Object[]{resource, user, isNormative, isInTransaction, CsarInfo.class});
3203         }
3204
3205         
3206         
3207         @Test
3208         public void testMergeOldResourceMetadataWithNew() throws Exception {
3209         ResourceBusinessLogic testSubject;
3210         Resource oldResource = createResourceObject(true);
3211         Resource newResource = createResourceObject(true);;
3212         
3213         
3214         // default test
3215         testSubject=createTestSubject();Deencapsulation.invoke(testSubject, "mergeOldResourceMetadataWithNew", new Object[]{oldResource, newResource});
3216         }
3217
3218         
3219         @Test
3220         public void testPrepareResourceForUpdate() throws Exception {
3221         ResourceBusinessLogic testSubject;
3222         Resource latestResource = createResourceObject(true);;
3223         
3224         boolean inTransaction = false;
3225         boolean needLock = false;
3226         Either<Resource,ResponseFormat> result;
3227         
3228         // default test
3229         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "prepareResourceForUpdate", new Object[]{latestResource, user, inTransaction, needLock});
3230         }
3231
3232         
3233         @Test
3234         public void testValidateResourceBeforeCreate_2() throws Exception {
3235         ResourceBusinessLogic testSubject;Resource resource = createResourceObject(true);
3236         
3237         AuditingActionEnum actionEnum = null;
3238         boolean inTransaction = false;
3239         CsarInfo csarInfo = null;
3240         Either<Resource,ResponseFormat> result;
3241         
3242         // default test
3243         testSubject=createTestSubject();result=testSubject.validateResourceBeforeCreate(resource, user, actionEnum, inTransaction, csarInfo);
3244         }
3245
3246         
3247         @Test
3248         public void testValidateResourceType() throws Exception {
3249         ResourceBusinessLogic testSubject;
3250         Resource resource = createResourceObject(true);
3251         AuditingActionEnum actionEnum = AuditingActionEnum.ARTIFACT_DOWNLOAD;
3252         Either<Boolean,ResponseFormat> result;
3253         
3254         // default test
3255         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateResourceType", new Object[]{user, resource, actionEnum});
3256         }
3257
3258         
3259         @Test
3260         public void testValidateLifecycleTypesCreate() throws Exception {
3261         ResourceBusinessLogic testSubject;
3262         Resource resource = createResourceObject(true);
3263         AuditingActionEnum actionEnum = AuditingActionEnum.ARTIFACT_METADATA_UPDATE;
3264         Either<Boolean,ResponseFormat> result;
3265         
3266         // default test
3267         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateLifecycleTypesCreate", new Object[]{user, resource, actionEnum});
3268         }
3269
3270         
3271         @Test
3272         public void testValidateCapabilityTypesCreate() throws Exception {
3273         ResourceBusinessLogic testSubject;
3274         ICapabilityTypeOperation capabilityTypeOperation = new ICapabilityTypeOperation() {
3275                 
3276                 @Override
3277                 public Either<CapabilityTypeDefinition, StorageOperationStatus> getCapabilityType(String uniqueId,
3278                                 boolean inTransaction) {
3279                         // TODO Auto-generated method stub
3280                         return null;
3281                 }
3282                 
3283                 @Override
3284                 public Either<CapabilityTypeDefinition, StorageOperationStatus> getCapabilityType(String uniqueId) {
3285                         // TODO Auto-generated method stub
3286                         return null;
3287                 }
3288                 
3289                 @Override
3290                 public Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType(
3291                                 CapabilityTypeDefinition capabilityTypeDefinition, boolean inTransaction) {
3292                         // TODO Auto-generated method stub
3293                         return null;
3294                 }
3295                 
3296                 @Override
3297                 public Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType(
3298                                 CapabilityTypeDefinition capabilityTypeDefinition) {
3299                         // TODO Auto-generated method stub
3300                         return null;
3301                 }
3302         };
3303         Resource resource = createResourceObject(true);
3304         AuditingActionEnum actionEnum = AuditingActionEnum.ARTIFACT_UPLOAD;
3305         boolean inTransaction = false;
3306         Either<Boolean,ResponseFormat> result;
3307         
3308         // default test
3309         testSubject=createTestSubject();
3310         result=Deencapsulation.invoke(testSubject, "validateCapabilityTypesCreate", new Object[]{user, capabilityTypeOperation, resource, actionEnum, inTransaction});
3311         }
3312
3313         
3314         @Test(expected=UnsupportedOperationException.class)
3315         public void testValidateCapabilityTypeExists() throws Exception {
3316         ResourceBusinessLogic testSubject;
3317         ICapabilityTypeOperation capabilityTypeOperation = new ICapabilityTypeOperation() {
3318                 
3319                 @Override
3320                 public Either<CapabilityTypeDefinition, StorageOperationStatus> getCapabilityType(String uniqueId,
3321                                 boolean inTransaction) {
3322                         // TODO Auto-generated method stub
3323                         return Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND);
3324                 }
3325                 
3326                 @Override
3327                 public Either<CapabilityTypeDefinition, StorageOperationStatus> getCapabilityType(String uniqueId) {
3328                         // TODO Auto-generated method stub
3329                         return Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND);
3330                 }
3331                 
3332                 @Override
3333                 public Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType(
3334                                 CapabilityTypeDefinition capabilityTypeDefinition, boolean inTransaction) {
3335                         // TODO Auto-generated method stub
3336                         return Either.right(StorageOperationStatus.ARTIFACT_NOT_FOUND);
3337                 }
3338                 
3339                 @Override
3340                 public Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType(
3341                                 CapabilityTypeDefinition capabilityTypeDefinition) {
3342                         // TODO Auto-generated method stub
3343                         return null;
3344                 }
3345         };
3346         Resource resource = createResourceObject(true);
3347         List<?> validationObjects = new ArrayList<>();
3348         AuditingActionEnum actionEnum = AuditingActionEnum.ADD_CATEGORY;
3349         Either<Boolean,ResponseFormat> eitherResult = Either.left(true);
3350         String type = "";
3351         boolean inTransaction = false;
3352         Either<Boolean,ResponseFormat> result;
3353         
3354         // default test
3355         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateCapabilityTypeExists", new Object[]{user, capabilityTypeOperation, resource, validationObjects, actionEnum,eitherResult, type, inTransaction});
3356         }
3357         
3358         @Test
3359         public void testCreateResourceTransaction() throws Exception {
3360         ResourceBusinessLogic testSubject;
3361         Resource resource = createResourceObject(true);
3362         
3363         boolean isNormative = false;
3364         boolean inTransaction = false;
3365         Either<Resource,ResponseFormat> result;
3366         
3367         // default test
3368         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createResourceTransaction", new Object[]{resource, user, isNormative, inTransaction});
3369         }
3370
3371         
3372         @Test
3373         public void testCreateArtifactsPlaceHolderData() throws Exception {
3374         ResourceBusinessLogic testSubject;
3375         Resource resource = createResourceObject(true);
3376         
3377         
3378         
3379         // default test
3380         testSubject=createTestSubject();Deencapsulation.invoke(testSubject, "createArtifactsPlaceHolderData", new Object[]{resource, user});
3381         }
3382
3383         
3384         @Test
3385         public void testSetInformationalArtifactsPlaceHolder() throws Exception {
3386         ResourceBusinessLogic testSubject;
3387         Resource resource = createResourceObject(true);
3388         
3389         
3390         
3391         // default test
3392         testSubject=createTestSubject();Deencapsulation.invoke(testSubject, "setInformationalArtifactsPlaceHolder", new Object[]{resource, user});
3393         }
3394
3395         
3396         @Test
3397         public void testDeleteResource() throws Exception {
3398         ResourceBusinessLogic testSubject;
3399         Resource resource = createResourceObject(true);
3400         String resourceId = resource.getUniqueId();
3401         ResponseFormat result;
3402         
3403           
3404         Either<Component, StorageOperationStatus> resourceStatus  = Either.right(StorageOperationStatus.BAD_REQUEST);
3405         when(toscaOperationFacade.getToscaElement(resourceId))
3406                                 .thenReturn(resourceStatus);
3407         
3408         // default test
3409         testSubject=createTestSubject();result=testSubject.deleteResource(resourceId, user);
3410         }
3411
3412         
3413         @Test
3414         public void testDeleteResourceByNameAndVersion() throws Exception {
3415         ResourceBusinessLogic testSubject;
3416         Resource resource = createResourceObject(true);
3417         String resourceName = resource.getName();
3418         String version = resource.getVersion();
3419         
3420         ResponseFormat result;
3421         
3422     Either<Component, StorageOperationStatus> resourceStatus = Either.right(StorageOperationStatus.BAD_REQUEST);
3423         when(toscaOperationFacade.getComponentByNameAndVersion(ComponentTypeEnum.RESOURCE, resourceName, version))
3424                         .thenReturn(resourceStatus);
3425         // default test
3426         testSubject=createTestSubject();result=testSubject.deleteResourceByNameAndVersion(resourceName, version, user);
3427         }
3428
3429         
3430         @Test
3431         public void testUpdateResourceMetadata_1() throws Exception {
3432         ResourceBusinessLogic testSubject;String resourceIdToUpdate = "";
3433         Resource newResource = createResourceObject(true);;
3434         Resource currentResource = createResourceObject(true);;
3435         
3436         boolean inTransaction = false;
3437         Either<Resource,ResponseFormat> result;
3438         
3439         // default test
3440         testSubject=createTestSubject();result=testSubject.updateResourceMetadata(resourceIdToUpdate, newResource, currentResource, user, inTransaction);
3441         }
3442
3443         
3444         @Test
3445         public void testUpdateComponentGroupName() throws Exception {
3446         ResourceBusinessLogic testSubject;
3447         String replacePattern = "";
3448         String with = "";
3449         List<GroupDefinition> oldGroup = new ArrayList<>();
3450         Either<List<GroupDefinition>,Boolean> result;
3451         
3452         // test 1
3453         testSubject=createTestSubject();
3454         result=Deencapsulation.invoke(testSubject, "updateComponentGroupName", new Object[]{replacePattern, with, oldGroup});
3455         
3456         }
3457
3458         
3459         @Test
3460         public void testIsComponentNameChanged() throws Exception {
3461         ResourceBusinessLogic testSubject;
3462         Resource newResource = createResourceObject(true);
3463         Resource oldResource = createResourceObject(true);
3464         boolean result;
3465         
3466         // test 1
3467         testSubject=createTestSubject();
3468         result=Deencapsulation.invoke(testSubject, "isComponentNameChanged", new Object[]{oldResource, newResource});
3469         }
3470
3471         
3472         @Test
3473         public void testValidateResourceFieldsBeforeCreate() throws Exception {
3474         ResourceBusinessLogic testSubject;
3475         Resource resource = createResourceObject(true);
3476         AuditingActionEnum actionEnum = AuditingActionEnum.ACTIVATE_SERVICE_BY_API;
3477         boolean inTransaction = false;
3478         Either<Boolean,ResponseFormat> result;
3479         
3480         // default test
3481         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateResourceFieldsBeforeCreate", new Object[]{user, resource, actionEnum, inTransaction});
3482         }
3483
3484         
3485         @Test
3486         public void testValidateResourceFieldsBeforeUpdate() throws Exception {
3487         ResourceBusinessLogic testSubject;
3488         Resource currentResource =  createResourceObject(true);
3489         Resource updateInfoResource = createResourceObject(true);
3490         boolean inTransaction = false;
3491         boolean isNested = false;
3492         Either<Boolean,ResponseFormat> result;
3493         
3494         // default test
3495         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateResourceFieldsBeforeUpdate", new Object[]{updateInfoResource, currentResource, inTransaction, isNested});
3496         }
3497
3498         
3499         @Test
3500         public void testValidateResourceName() throws Exception {
3501         ResourceBusinessLogic testSubject;
3502         Resource currentResource = createResourceObject(true);;
3503         Resource updateInfoResource = createResourceObject(true);;
3504         boolean hasBeenCertified = false;
3505         boolean isNested = false;
3506         Either<Boolean,ResponseFormat> result;
3507         
3508         // default test
3509         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateResourceName", new Object[]{currentResource, updateInfoResource, hasBeenCertified, isNested});
3510         }
3511
3512         
3513         @Test
3514         public void testValidateIcon() throws Exception {
3515         ResourceBusinessLogic testSubject;
3516         Resource currentResource = createResourceObject(true);;
3517         Resource updateInfoResource = createResourceObject(true);;
3518         boolean hasBeenCertified = false;
3519         Either<Boolean,ResponseFormat> result;
3520         
3521         Either<Component, StorageOperationStatus> resourceStatus = Either.right(StorageOperationStatus.BAD_REQUEST);
3522         when(toscaOperationFacade.getToscaElement(currentResource.getUniqueId()))
3523                         .thenReturn(resourceStatus);
3524         
3525
3526         // default test
3527         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateIcon", new Object[]{currentResource, updateInfoResource, hasBeenCertified});
3528         }
3529
3530         
3531         @Test
3532         public void testValidateVendorName() throws Exception {
3533         ResourceBusinessLogic testSubject;
3534         Resource currentResource = createResourceObject(true);
3535         Resource updateInfoResource = createResourceObject(true);
3536         boolean hasBeenCertified = false;
3537         Either<Boolean,ResponseFormat> result;
3538         
3539         // default test
3540         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateVendorName", new Object[]{currentResource, updateInfoResource, hasBeenCertified});
3541         }
3542
3543         
3544         @Test
3545         public void testValidateResourceVendorModelNumber() throws Exception {
3546         ResourceBusinessLogic testSubject;
3547         Resource currentResource = createResourceObject(true);;
3548         Resource updateInfoResource = createResourceObject(true);;
3549         Either<Boolean,ResponseFormat> result;
3550         
3551         // default test
3552         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateResourceVendorModelNumber", new Object[]{currentResource, updateInfoResource});
3553         }
3554
3555         
3556         @Test
3557         public void testValidateCategory() throws Exception {
3558         ResourceBusinessLogic testSubject;
3559         Resource currentResource = createResourceObject(true);;
3560         Resource updateInfoResource = createResourceObject(true);;
3561         boolean hasBeenCertified = false;
3562         boolean inTransaction = false;
3563         Either<Boolean,ResponseFormat> result;
3564         
3565         // default test
3566         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateCategory", new Object[]{currentResource, updateInfoResource, hasBeenCertified, inTransaction});
3567         }
3568
3569         
3570         @Test
3571         public void testValidateDerivedFromDuringUpdate() throws Exception {
3572         ResourceBusinessLogic testSubject;
3573         Resource currentResource = createResourceObject(true);
3574         Resource updateInfoResource = createResourceObject(true);
3575         boolean hasBeenCertified = false;
3576         Either<Boolean,ResponseFormat> result;
3577         
3578         // default test
3579         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateDerivedFromDuringUpdate", new Object[]{currentResource, updateInfoResource, hasBeenCertified});
3580         }
3581
3582         
3583         @Test
3584         public void testValidateNestedDerivedFromDuringUpdate() throws Exception {
3585         ResourceBusinessLogic testSubject;
3586         Resource currentResource = createResourceObject(true);
3587         Resource updateInfoResource = createResourceObject(true);
3588         boolean hasBeenCertified = false;
3589         Either<Boolean,ResponseFormat> result;
3590         
3591         // default test
3592         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateNestedDerivedFromDuringUpdate", new Object[]{currentResource, updateInfoResource, hasBeenCertified});
3593         }
3594
3595         
3596         @Test
3597         public void testValidateDerivedFromExist() throws Exception {
3598         ResourceBusinessLogic testSubject;
3599         Resource resource = createResourceObject(true);
3600         AuditingActionEnum actionEnum = AuditingActionEnum.ACTIVATE_SERVICE_BY_API;
3601         Either<Boolean,ResponseFormat> result;
3602         
3603         // default test
3604         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateDerivedFromExist", new Object[]{user, resource, actionEnum});
3605         }
3606
3607         
3608         @Test(expected=UnsupportedOperationException.class)
3609         public void testValidateDerivedFromExtending() throws Exception {
3610         ResourceBusinessLogic testSubject;
3611         Resource currentResource = createResourceObject(true);
3612         Resource updateInfoResource = createResourceObject(true);
3613         AuditingActionEnum actionEnum = AuditingActionEnum.ADD_CATEGORY;
3614         Either<Boolean,ResponseFormat> result;
3615          
3616          Either<Boolean, StorageOperationStatus> dataModelResponse = Either.right(StorageOperationStatus.BAD_REQUEST);
3617                 when(toscaOperationFacade.validateToscaResourceNameExtends(currentResource.getDerivedFrom().get(0), updateInfoResource.getDerivedFrom().get(0))).thenReturn(dataModelResponse);
3618         
3619         // default test
3620         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateDerivedFromExtending", new Object[]{user, currentResource, updateInfoResource, actionEnum});
3621         }
3622
3623         
3624         @Test
3625         public void testValidateResourceNameExists_2() throws Exception {
3626         ResourceBusinessLogic testSubject;
3627         Resource resource = createResourceObject(true);
3628         Either<Boolean,ResponseFormat> result;
3629         
3630         // default test
3631         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateResourceNameExists", new Object[]{resource});
3632         }
3633
3634         
3635         @Test
3636         public void testValidateCategory_1() throws Exception {
3637         ResourceBusinessLogic testSubject;
3638         Resource resource = createResourceObject(true);
3639         AuditingActionEnum actionEnum = AuditingActionEnum.ADD_ECOMP_USER_CREDENTIALS;
3640         boolean inTransaction = false;
3641         Either<Boolean,ResponseFormat> result;
3642         
3643         // default test
3644         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateCategory", new Object[]{user, resource, actionEnum, inTransaction});
3645         }
3646
3647         
3648         @Test
3649         public void testValidateCategoryListed() throws Exception {
3650         ResourceBusinessLogic testSubject;
3651         CategoryDefinition category = null;
3652         SubCategoryDefinition subcategory = null;
3653         boolean inTransaction = false;
3654         Either<Boolean,ResponseFormat> result;
3655         
3656         // test 1
3657         testSubject=createTestSubject();
3658         result=Deencapsulation.invoke(testSubject, "validateCategoryListed", new Object[]{CategoryDefinition.class, SubCategoryDefinition.class, inTransaction});
3659         
3660         }
3661
3662         
3663         @Test
3664         public void testValidateVendorReleaseName_2() throws Exception {
3665         ResourceBusinessLogic testSubject;
3666         Resource resource = createResourceObject(true);
3667         AuditingActionEnum actionEnum = null;
3668         Either<Boolean,ResponseFormat> result;
3669         
3670         // default test
3671         testSubject=createTestSubject();result=testSubject.validateVendorReleaseName(user, resource, actionEnum);
3672         }
3673
3674         
3675         @Test
3676         public void testValidateVendorReleaseName_3() throws Exception {
3677         ResourceBusinessLogic testSubject;
3678         String vendorRelease = "";
3679         Either<Boolean,ResponseFormat> result;
3680         
3681         // test 1
3682         testSubject=createTestSubject();vendorRelease = null;
3683         result=testSubject.validateVendorReleaseName(vendorRelease);
3684         }
3685
3686         
3687         @Test
3688         public void testValidateVendorName_1() throws Exception {
3689         ResourceBusinessLogic testSubject;
3690         Resource resource = createResourceObject(true);
3691         AuditingActionEnum actionEnum = AuditingActionEnum.ARTIFACT_DELETE;
3692         Either<Boolean,ResponseFormat> result;
3693         
3694         // default test
3695         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateVendorName", new Object[]{user, resource, actionEnum});
3696         }
3697
3698         
3699         @Test
3700         public void testValidateResourceVendorModelNumber_1() throws Exception {
3701         ResourceBusinessLogic testSubject;
3702         Resource resource = createResourceObject(true);
3703         AuditingActionEnum actionEnum = AuditingActionEnum.ARTIFACT_DELETE;
3704         Either<Boolean,ResponseFormat> result;
3705         
3706         // default test
3707         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateResourceVendorModelNumber", new Object[]{user, resource, actionEnum});
3708         }
3709
3710         
3711         @Test
3712         public void testValidateVendorName_2() throws Exception {
3713         ResourceBusinessLogic testSubject;
3714         String vendorName = "";
3715         Either<Boolean,ResponseFormat> result;
3716         
3717         // test 1
3718         testSubject=createTestSubject();
3719         result=Deencapsulation.invoke(testSubject, "validateVendorName", new Object[]{vendorName});
3720         }
3721
3722         
3723         @Test
3724         public void testValidateResourceVendorModelNumber_2() throws Exception {
3725         ResourceBusinessLogic testSubject;
3726         String resourceVendorModelNumber = "";
3727         Either<Boolean,ResponseFormat> result;
3728         
3729         // default test
3730         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateResourceVendorModelNumber", new Object[]{resourceVendorModelNumber});
3731         }
3732
3733         
3734         @Test
3735         public void testValidateCost() throws Exception {
3736         ResourceBusinessLogic testSubject;
3737         Resource resource = createResourceObject(true);
3738         AuditingActionEnum actionEnum = AuditingActionEnum.ADD_GROUPING;
3739         Either<Boolean,ResponseFormat> result;
3740         
3741         // default test
3742         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateCost", new Object[]{user, resource, AuditingActionEnum.class});
3743         }
3744
3745         
3746         @Test
3747         public void testValidateLicenseType() throws Exception {
3748         ResourceBusinessLogic testSubject;
3749         Resource resource = createResourceObject(true);
3750         AuditingActionEnum actionEnum = AuditingActionEnum.ADD_KEY_TO_TOPIC_ACL;
3751         Either<Boolean,ResponseFormat> result;
3752         
3753         // default test
3754         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateLicenseType", new Object[]{user, resource, actionEnum});
3755         }
3756
3757
3758         @Test
3759         public void testDeleteMarkedComponents() throws Exception {
3760         ResourceBusinessLogic testSubject;
3761         Either<List<String>,ResponseFormat> result;
3762         
3763         Either<List<String>, StorageOperationStatus> deleteMarkedElements = Either.right(StorageOperationStatus.BAD_REQUEST);
3764         when(toscaOperationFacade.deleteMarkedElements(ComponentTypeEnum.RESOURCE)).thenReturn(deleteMarkedElements);
3765         
3766         
3767         // default test
3768         testSubject=createTestSubject();result=testSubject.deleteMarkedComponents();
3769         }
3770
3771         
3772         @Test
3773         public void testGetComponentTypeForResponse() throws Exception {
3774         ResourceBusinessLogic testSubject;Component component = null;
3775         String result;
3776         
3777         // default test
3778         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getComponentTypeForResponse", new Object[]{Component.class});
3779         }
3780
3781         
3782         @Test
3783         public void testCreateGroupsFromYaml() throws Exception {
3784         ResourceBusinessLogic testSubject;
3785         String yamlFileName = "";
3786         Map<String,Object> toscaJson = new HashMap<>();;
3787         Resource resource = createResourceObject(true);
3788         Either<Map<String,GroupDefinition>,ResponseFormat> result;
3789         
3790         // default test
3791         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createGroupsFromYaml", new Object[]{yamlFileName, toscaJson, resource});
3792         }
3793
3794         
3795         @Test
3796         public void testCreateInputsFromYaml() throws Exception {
3797         ResourceBusinessLogic testSubject;
3798         String yamlFileName = "";
3799         Map<String,Object> toscaJson = new HashMap<>();;
3800         Resource resource = createResourceObject(true);
3801         Either<Map<String,InputDefinition>,ResponseFormat> result;
3802         
3803         // default test
3804         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createInputsFromYaml", new Object[]{yamlFileName, toscaJson, resource});
3805         }
3806
3807         
3808         @Test
3809         public void testCreateGroupInfo() throws Exception {
3810         ResourceBusinessLogic testSubject;String groupName = "";
3811         Object groupTemplateJson = null;
3812         Either<GroupDefinition,ResponseFormat> result;
3813         
3814         // default test
3815         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "createGroupInfo", new Object[]{groupName, Object.class});
3816         }
3817
3818         @Test
3819         public void testGetValidComponentInstanceCapabilities() throws Exception {
3820         ResourceBusinessLogic testSubject;
3821         Resource resource = createResourceObject(true);
3822         String resourceId = resource.getUniqueId();
3823         Map<String,List<CapabilityDefinition>> defaultCapabilities = new HashMap<>();
3824         Map<String,List<UploadCapInfo>> uploadedCapabilities = new HashMap<>();
3825         Either<Map<String,List<CapabilityDefinition>>,ResponseFormat> result;
3826         
3827         // default test
3828         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getValidComponentInstanceCapabilities", new Object[]{resourceId, defaultCapabilities, uploadedCapabilities});
3829         }
3830
3831         
3832         @Test
3833         public void testBuildNestedToscaResourceName() throws Exception {
3834         ResourceBusinessLogic testSubject;
3835         String nodeResourceType = "VF";
3836         String vfResourceName = "Resource12";
3837         String nodeTypeFullName = "org.openecomp.resource.VF.Resource12";
3838         ImmutablePair<String,String> result;
3839         
3840         // default test
3841         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "buildNestedToscaResourceName", new Object[]{nodeResourceType, vfResourceName, nodeTypeFullName});
3842         }
3843
3844         
3845         @Test
3846         public void testValidateAndUpdateInterfaces() throws Exception {
3847         ResourceBusinessLogic testSubject;
3848         Resource resourceUpdate = createResourceObject(true);;
3849         String resourceId = resourceUpdate.getUniqueId();
3850         Either<Boolean,ResponseFormat> result;
3851         
3852         
3853         Either<Component, StorageOperationStatus> resourceStorageOperationStatusEither = Either.right(StorageOperationStatus.BAD_REQUEST);
3854         when(toscaOperationFacade.getToscaElement(resourceUpdate.getUniqueId())).thenReturn(resourceStorageOperationStatusEither);
3855         
3856         // default test
3857         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "validateAndUpdateInterfaces", new Object[]{resourceId, resourceUpdate});
3858         }
3859
3860         
3861         @Test
3862         public void testUpdateInterfaceDefinition() throws Exception {
3863         ResourceBusinessLogic testSubject;
3864         Resource resourceUpdate = createResourceObject(true);
3865         InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
3866         Collection<InterfaceDefinition> interfaceDefinitionListFromToscaName = new ArrayList<>();
3867         Either<InterfaceDefinition,ResponseFormat> result;
3868         
3869         // default test
3870         testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "updateInterfaceDefinition", new Object[]{resourceUpdate, interfaceDefinition, interfaceDefinitionListFromToscaName});
3871         }
3872         
3873         
3874 }