Make Service base type optional
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / impl / ServiceBusinessLogicTest.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 static org.assertj.core.api.Assertions.assertThat;
24 import static org.hamcrest.Matchers.is;
25 import static org.hamcrest.Matchers.notNullValue;
26 import static org.hamcrest.Matchers.nullValue;
27 import static org.junit.jupiter.api.Assertions.assertEquals;
28 import static org.junit.jupiter.api.Assertions.assertFalse;
29 import static org.junit.jupiter.api.Assertions.assertNotNull;
30 import static org.junit.jupiter.api.Assertions.assertNull;
31 import static org.junit.jupiter.api.Assertions.assertTrue;
32 import static org.junit.jupiter.api.Assertions.fail;
33 import static org.mockito.Mockito.when;
34
35 import com.google.common.collect.Lists;
36 import com.google.common.collect.Maps;
37 import fj.data.Either;
38 import java.lang.reflect.Method;
39 import java.util.ArrayList;
40 import java.util.Arrays;
41 import java.util.HashMap;
42 import java.util.List;
43 import java.util.Map;
44 import java.util.UUID;
45 import org.apache.commons.lang3.tuple.ImmutablePair;
46 import org.junit.jupiter.api.Test;
47 import org.mockito.Mockito;
48 import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
49 import org.openecomp.sdc.be.dao.api.ActionStatus;
50 import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
51 import org.openecomp.sdc.be.datatypes.elements.InterfaceInstanceDataDefinition;
52 import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
53 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
54 import org.openecomp.sdc.be.model.ArtifactDefinition;
55 import org.openecomp.sdc.be.model.Component;
56 import org.openecomp.sdc.be.model.ComponentInstance;
57 import org.openecomp.sdc.be.model.ComponentInstanceInterface;
58 import org.openecomp.sdc.be.model.GroupInstance;
59 import org.openecomp.sdc.be.model.Operation;
60 import org.openecomp.sdc.be.model.PropertyDefinition;
61 import org.openecomp.sdc.be.model.Resource;
62 import org.openecomp.sdc.be.model.Service;
63 import org.openecomp.sdc.be.model.category.CategoryDefinition;
64 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
65 import org.openecomp.sdc.be.plugins.ServiceCreationPlugin;
66 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
67 import org.openecomp.sdc.be.resources.data.auditing.DistributionDeployEvent;
68 import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent;
69 import org.openecomp.sdc.be.types.ServiceConsumptionData;
70 import org.openecomp.sdc.be.user.Role;
71 import org.openecomp.sdc.common.util.ValidationUtils;
72 import org.openecomp.sdc.exception.ResponseFormat;
73 import org.springframework.http.HttpStatus;
74
75 class ServiceBusinessLogicTest extends ServiceBusinessLogicBaseTestSetup {
76
77     private final static String DEFAULT_ICON = "defaulticon";
78     private static final String ALREADY_EXIST = "alreadyExist";
79
80     @Test
81     void testGetComponentAuditRecordsCertifiedVersion() {
82         Either<List<Map<String, Object>>, ResponseFormat> componentAuditRecords = bl.getComponentAuditRecords(CERTIFIED_VERSION, COMPONNET_ID, user.getUserId());
83         assertTrue(componentAuditRecords.isLeft());
84         assertEquals(3, componentAuditRecords.left().value().size());
85     }
86
87     @Test
88     void testGetComponentAuditRecordsUnCertifiedVersion() {
89         Either<List<Map<String, Object>>, ResponseFormat> componentAuditRecords = bl.getComponentAuditRecords(UNCERTIFIED_VERSION, COMPONNET_ID, user.getUserId());
90         assertTrue(componentAuditRecords.isLeft());
91         assertEquals(4, componentAuditRecords.left().value().size());
92     }
93
94     @Test
95     void testHappyScenario() {
96         Service service = createServiceObject(false);
97         when(genericTypeBusinessLogic.fetchDerivedFromGenericType(service, null)).thenReturn(Either.left(genericService));
98         Either<Service, ResponseFormat> createResponse = bl.createService(service, user);
99
100         if (createResponse.isRight()) {
101             assertEquals(new Integer(200), createResponse.right().value().getStatus());
102         }
103         assertEqualsServiceObject(createServiceObject(true), createResponse.left().value());
104     }
105
106     @Test
107     void testServiceCreationPluginCall() {
108         final Service service = createServiceObject(false);
109         when(genericTypeBusinessLogic.fetchDerivedFromGenericType(service, null)).thenReturn(Either.left(genericService));
110         final List<ServiceCreationPlugin> serviceCreationPlugins = new ArrayList<>();
111         serviceCreationPlugins.add(new ServiceCreationPlugin() {
112             @Override
113             public void beforeCreate(Service service) {
114                 //do nothing
115             }
116
117             @Override
118             public int getOrder() {
119                 return 0;
120             }
121         });
122         serviceCreationPlugins.add(new ServiceCreationPlugin() {
123             @Override
124             public void beforeCreate(Service service) {
125                 throw new RuntimeException();
126             }
127
128             @Override
129             public int getOrder() {
130                 return 0;
131             }
132         });
133         bl.setServiceCreationPluginList(serviceCreationPlugins);
134         final Either<Service, ResponseFormat> createResponse = bl.createService(service, user);
135         assertTrue(createResponse.isLeft());
136     }
137
138
139     @Test
140     void testCreateServiceWhenGenericTypeHasProperties() {
141         final Service service = createServiceObject(false);
142
143         final Resource genericTypeResource = mockGenericTypeResource();
144
145         when(genericTypeBusinessLogic.fetchDerivedFromGenericType(service, null)).thenReturn(Either.left(genericTypeResource));
146         final Service expectedService = createServiceObject(true);
147         expectedService.setProperties(mockPropertyList());
148         when(toscaOperationFacade.createToscaComponent(service)).thenReturn(Either.left(expectedService));
149         Either<Service, ResponseFormat> createResponse = bl.createService(service, user);
150
151         org.hamcrest.MatcherAssert.assertThat("Service creation should be successful",
152             createResponse.isLeft(), is(true));
153         final Service actualService = createResponse.left().value();
154         org.hamcrest.MatcherAssert.assertThat("Service should not be null", service, is(notNullValue()));
155
156         assertEqualsServiceObject(expectedService, actualService);
157     }
158
159     @Test
160     void testCreateServiceWhenGenericTypeAndServiceHasProperties() {
161         final Service service = createServiceObject(false);
162         service.setProperties(mockPropertyList());
163         service.getProperties().remove(0);
164         final PropertyDefinition serviceProperty = new PropertyDefinition();
165         serviceProperty.setName("aServiceProperty");
166         service.getProperties().add(serviceProperty);
167
168         final Resource genericTypeResource = mockGenericTypeResource();
169
170         when(genericTypeBusinessLogic.fetchDerivedFromGenericType(service, null)).thenReturn(Either.left(genericTypeResource));
171         final Service expectedService = createServiceObject(true);
172         expectedService.setProperties(mockPropertyList());
173         expectedService.getProperties().add(serviceProperty);
174         when(toscaOperationFacade.createToscaComponent(service)).thenReturn(Either.left(expectedService));
175         Either<Service, ResponseFormat> createResponse = bl.createService(service, user);
176
177         org.hamcrest.MatcherAssert.assertThat("Service creation should be successful",
178             createResponse.isLeft(), is(true));
179         final Service actualService = createResponse.left().value();
180         org.hamcrest.MatcherAssert.assertThat("Service should not be null", service, is(notNullValue()));
181
182
183         assertEqualsServiceObject(expectedService, actualService);
184     }
185
186     @Test
187     void testHappyScenarioCRNullProjectCode() {
188         Service service = createServiceObject(false);
189         service.setProjectCode(null);
190         when(genericTypeBusinessLogic.fetchDerivedFromGenericType(service, null)).thenReturn(Either.left(genericService));
191         Either<Service, ResponseFormat> createResponse = bl.createService(service, user);
192
193         if (createResponse.isRight()) {
194             assertEquals(new Integer(200), createResponse.right().value().getStatus());
195         }
196         assertEqualsServiceObject(createServiceObject(true), createResponse.left().value());
197     }
198
199     @Test
200     void testHappyScenarioCREmptyStringProjectCode() {
201         createServiceValidator();
202         Service service = createServiceObject(false);
203         service.setProjectCode("");
204         when(genericTypeBusinessLogic.fetchDerivedFromGenericType(service, null)).thenReturn(Either.left(genericService));
205         Either<Service, ResponseFormat> createResponse = bl.createService(service, user);
206
207         if (createResponse.isRight()) {
208             assertEquals(new Integer(200), createResponse.right().value().getStatus());
209         }
210         assertEqualsServiceObject(createServiceObject(true), createResponse.left().value());
211     }
212     private void assertEqualsServiceObject(final Service expectedService, final Service actualService) {
213         assertEquals(expectedService.getContactId(), actualService.getContactId());
214         assertEquals(expectedService.getCategories(), actualService.getCategories());
215         assertEquals(expectedService.getCreatorUserId(), actualService.getCreatorUserId());
216         assertEquals(expectedService.getCreatorFullName(), actualService.getCreatorFullName());
217         assertEquals(expectedService.getDescription(), actualService.getDescription());
218         assertEquals(expectedService.getIcon(), actualService.getIcon());
219         assertEquals(expectedService.getLastUpdaterUserId(), actualService.getLastUpdaterUserId());
220         assertEquals(expectedService.getLastUpdaterFullName(), actualService.getLastUpdaterFullName());
221         assertEquals(expectedService.getName(), actualService.getName());
222         assertEquals(expectedService.getUniqueId(), actualService.getUniqueId());
223         assertEquals(expectedService.getVersion(), actualService.getVersion());
224         assertEquals(expectedService.getArtifacts(), actualService.getArtifacts());
225         assertEquals(expectedService.getCreationDate(), actualService.getCreationDate());
226         assertEquals(expectedService.getLastUpdateDate(), actualService.getLastUpdateDate());
227         assertEquals(expectedService.getLifecycleState(), actualService.getLifecycleState());
228         assertEquals(expectedService.getTags(), actualService.getTags());
229         if (expectedService.getProperties() == null) {
230             org.hamcrest.MatcherAssert.assertThat("Service properties should be null",
231                 actualService.getProperties(), is(nullValue()));
232             return;
233         }
234         org.hamcrest.MatcherAssert.assertThat("Service properties should be as expected",
235             actualService.getProperties(), is(expectedService.getProperties()));
236     }
237
238
239
240     /* CREATE validations - start ***********************/
241     // Service name - start
242
243     @Test
244     void testFailedServiceValidations() {
245
246         testServiceNameAlreadyExists();
247         testServiceNameEmpty();
248         testServiceNameWrongFormat();
249         testServiceDescriptionEmpty();
250         testServiceDescriptionMissing();
251         testServiceDescExceedsLimitCreate();
252         testServiceDescNotEnglish();
253         testServiceIconEmpty();
254         testServiceIconMissing();
255         testResourceIconInvalid();
256         testTagsNoServiceName();
257         testInvalidTag();
258         testServiceTagNotExist();
259         testServiceTagEmpty();
260
261         testContactIdTooLong();
262         testContactIdWrongFormatCreate();
263         testInvalidProjectCode();
264         testProjectCodeTooLong();
265         testProjectCodeTooShort();
266
267         testResourceContactIdMissing();
268         testServiceCategoryExist();
269         testServiceBadCategoryCreate();
270     }
271
272     private void testServiceNameAlreadyExists() {
273         String serviceName = ALREADY_EXIST;
274         Service serviceExccedsNameLimit = createServiceObject(false);
275         // 51 chars, the limit is 50
276         serviceExccedsNameLimit.setName(serviceName);
277         List<String> tgs = new ArrayList<>();
278         tgs.add(serviceName);
279         serviceExccedsNameLimit.setTags(tgs);
280         try {
281             bl.createService(serviceExccedsNameLimit, user);
282         } catch (ComponentException exp) {
283             assertResponse(exp.getResponseFormat(), ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.SERVICE.getValue(), serviceName);
284             return;
285         }
286         fail();
287     }
288
289     private void testServiceNameEmpty() {
290         Service serviceExccedsNameLimit = createServiceObject(false);
291         serviceExccedsNameLimit.setName(null);
292         try{
293             bl.createService(serviceExccedsNameLimit, user);
294         } catch(ComponentException e){
295             assertComponentException(e, ActionStatus.MISSING_COMPONENT_NAME, ComponentTypeEnum.SERVICE.getValue());
296             return;
297         }
298         fail();
299     }
300
301     private void testServiceNameWrongFormat() {
302         Service service = createServiceObject(false);
303         // contains :
304         String nameWrongFormat = "ljg\\fd";
305         service.setName(nameWrongFormat);
306         try{
307             bl.createService(service, user);
308         } catch(ComponentException e){
309             assertComponentException(e, ActionStatus.INVALID_COMPONENT_NAME, ComponentTypeEnum.SERVICE.getValue());
310             return;
311         }
312         fail();
313     }
314
315     // Service name - end
316     // Service description - start
317
318     private void testServiceDescriptionEmpty() {
319         Service serviceExist = createServiceObject(false);
320         serviceExist.setDescription("");
321         try{
322             bl.createService(serviceExist, user);
323         } catch(ComponentException e){
324             assertComponentException(e, ActionStatus.COMPONENT_MISSING_DESCRIPTION, ComponentTypeEnum.SERVICE.getValue());
325             return;
326         }
327         fail();
328     }
329     private void testServiceDescriptionMissing() {
330         Service serviceExist = createServiceObject(false);
331         serviceExist.setDescription(null);
332         try{
333             bl.createService(serviceExist, user);
334         } catch(ComponentException e){
335             assertComponentException(e, ActionStatus.COMPONENT_MISSING_DESCRIPTION, ComponentTypeEnum.SERVICE.getValue());
336             return;
337         }
338         fail();
339     }
340
341     private void testServiceDescExceedsLimitCreate() {
342         Service serviceExccedsDescLimit = createServiceObject(false);
343         // 1025 chars, the limit is 1024
344         String tooLongServiceDesc = "1GUODojQ0sGzKR4NP7e5j82ADQ3KHTVOaezL95qcbuaqDtjZhAQGQ3iFwKAy580K4WiiXs3u3zq7RzXcSASl5fm0RsWtCMOIDP"
345                 + "AOf9Tf2xtXxPCuCIMCR5wOGnNTaFxgnJEHAGxilBhZDgeMNHmCN1rMK5B5IRJOnZxcpcL1NeG3APTCIMP1lNAxngYulDm9heFSBc8TfXAADq7703AvkJT0QPpGq2z2P"
346                 + "tlikcAnIjmWgfC5Tm7UH462BAlTyHg4ExnPPL4AO8c92VrD7kZSgSqiy73cN3gLT8uigkKrUgXQFGVUFrXVyyQXYtVM6bLBeuCGQf4C2j8lkNg6M0J3PC0PzMRoinOxk"
347                 + "Ae2teeCtVcIj4A1KQo3210j8q2v7qQU69Mabsa6DT9FgE4rcrbiFWrg0Zto4SXWD3o1eJA9o29lTg6kxtklH3TuZTmpi5KVp1NFhS1RpnqF83tzv4mZLKsx7Zh1fEgYvRFwx1"
348                 + "ar3RolyDfNoZiGBGTMsZzz7RPFBf2hTnLmNqVGQnHKhhGj0Y5s8t2cbqbO2nmHiJb9uaUVrCGypgbAcJL3KPOBfAVW8PcpmNj4yVjI3L4x5zHjmGZbp9vKshEQODcrmcgsYAoKqe"
349                 + "uu5u7jk8XVxEfQ0m5qL8UOErXPlJovSmKUmP5B5T0w299zIWDYCzSoNasHpHjOMDLAiDDeHbozUOn9t3Qou00e9POq4RMM0VnIx1H38nJoJZz2XH8CI5YMQe7oTagaxgQTF2aa0qaq2"
350                 + "V6nJsfRGRklGjNhFFYP2cS4Xv2IJO9DSX6LTXOmENrGVJJvMOZcvnBaZPfoAHN0LU4i1SoepLzulIxnZBfkUWFJgZ5wQ0Bco2GC1HMqzW21rwy4XHRxXpXbmW8LVyoA1KbnmVmROycU4"
351                 + "scTZ62IxIcIWCVeMjBIcTviXULbPUyqlfEPXWr8IMJtpAaELWgyquPClAREMDs2b9ztKmUeXlMccFES1XWbFTrhBHhmmDyVReEgCwfokrUFR13LTUK1k8I6OEHOs";
352
353         serviceExccedsDescLimit.setDescription(tooLongServiceDesc);
354         try{
355             bl.createService(serviceExccedsDescLimit, user);
356         } catch(ComponentException e){
357             assertComponentException(e, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT, ComponentTypeEnum.SERVICE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
358             return;
359         }
360         fail();
361     }
362
363     private void testServiceDescNotEnglish() {
364         Service notEnglish = createServiceObject(false);
365         // Not english
366         String tooLongServiceDesc = "\uC2B5";
367         notEnglish.setDescription(tooLongServiceDesc);
368         try{
369             bl.createService(notEnglish, user);
370         } catch(ComponentException e){
371             assertComponentException(e, ActionStatus.COMPONENT_INVALID_DESCRIPTION, ComponentTypeEnum.SERVICE.getValue());
372             return;
373         }
374         fail();
375     }
376
377     // Service description - stop
378     // Service icon - start
379
380     private void testServiceIconEmpty() {
381         Service serviceExist = createServiceObject(false);
382         serviceExist.setIcon("");
383         Either<Service, ResponseFormat> service = bl.validateServiceBeforeCreate(serviceExist,user,AuditingActionEnum.CREATE_SERVICE);
384         assertThat(service.left().value().getIcon()).isEqualTo(DEFAULT_ICON);
385
386     }
387     private void testServiceIconMissing() {
388         Service serviceExist = createServiceObject(false);
389         serviceExist.setIcon(null);
390         Either<Service, ResponseFormat> service = bl.validateServiceBeforeCreate(serviceExist,user,AuditingActionEnum.CREATE_SERVICE);
391         assertThat(service.left().value().getIcon()).isEqualTo(DEFAULT_ICON);
392     }
393
394     private void testResourceIconInvalid() {
395         Service resourceExist = createServiceObject(false);
396         resourceExist.setIcon("kjk3453^&");
397
398         Either<Service, ResponseFormat> service = bl.validateServiceBeforeCreate(resourceExist, user, AuditingActionEnum.CREATE_RESOURCE);
399         assertThat(service.left().value().getIcon()).isEqualTo(DEFAULT_ICON);
400
401     }
402
403     private void testTagsNoServiceName() {
404         Service serviceExccedsNameLimit = createServiceObject(false);
405         String tag1 = "afzs2qLBb";
406         List<String> tagsList = new ArrayList<>();
407         tagsList.add(tag1);
408         serviceExccedsNameLimit.setTags(tagsList);
409         try{
410             bl.createService(serviceExccedsNameLimit, user);
411         } catch(ComponentException e) {
412             assertComponentException(e, ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME);
413             return;
414         }
415         fail();
416     }
417
418     private void testInvalidTag() {
419         Service serviceExccedsNameLimit = createServiceObject(false);
420         String tag1 = "afzs2qLBb%#%";
421         List<String> tagsList = new ArrayList<>();
422         tagsList.add(tag1);
423         serviceExccedsNameLimit.setTags(tagsList);
424         try{
425             bl.createService(serviceExccedsNameLimit, user);
426         } catch(ComponentException e) {
427             assertComponentException(e, ActionStatus.INVALID_FIELD_FORMAT, "Service", "tag");
428             return;
429         }
430         fail();
431     }
432
433     private void testServiceTagNotExist() {
434         Service serviceExist = createServiceObject(false);
435         serviceExist.setTags(null);
436
437         Either<Service, ResponseFormat> service = bl.validateServiceBeforeCreate(serviceExist, user, AuditingActionEnum.CREATE_RESOURCE);
438         assertThat(service.left().value().getTags().get(0)).isEqualTo(serviceExist.getName());
439     }
440
441     private void testServiceTagEmpty() {
442         Service serviceExist = createServiceObject(false);
443         serviceExist.setTags(new ArrayList<>());
444
445         Either<Service, ResponseFormat> service = bl.validateServiceBeforeCreate(serviceExist, user, AuditingActionEnum.CREATE_RESOURCE);
446         assertThat(service.left().value().getTags().get(0)).isEqualTo(serviceExist.getName());
447     }
448
449     // Service tags - stop
450     // Service contactId - start
451
452     private void testContactIdTooLong() {
453         Service serviceContactId = createServiceObject(false);
454         // 59 chars instead of 50
455         String contactIdTooLong = "thisNameIsVeryLongAndExeccedsTheNormalLengthForContactId";
456         serviceContactId.setContactId(contactIdTooLong);
457         try{
458             bl.createService(serviceContactId, user);
459         } catch(ComponentException e) {
460             assertComponentException(e, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.SERVICE.getValue());
461             return;
462         }
463         fail();
464     }
465     private void testContactIdWrongFormatCreate() {
466         Service serviceContactId = createServiceObject(false);
467         // 3 letters and 3 digits and special characters
468         String contactIdTooLong = "yrt134!!!";
469         serviceContactId.setContactId(contactIdTooLong);
470         try{
471             bl.createService(serviceContactId, user);
472         } catch(ComponentException e) {
473             assertComponentException(e, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.SERVICE.getValue());
474             return;
475         }
476         fail();
477     }
478
479     private void testResourceContactIdMissing() {
480         Service resourceExist = createServiceObject(false);
481         resourceExist.setContactId(null);
482         try{
483             bl.createService(resourceExist, user);
484         } catch(ComponentException e) {
485             assertComponentException(e, ActionStatus.COMPONENT_MISSING_CONTACT, ComponentTypeEnum.SERVICE.getValue());
486             return;
487         }
488         fail();
489     }
490
491     // Service contactId - stop
492     // Service category - start
493
494     private void testServiceCategoryExist() {
495         Service serviceExist = createServiceObject(false);
496         serviceExist.setCategories(null);
497         try{
498             bl.createService(serviceExist, user);
499         } catch(ComponentException e) {
500             assertComponentException(e, ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.SERVICE.getValue());
501             return;
502         }
503         fail();
504     }
505     @Test
506     void markDistributionAsDeployedTestAlreadyDeployed() {
507         String notifyAction = "DNotify";
508         String requestAction = "DRequest";
509         String resultAction = "DResult";
510         String did = "123456";
511
512         setupBeforeDeploy(notifyAction, requestAction, did);
513         List<DistributionDeployEvent> resultList = new ArrayList<>();
514         Map<String, Object> params = new HashMap<>();
515         DistributionDeployEvent event = new DistributionDeployEvent();
516
517         event.setAction(resultAction);
518         event.setDid(did);
519         event.setStatus("200");
520         // ESTimeBasedEvent deployEvent = new ESTimeBasedEvent();
521         // deployEvent.setFields(params);
522         resultList.add(event);
523         Either<List<DistributionDeployEvent>, ActionStatus> eventList = Either.left(resultList);
524
525         Mockito.when(auditingDao.getDistributionDeployByStatus(Mockito.anyString(), Mockito.eq(resultAction), Mockito.anyString())).thenReturn(eventList);
526
527         Either<Service, ResponseFormat> markDeployed = bl.markDistributionAsDeployed(did, did, user);
528         assertTrue(markDeployed.isLeft());
529
530         Mockito.verify(auditingDao, Mockito.times(0)).getDistributionRequest(did, requestAction);
531
532     }
533
534     @Test
535     void markDistributionAsDeployedTestSuccess() {
536         String notifyAction = "DNotify";
537         String requestAction = "DRequest";
538         String did = "123456";
539
540         setupBeforeDeploy(notifyAction, requestAction, did);
541         List<Role> roles = new ArrayList<>();
542         roles.add(Role.ADMIN);
543         roles.add(Role.DESIGNER);
544         Either<Service, ResponseFormat> markDeployed = bl.markDistributionAsDeployed(did, did, user);
545         assertTrue(markDeployed.isLeft());
546     }
547
548     @Test
549     void markDistributionAsDeployedTestNotDistributed() {
550         String notifyAction = "DNotify";
551         String requestAction = "DRequest";
552         String did = "123456";
553
554         setupBeforeDeploy(notifyAction, requestAction, did);
555         List<ResourceAdminEvent> emptyList = new ArrayList<>();
556         Either<List<ResourceAdminEvent>, ActionStatus> emptyEventList = Either.left(emptyList);
557         Mockito.when(auditingDao.getDistributionRequest(Mockito.anyString(), Mockito.eq(requestAction))).thenReturn(emptyEventList);
558
559         Either<Component, StorageOperationStatus> notFound = Either.right(StorageOperationStatus.NOT_FOUND);
560         Mockito.when(toscaOperationFacade.getToscaElement(did)).thenReturn(notFound);
561
562         Either<Service, ResponseFormat> markDeployed = bl.markDistributionAsDeployed(did, did, user);
563         assertTrue(markDeployed.isRight());
564         assertEquals(404, markDeployed.right().value().getStatus().intValue());
565
566     }
567
568     private void testServiceBadCategoryCreate() {
569
570         Service serviceExist = createServiceObject(false);
571         CategoryDefinition category = new CategoryDefinition();
572         category.setName("koko");
573         category.setIcons(Arrays.asList(DEFAULT_ICON));
574         List<CategoryDefinition> categories = new ArrayList<>();
575         categories.add(category);
576         serviceExist.setCategories(categories);
577         try{
578             bl.createService(serviceExist, user);
579         } catch(ComponentException e) {
580             assertComponentException(e, ActionStatus.COMPONENT_INVALID_CATEGORY, ComponentTypeEnum.SERVICE.getValue());
581             return;
582         }
583         fail();
584     }
585
586     // Service category - stop
587     // Service projectCode - start
588
589     private void testInvalidProjectCode() {
590
591         Service serviceExist = createServiceObject(false);
592         serviceExist.setProjectCode("koko!!");
593
594         try {
595             bl.createService(serviceExist, user);
596         } catch(ComponentException exp) {
597            assertComponentException(exp, ActionStatus.INVALID_PROJECT_CODE);
598             return;
599         }
600         fail();
601     }
602
603     private void testProjectCodeTooLong() {
604
605         Service serviceExist = createServiceObject(false);
606         String tooLongProjectCode = "thisNameIsVeryLongAndExeccedsTheNormalLengthForProjectCode";
607         serviceExist.setProjectCode(tooLongProjectCode);
608
609         try {
610             bl.createService(serviceExist, user);
611         } catch(ComponentException exp) {
612             assertComponentException(exp, ActionStatus.INVALID_PROJECT_CODE);
613             return;
614         }
615         fail();
616     }
617
618
619     private void testProjectCodeTooShort() {
620
621         Service serviceExist = createServiceObject(false);
622         serviceExist.setProjectCode("333");
623
624         try {
625             bl.createService(serviceExist, user);
626         } catch(ComponentException exp) {
627             assertComponentException(exp, ActionStatus.INVALID_PROJECT_CODE);
628             return;
629         }
630         fail();
631     }
632
633     @Test
634     void testDeleteMarkedServices() {
635         List<String> ids = new ArrayList<>();
636         List<String> responseIds = new ArrayList<>();
637         String resourceInUse = "123";
638         ids.add(resourceInUse);
639         String resourceFree = "456";
640         ids.add(resourceFree);
641         responseIds.add(resourceFree);
642         Either<List<String>, StorageOperationStatus> eitherNoResources = Either.left(ids);
643         when(toscaOperationFacade.getAllComponentsMarkedForDeletion(ComponentTypeEnum.RESOURCE)).thenReturn(eitherNoResources);
644
645         Either<Boolean, StorageOperationStatus> resourceInUseResponse = Either.left(true);
646         Either<Boolean, StorageOperationStatus> resourceFreeResponse = Either.left(false);
647
648         List<ArtifactDefinition> artifacts = new ArrayList<>();
649         Either<List<ArtifactDefinition>, StorageOperationStatus> getArtifactsResponse = Either.left(artifacts);
650
651         Either<Component, StorageOperationStatus> eitherDelete = Either.left(new Resource());
652         when(toscaOperationFacade.deleteToscaComponent(resourceFree)).thenReturn(eitherDelete);
653         when(toscaOperationFacade.deleteMarkedElements(ComponentTypeEnum.SERVICE)).thenReturn(Either.left(responseIds));
654         Either<List<String>, ResponseFormat> deleteMarkedResources = bl.deleteMarkedComponents();
655         assertTrue(deleteMarkedResources.isLeft());
656         List<String> resourceIdList = deleteMarkedResources.left().value();
657         assertFalse(resourceIdList.isEmpty());
658         assertTrue(resourceIdList.contains(resourceFree));
659         assertFalse(resourceIdList.contains(resourceInUse));
660     }
661
662
663     @SuppressWarnings({ "unchecked", "rawtypes" })
664     @Test
665     void testFindGroupInstanceOnRelatedComponentInstance() {
666
667         Class<ServiceBusinessLogic> targetClass = ServiceBusinessLogic.class;
668         String methodName = "findGroupInstanceOnRelatedComponentInstance";
669         Object invalidId = "invalidId";
670
671         Component service = createNewService();
672         List<ComponentInstance> componentInstances = service.getComponentInstances();
673
674         Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat> findGroupInstanceRes;
675         Object[] argObjects = {service, componentInstances.get(1).getUniqueId(), componentInstances.get(1).getGroupInstances().get(1).getUniqueId()};
676         Class[] argClasses = {Component.class, String.class,String.class};
677         try {
678             Method method = targetClass.getDeclaredMethod(methodName, argClasses);
679             method.setAccessible(true);
680
681             findGroupInstanceRes = (Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat>) method.invoke(bl, argObjects);
682             assertNotNull(findGroupInstanceRes);
683             assertEquals(findGroupInstanceRes.left().value().getKey().getUniqueId(), componentInstances.get(1)
684                                                                                                        .getUniqueId());
685             assertEquals(findGroupInstanceRes.left().value().getValue().getUniqueId(), componentInstances.get(1)
686                                                                                                          .getGroupInstances()
687                                                                                                          .get(1)
688                                                                                                          .getUniqueId());
689
690             Object[] argObjectsInvalidCiId = {service, invalidId , componentInstances.get(1).getGroupInstances().get(1).getUniqueId()};
691
692             findGroupInstanceRes =    (Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat>) method.invoke(bl, argObjectsInvalidCiId);
693             assertNotNull(findGroupInstanceRes);
694             assertTrue(findGroupInstanceRes.isRight());
695             assertEquals("SVC4593", findGroupInstanceRes.right().value().getMessageId());
696
697             Object[] argObjectsInvalidGiId = {service, componentInstances.get(1).getUniqueId() , invalidId};
698
699             findGroupInstanceRes =    (Either<ImmutablePair<ComponentInstance, GroupInstance>, ResponseFormat>) method.invoke(bl, argObjectsInvalidGiId);
700             assertNotNull(findGroupInstanceRes);
701             assertTrue(findGroupInstanceRes.isRight());
702             assertEquals("SVC4653", findGroupInstanceRes.right().value().getMessageId());
703         }
704         catch (Exception e) {
705             e.printStackTrace();
706         }
707     }
708
709     private Component createNewComponent() {
710
711         Service service = new Service();
712         int listSize = 3;
713         service.setName("serviceName");
714         service.setUniqueId("serviceUniqueId");
715         List<ComponentInstance> componentInstances = new ArrayList<>();
716         ComponentInstance ci;
717         for(int i= 0; i<listSize; ++i){
718             ci = new ComponentInstance();
719             ci.setName("ciName" + i);
720             ci.setUniqueId("ciId" + i);
721             List<GroupInstance>  groupInstances= new ArrayList<>();
722             GroupInstance gi;
723             for(int j = 0; j<listSize; ++j){
724                 gi = new GroupInstance();
725                 gi.setName(ci.getName( )+ "giName" + j);
726                 gi.setUniqueId(ci.getName() + "giId" + j);
727                 groupInstances.add(gi);
728             }
729             ci.setGroupInstances(groupInstances);
730             componentInstances.add(ci);
731         }
732         service.setComponentInstances(componentInstances);
733         return service;
734     }
735
736     protected Service createNewService() {
737         return (Service)createNewComponent();
738     }
739
740     @Test
741     void testDerivedFromGeneric() {
742         Service service = createServiceObject(true);
743         service.setDerivedFromGenericInfo(genericService);
744         when(toscaOperationFacade.createToscaComponent(service)).thenReturn(Either.left(service));
745         when(genericTypeBusinessLogic.fetchDerivedFromGenericType(service, null)).thenReturn(Either.left(genericService));
746         Either<Service, ResponseFormat> createResponse = bl.createService(service, user);
747         assertTrue(createResponse.isLeft());
748         service = createResponse.left().value();
749         assertEquals(genericService.getToscaResourceName(), service.getDerivedFromGenericType());
750         assertEquals(genericService.getVersion(), service.getDerivedFromGenericVersion());
751     }
752
753     @Test
754     void testServiceWithoutDerivedFromGeneric() {
755         final Service service = createServiceObject(true);
756         when(toscaOperationFacade.createToscaComponent(service)).thenReturn(Either.left(service));
757         when(genericTypeBusinessLogic.fetchDerivedFromGenericType(service, null)).thenReturn(Either.left(genericService));
758         final Either<Service, ResponseFormat> createResponse = bl.createService(service, user);
759         assertTrue(createResponse.isLeft());
760         final Service actualService = createResponse.left().value();
761         assertNull(actualService.getDerivedFromGenericType());
762         assertNull(actualService.getDerivedFromGenericVersion());
763     }
764
765     @Test
766     void testUpdateMetadataNamingPolicy() {
767         Service currentService = createServiceObject(true);
768         Service newService = createServiceObject(false);
769         currentService.setEcompGeneratedNaming(false);
770         newService.setEcompGeneratedNaming(true);
771         newService.setNamingPolicy("policy");
772         Either<Service, ResponseFormat> resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
773         assertThat(resultOfUpdate.isLeft()).isTrue();
774         Service updatedService = resultOfUpdate.left().value();
775         assertThat(updatedService.isEcompGeneratedNaming()).isTrue();
776         assertThat(updatedService.getNamingPolicy()).isEqualToIgnoringCase("policy");
777     }
778
779     @Test
780     void testUpdateMetadataToEmptyProjectCode() {
781         Service currentService = createServiceObject(true);
782         Service newService = createServiceObject(false);
783         currentService.setProjectCode("12345");
784         newService.setProjectCode("");
785         Either<Service, ResponseFormat> resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
786         assertThat(resultOfUpdate.isLeft()).isTrue();
787         Service updatedService = resultOfUpdate.left().value();
788         assertThat(updatedService.getProjectCode()).isEmpty();
789     }
790
791     @Test
792     void testUpdateMetadataFromEmptyProjectCode() {
793         Service currentService = createServiceObject(true);
794         Service newService = createServiceObject(false);
795         currentService.setProjectCode("");
796         newService.setProjectCode("12345");
797         Either<Service, ResponseFormat> resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
798         assertThat(resultOfUpdate.isLeft()).isTrue();
799         Service updatedService = resultOfUpdate.left().value();
800         assertThat(updatedService.getProjectCode()).isEqualTo("12345");
801     }
802
803     @Test
804     void testUpdateMetadataProjectCode() {
805         Service currentService = createServiceObject(true);
806         Service newService = createServiceObject(false);
807         currentService.setProjectCode("33333");
808         newService.setProjectCode("12345");
809         Either<Service, ResponseFormat> resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
810         assertThat(resultOfUpdate.isLeft()).isTrue();
811         Service updatedService = resultOfUpdate.left().value();
812         assertThat(updatedService.getProjectCode()).isEqualTo("12345");
813     }
814
815     @Test
816     void testUpdateMetadataServiceType() {
817         Service currentService = createServiceObject(true);
818         Service newService = createServiceObject(false);
819         currentService.setServiceType("alice");
820         //valid English word
821         newService.setServiceType("bob");
822         Either<Service, ResponseFormat> resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
823         assertThat(resultOfUpdate.isLeft()).isTrue();
824         Service updatedService = resultOfUpdate.left().value();
825         assertThat(updatedService.getServiceType()).isEqualToIgnoringCase("bob");
826         //empty string is invalid
827         newService.setServiceType("");
828         resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
829         assertThat(resultOfUpdate.isLeft()).isTrue();
830         //null is invalid
831         newService.setServiceType(null);
832         resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
833         assertThat(resultOfUpdate.isRight()).isTrue();
834     }
835
836     @Test
837     void testCreateDefaultMetadataServiceFunction() {
838         Service currentService = createServiceObject(true);
839         assertThat(currentService.getServiceFunction()).isEqualTo("");
840     }
841
842     @Test
843     void testCreateCustomMetadataServiceFunction() {
844         String customServiceFunctionName = "customName";
845         Service currentService = createServiceObject(true);
846         currentService.setServiceFunction(customServiceFunctionName);
847         assertThat(currentService.getServiceFunction()).isEqualTo(customServiceFunctionName);
848     }
849
850     @Test
851     void testUpdateMetadataServiceFunction() {
852         Service currentService = createServiceObject(true);
853         Service newService = createServiceObject(false);
854         currentService.setServiceFunction("alice");
855         //valid English word
856         newService.setServiceFunction("bob");
857         Either<Service, ResponseFormat> resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
858         assertThat(resultOfUpdate.isLeft()).isTrue();
859         Service updatedService = resultOfUpdate.left().value();
860         assertThat(updatedService.getServiceFunction()).isEqualToIgnoringCase("bob");
861         //empty string is valid
862         newService.setServiceFunction("");
863         resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
864         assertThat(resultOfUpdate.isLeft()).isTrue();
865         //null is valid and assigner to ""
866         newService.setServiceFunction(null);
867         resultOfUpdate = bl.validateAndUpdateServiceMetadata(user, currentService, newService);
868         assertThat(resultOfUpdate.isLeft()).isTrue();
869         assertThat(updatedService.getServiceFunction()).isEqualTo("");
870     }
871
872
873
874     @Test
875     void testServiceFunctionExceedLength() {
876         String serviceName = "Service";
877         String serviceFunction = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
878         Service serviceFunctionExceedLength = createServiceObject(false);
879         serviceFunctionExceedLength.setName(serviceName);
880         serviceFunctionExceedLength.setServiceFunction(serviceFunction);
881         List<String> tgs = new ArrayList<>();
882         tgs.add(serviceName);
883         serviceFunctionExceedLength.setTags(tgs);
884         try {
885             serviceFunctionValidator.validateAndCorrectField(user, serviceFunctionExceedLength, AuditingActionEnum.CREATE_SERVICE);
886         } catch (ComponentException exp) {
887             assertResponse(exp.getResponseFormat(), ActionStatus.PROPERTY_EXCEEDS_LIMIT, SERVICE_FUNCTION);
888         }
889     }
890
891     @Test
892     void testServiceFunctionInvalidCharacter(){
893         String serviceName = "Service";
894         String serviceFunction = "a?";
895         Service serviceFunctionExceedLength = createServiceObject(false);
896         serviceFunctionExceedLength.setName(serviceName);
897         serviceFunctionExceedLength.setServiceFunction(serviceFunction);
898         List<String> tgs = new ArrayList<>();
899         tgs.add(serviceName);
900         serviceFunctionExceedLength.setTags(tgs);
901         try {
902             serviceFunctionValidator.validateAndCorrectField(user, serviceFunctionExceedLength, AuditingActionEnum.CREATE_SERVICE);
903         } catch (ComponentException exp) {
904             assertResponse(exp.getResponseFormat(), ActionStatus.INVALID_PROPERY, SERVICE_FUNCTION);
905         }
906     }
907
908     @Test
909     void testAddPropertyServiceConsumptionServiceNotFound() {
910         Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
911
912         Either<Operation, ResponseFormat> operationEither =
913                 bl.addPropertyServiceConsumption("1", "2", "3",
914                         user.getUserId(), new ServiceConsumptionData());
915         assertTrue(operationEither.isRight());
916         assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
917     }
918
919     @Test
920     void testAddPropertyServiceConsumptionParentServiceIsEmpty() {
921         Either<Component, StorageOperationStatus> eitherService = Either.left(createNewComponent());
922         Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
923
924         Either<Operation, ResponseFormat> operationEither =
925                 bl.addPropertyServiceConsumption("1", "2", "3",
926                         user.getUserId(), new ServiceConsumptionData());
927         assertTrue(operationEither.isRight());
928         assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
929     }
930
931     @Test
932     void testAddPropertyServiceConsumptionNoMatchingComponent() {
933         Service aService = createNewService();
934         Either<Component, StorageOperationStatus> eitherService = Either.left(aService);
935         Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
936
937         String weirdUniqueServiceInstanceId = UUID.randomUUID().toString();
938
939         Either<Operation, ResponseFormat> operationEither =
940                 bl.addPropertyServiceConsumption("1", weirdUniqueServiceInstanceId, "3",
941                         user.getUserId(), new ServiceConsumptionData());
942         assertTrue(operationEither.isRight());
943         assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
944     }
945
946     @Test
947     void testAddPropertyServiceConsumptionNotComponentInstancesInterfacesOnParentService() {
948         Service aService = createNewService();
949         aService.getComponentInstances().get(0).setUniqueId(aService.getUniqueId());
950         Either<Component, StorageOperationStatus> eitherService = Either.left(aService);
951         Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
952
953         Either<Operation, ResponseFormat> operationEither =
954                 bl.addPropertyServiceConsumption("1", aService.getUniqueId(), "3",
955                         user.getUserId(), new ServiceConsumptionData());
956         assertTrue(operationEither.isRight());
957         assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
958     }
959
960     @Test
961     void testAddPropertyServiceConsumptionInterfaceCandidateNotPresent() {
962         Service aService = createNewService();
963         aService.getComponentInstances().get(0).setUniqueId(aService.getUniqueId());
964         Either<Component, StorageOperationStatus> eitherService = Either.left(aService);
965         Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
966
967         Map<String, List<ComponentInstanceInterface>> componentInstancesInterfacesMap =
968                 Maps.newHashMap();
969         componentInstancesInterfacesMap.put(aService.getUniqueId(),
970                 Lists.newArrayList(new ComponentInstanceInterface("1", new InterfaceInstanceDataDefinition())));
971
972         aService.setComponentInstancesInterfaces(componentInstancesInterfacesMap);
973
974         Either<Operation, ResponseFormat> operationEither =
975                 bl.addPropertyServiceConsumption("1", aService.getUniqueId(), "3",
976                         user.getUserId(), new ServiceConsumptionData());
977         assertTrue(operationEither.isRight());
978         assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
979     }
980
981     @Test
982     void testAddPropertyServiceConsumptionNoInputsCandidate() {
983         Service aService = createNewService();
984         aService.getComponentInstances().get(0).setUniqueId(aService.getUniqueId());
985         Either<Component, StorageOperationStatus> eitherService = Either.left(aService);
986         Mockito.when(toscaOperationFacade.getToscaElement(Mockito.anyString())).thenReturn(eitherService);
987
988         String operationId = "operationId";
989         ComponentInstanceInterface componentInstanceInterface =
990                 new ComponentInstanceInterface("interfaceId", new InterfaceInstanceDataDefinition());
991         Map<String, Operation> operationsMap = Maps.newHashMap();
992         operationsMap.put(operationId, new Operation(new ArtifactDataDefinition(), "1",
993                 new ListDataDefinition<>(), new ListDataDefinition<>()));
994         componentInstanceInterface.setOperationsMap(operationsMap);
995
996         Map<String, List<ComponentInstanceInterface>> componentInstancesInterfacesMap = Maps.newHashMap();
997         componentInstancesInterfacesMap.put(aService.getUniqueId(), Lists.newArrayList(componentInstanceInterface));
998         aService.setComponentInstancesInterfaces(componentInstancesInterfacesMap);
999
1000         Either<Operation, ResponseFormat> operationEither =
1001                 bl.addPropertyServiceConsumption("1", aService.getUniqueId(), operationId,
1002                         user.getUserId(), new ServiceConsumptionData());
1003         assertTrue(operationEither.isRight());
1004         assertEquals(HttpStatus.NOT_FOUND.value(), operationEither.right().value().getStatus().intValue());
1005     }
1006
1007     private Resource mockGenericTypeResource() {
1008         final Resource genericTypeResource = new Resource();
1009         genericTypeResource.setProperties(mockPropertyList());
1010         return genericTypeResource;
1011     }
1012
1013     private List<PropertyDefinition> mockPropertyList() {
1014         final List<PropertyDefinition> propertyList = new ArrayList<>();
1015         final PropertyDefinition propertyDefinition1 = new PropertyDefinition();
1016         propertyDefinition1.setName("property1");
1017         propertyDefinition1.setType("string");
1018         propertyList.add(propertyDefinition1);
1019
1020         final PropertyDefinition propertyDefinition2 = new PropertyDefinition();
1021         propertyDefinition2.setName("property2");
1022         propertyDefinition2.setType("boolean");
1023         propertyList.add(propertyDefinition2);
1024
1025         final PropertyDefinition propertyDefinition3 = new PropertyDefinition();
1026         propertyDefinition3.setName("property3");
1027         propertyDefinition3.setType("string");
1028         propertyList.add(propertyDefinition3);
1029         return propertyList;
1030     }
1031
1032 }