1 package org.openecomp.sdc.be.components.impl;
3 import java.util.Collection;
7 import org.apache.commons.lang3.tuple.ImmutablePair;
9 import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
10 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
11 import org.openecomp.sdc.be.info.ArtifactTemplateInfo;
12 import org.openecomp.sdc.be.info.GroupDefinitionInfo;
13 import org.openecomp.sdc.be.model.Component;
14 import org.openecomp.sdc.be.model.ComponentInstance;
15 import org.openecomp.sdc.be.model.DataTypeDefinition;
16 import org.openecomp.sdc.be.model.GroupDefinition;
17 import org.openecomp.sdc.be.model.GroupInstance;
18 import org.openecomp.sdc.be.model.GroupInstanceProperty;
19 import org.openecomp.sdc.be.model.GroupProperty;
20 import org.openecomp.sdc.be.model.PropertyDefinition;
21 import org.openecomp.sdc.be.model.PropertyDefinition.PropertyNames;
22 import org.openecomp.sdc.be.model.User;
23 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
24 import org.openecomp.sdc.exception.ResponseFormat;
26 import com.google.common.base.Function;
28 import fj.data.Either;
31 public class GroupBusinessLogicTest {
33 private GroupBusinessLogic createTestSubject() {
34 return new GroupBusinessLogic();
39 public void testGetComponentTypeForResponse() throws Exception {
40 GroupBusinessLogic testSubject;
41 Component component = null;
45 testSubject = createTestSubject();
51 public void testVerifyArtifactsBelongsToComponent() throws Exception {
52 GroupBusinessLogic testSubject;Component component = null;
53 List<String> artifacts = null;
55 Either<Boolean,ResponseFormat> result;
58 testSubject=createTestSubject();artifacts = null;
65 public void testVerifyComponentInstancesAreValidMembers() throws Exception {
66 GroupBusinessLogic testSubject;Component component = null;
67 ComponentTypeEnum componentType = null;
68 String groupName = "";
69 String groupType = "";
70 Map<String,String> groupMembers = null;
71 List<String> memberToscaTypes = null;
72 Either<Boolean,ResponseFormat> result;
75 testSubject=createTestSubject();groupMembers = null;
80 testSubject=createTestSubject();memberToscaTypes = null;
87 public void testValidateAndUpdateGroupMetadata() throws Exception {
88 GroupBusinessLogic testSubject;
89 String componentId = "";
91 ComponentTypeEnum componentType = null;
92 GroupDefinition updatedGroup = null;
93 boolean inTransaction = false;
94 boolean shouldLock = false;
95 Either<GroupDefinition, ResponseFormat> result;
98 testSubject = createTestSubject();
104 public void testUpdateGroupMetadata() throws Exception {
105 GroupBusinessLogic testSubject;
106 Component component = null;
107 GroupDefinition currentGroup = null;
108 GroupDefinition updatedGroup = null;
109 Either<GroupDefinition, ResponseFormat> result;
112 testSubject = createTestSubject();
118 public void testUpdateGroup() throws Exception {
119 GroupBusinessLogic testSubject;
120 Component component = null;
121 GroupDefinition updatedGroup = null;
122 String currentGroupName = "";
123 Either<GroupDefinition, ResponseFormat> result;
126 testSubject = createTestSubject();
132 public void testValidateAndUpdateGroupProperties() throws Exception {
133 GroupBusinessLogic testSubject;
134 String componentId = "";
135 String groupUniqueId = "";
137 ComponentTypeEnum componentType = null;
138 List<GroupProperty> groupPropertiesToUpdate = null;
139 boolean inTransaction = false;
140 Either<List<GroupProperty>, ResponseFormat> result;
143 testSubject = createTestSubject();
149 public void testResetEmptyValueWithDefaults() throws Exception {
150 GroupBusinessLogic testSubject;List<GroupProperty> groupPropertiesToUpdate = null;
151 GroupDefinition originalGroup = null;
159 public void testValidateGroupPropertyAndResetEmptyValue() throws Exception {
160 GroupBusinessLogic testSubject;GroupDefinition originalGroup = null;
161 List<GroupProperty> groupPropertiesToUpdate = null;
162 Either<List<GroupProperty>,ResponseFormat> result;
165 testSubject=createTestSubject();
170 public void testValidatePropertyBusinessLogic() throws Exception {
171 GroupBusinessLogic testSubject;List<GroupProperty> groupPropertiesToUpdate = null;
172 GroupDefinition originalGroup = null;
173 Either<List<GroupProperty>,ResponseFormat> result;
176 testSubject=createTestSubject();
181 public void testPrepareMapWithOriginalProperties() throws Exception {
182 GroupBusinessLogic testSubject;
183 GroupDefinition originalGroup = null;
184 Map<PropertyNames, String> result;
187 testSubject = createTestSubject();
193 public void testValidateOnlyValueChanged() throws Exception {
194 GroupBusinessLogic testSubject;List<GroupProperty> groupPropertiesToUpdate = null;
195 GroupDefinition originalGroup = null;
196 Either<List<GroupProperty>,ResponseFormat> result;
199 testSubject=createTestSubject();
204 public void testIsOnlyGroupPropertyValueChanged() throws Exception {
205 GroupBusinessLogic testSubject;
206 GroupProperty groupProperty = null;
207 GroupProperty groupProperty2 = null;
211 testSubject = createTestSubject();
217 public void testValidateAndUpdateGroupMetadata_1() throws Exception {
218 GroupBusinessLogic testSubject;
219 GroupDefinition currentGroup = null;
220 GroupDefinition groupUpdate = null;
221 Either<GroupDefinition, ResponseFormat> result;
224 testSubject = createTestSubject();
230 public void testValidateAndUpdateGroupName() throws Exception {
231 GroupBusinessLogic testSubject;
232 GroupDefinition currentGroup = null;
233 GroupDefinition groupUpdate = null;
234 Either<Boolean, ResponseFormat> result;
237 testSubject = createTestSubject();
243 public void testValidateGroupName() throws Exception {
244 GroupBusinessLogic testSubject;
245 String currentGroupName = "";
246 String groupUpdateName = "";
247 boolean isforceNameModification = false;
248 Either<Boolean, ResponseFormat> result;
251 testSubject = createTestSubject();
257 public void testGetGroupWithArtifactsById() throws Exception {
258 GroupBusinessLogic testSubject;
259 ComponentTypeEnum componentType = null;
260 String componentId = "";
263 boolean inTransaction = false;
264 Either<GroupDefinitionInfo, ResponseFormat> result;
267 testSubject = createTestSubject();
273 public void testFindGroupOnComponent() throws Exception {
274 GroupBusinessLogic testSubject;
275 Component component = null;
277 Either<GroupDefinition, StorageOperationStatus> result;
280 testSubject = createTestSubject();
286 public void testValidateGroupsBeforeUpdate() throws Exception {
287 GroupBusinessLogic testSubject;String componentId = "";
289 ComponentTypeEnum componentType = null;
290 List<GroupDefinition> groups = null;
291 boolean inTransaction = false;
292 Either<org.openecomp.sdc.be.model.Component,ResponseFormat> result;
295 testSubject=createTestSubject();
300 public void testValidateGroupsInComponentByFunc() throws Exception {
301 GroupBusinessLogic testSubject;List<GroupDefinition> groups = null;
302 Component component = null;
303 Function<GroupDefinition,String> getByParam = null;
304 ResponseFormat result;
307 testSubject=createTestSubject();
312 public void testGetAsString() throws Exception {
313 GroupBusinessLogic testSubject;
314 List<String> list = null;
318 testSubject = createTestSubject();
326 public void testUpdateGroupPropertiesValue() throws Exception {
327 GroupBusinessLogic testSubject;String componentId = "";
328 GroupDefinition currentGroup = null;
329 List<GroupProperty> groupPropertyToUpdate = null;
330 boolean inTransaction = false;
331 Either<List<GroupProperty>,ResponseFormat> result;
334 testSubject=createTestSubject();
339 public void testValidateGenerateVfModuleGroupNames() throws Exception {
340 GroupBusinessLogic testSubject;
341 List<ArtifactTemplateInfo> allGroups = null;
342 String resourceSystemName = "";
343 int startGroupCounter = 0;
344 Either<Boolean, ResponseFormat> result;
347 testSubject = createTestSubject();
353 public void testValidateGenerateVfModuleGroupName() throws Exception {
354 GroupBusinessLogic testSubject;
355 String resourceSystemName = "";
356 String description = "";
357 int groupCounter = 0;
358 Either<String, ResponseFormat> result;
361 testSubject = createTestSubject();
362 resourceSystemName = null;
368 testSubject = createTestSubject();
369 resourceSystemName = "";
375 testSubject = createTestSubject();
377 resourceSystemName = null;
382 testSubject = createTestSubject();
384 resourceSystemName = null;
391 public void testValidateUpdateVfGroupNames() throws Exception {
392 GroupBusinessLogic testSubject;
393 Map<String, GroupDefinition> groups = null;
394 String resourceSystemName = "";
395 Either<Map<String, GroupDefinition>, ResponseFormat> result;
398 testSubject = createTestSubject();
404 public void testGetNextVfModuleNameCounter() throws Exception {
405 GroupBusinessLogic testSubject;
406 Map<String, GroupDefinition> groups = null;
410 testSubject = createTestSubject();
418 public void testGetNextVfModuleNameCounter_1() throws Exception {
419 GroupBusinessLogic testSubject;
420 Collection<GroupDefinition> groups = null;
424 testSubject = createTestSubject();
432 public void testValidateUpdateVfGroupNamesOnGraph() throws Exception {
433 GroupBusinessLogic testSubject;
434 List<GroupDefinition> groups = null;
435 Component component = null;
436 boolean inTransaction = false;
437 Either<List<GroupDefinition>, ResponseFormat> result;
440 testSubject = createTestSubject();
446 public void testGetGroupInstWithArtifactsById() throws Exception {
447 GroupBusinessLogic testSubject;
448 ComponentTypeEnum componentType = null;
449 String componentId = "";
450 String componentInstanceId = "";
451 String groupInstId = "";
453 boolean inTransaction = false;
454 Either<GroupDefinitionInfo, ResponseFormat> result;
457 testSubject = createTestSubject();
463 public void testFindComponentInstanceAndGroupInstanceOnComponent() throws Exception {
464 GroupBusinessLogic testSubject;
465 Component component = null;
466 String componentInstanceId = "";
467 String groupInstId = "";
468 Either<ImmutablePair<ComponentInstance, GroupInstance>, StorageOperationStatus> result;
471 testSubject = createTestSubject();
477 public void testGetLatestIntProperty() throws Exception {
478 GroupBusinessLogic testSubject;Map<PropertyNames,String> newValues = null;
479 Map<PropertyNames,String> parentValues = null;
480 PropertyNames propertyKey = null;
484 testSubject=createTestSubject();
489 public void testIsPropertyChanged() throws Exception {
490 GroupBusinessLogic testSubject;Map<PropertyNames,String> newValues = null;
491 Map<PropertyNames,String> parentValues = null;
492 PropertyNames minInstances = null;
496 testSubject=createTestSubject();
501 public void testValidateMinMaxAndInitialCountPropertyLogicVF() throws Exception {
502 GroupBusinessLogic testSubject;Map<PropertyNames,String> newValues = null;
503 Map<PropertyNames,String> parentValues = null;
504 Either<Boolean,ResponseFormat> result;
507 testSubject=createTestSubject();
512 public void testValidateMinMaxAndInitialCountPropertyLogic() throws Exception {
513 GroupBusinessLogic testSubject;Map<PropertyNames,String> newValues = null;
514 Map<PropertyNames,String> currValues = null;
515 Map<PropertyNames,String> parentValues = null;
516 Either<Boolean,ResponseFormat> result;
519 testSubject=createTestSubject();
524 public void testValidateValueInRange() throws Exception {
525 GroupBusinessLogic testSubject;ImmutablePair<PropertyNames,String> newValue = null;
526 ImmutablePair<PropertyNames,String> min = null;
527 ImmutablePair<PropertyNames,String> max = null;
528 Either<Boolean,ResponseFormat> result;
531 testSubject=createTestSubject();
536 public void testParseIntValue() throws Exception {
537 GroupBusinessLogic testSubject;
539 PropertyNames propertyName = null;
543 testSubject = createTestSubject();
549 public void testValidateAndUpdateGroupInstancePropertyValues() throws Exception {
550 GroupBusinessLogic testSubject;
551 String componentId = "";
552 String instanceId = "";
553 GroupInstance oldGroupInstance = null;
554 List<GroupInstanceProperty> newProperties = null;
555 boolean inTransaction = false;
556 Either<GroupInstance, ResponseFormat> result;
559 testSubject = createTestSubject();
565 public void testValidateReduceGroupInstancePropertiesBeforeUpdate() throws Exception {
566 GroupBusinessLogic testSubject;GroupInstance oldGroupInstance = null;
567 List<GroupInstanceProperty> newProperties = null;
568 Either<List<GroupInstanceProperty>,ResponseFormat> result;
571 testSubject=createTestSubject();
576 public void testFillValuesAndParentValuesFromExistingProperties() throws Exception {
577 GroupBusinessLogic testSubject;Map<String,GroupInstanceProperty> existingProperties = null;
578 Map<PropertyNames,String> propertyValues = null;
579 Map<PropertyNames,String> parentPropertyValues = null;
587 public void testHandleAndAddProperty() throws Exception {
588 GroupBusinessLogic testSubject;List<GroupInstanceProperty> reducedProperties = null;
589 Map<PropertyNames,String> newPropertyValues = null;
590 GroupInstanceProperty currNewProperty = null;
591 GroupInstanceProperty currExistingProperty = null;
592 Either<Boolean,ResponseFormat> result;
595 testSubject=createTestSubject();
600 public void testIsUpdatable() throws Exception {
601 GroupBusinessLogic testSubject;
602 PropertyNames updatablePropertyName = null;
606 testSubject = createTestSubject();
612 public void testAddPropertyUpdatedValues() throws Exception {
613 GroupBusinessLogic testSubject;List<GroupInstanceProperty> reducedProperties = null;
614 PropertyNames propertyName = null;
615 Map<PropertyNames,String> newPropertyValues = null;
616 GroupInstanceProperty newProperty = null;
617 GroupInstanceProperty existingProperty = null;
625 public void testIsEmptyMinInitialCountValue() throws Exception {
626 GroupBusinessLogic testSubject;
627 PropertyNames propertyName = null;
628 String newValue = "";
632 testSubject = createTestSubject();
638 public void testConvertIfUnboundMax() throws Exception {
639 GroupBusinessLogic testSubject;
644 testSubject = createTestSubject();
650 public void testValidateAndUpdatePropertyValue() throws Exception {
651 GroupBusinessLogic testSubject;
652 GroupInstanceProperty newProperty = null;
653 GroupInstanceProperty existingProperty = null;
654 Either<Boolean, ResponseFormat> result;
657 testSubject = createTestSubject();
663 public void testValidateImmutableProperty() throws Exception {
664 GroupBusinessLogic testSubject;
665 GroupProperty oldProperty = null;
666 GroupProperty newProperty = null;
669 testSubject = createTestSubject();
674 public void testCreateGroups() throws Exception {
675 GroupBusinessLogic testSubject;
676 Component component = null;
678 ComponentTypeEnum componentType = null;
679 List<GroupDefinition> groupDefinitions = null;
680 Either<List<GroupDefinition>, ResponseFormat> result;
683 testSubject = createTestSubject();
684 groupDefinitions = null;
691 public void testAddGroups() throws Exception {
692 GroupBusinessLogic testSubject;
693 Component component = null;
695 ComponentTypeEnum componentType = null;
696 List<GroupDefinition> groupDefinitions = null;
697 Either<List<GroupDefinition>, ResponseFormat> result;
700 testSubject = createTestSubject();
701 groupDefinitions = null;
708 public void testDeleteGroups() throws Exception {
709 GroupBusinessLogic testSubject;
710 Component component = null;
712 ComponentTypeEnum componentType = null;
713 List<GroupDefinition> groupDefinitions = null;
714 Either<List<GroupDefinition>, ResponseFormat> result;
717 testSubject = createTestSubject();
723 public void testUpdateGroups() throws Exception {
724 GroupBusinessLogic testSubject;
725 Component component = null;
726 ComponentTypeEnum componentType = null;
727 List<GroupDefinition> groupDefinitions = null;
728 Either<List<GroupDefinition>, ResponseFormat> result;
731 testSubject = createTestSubject();
737 public void testHandleGroup() throws Exception {
738 GroupBusinessLogic testSubject;
739 Component component = null;
741 ComponentTypeEnum componentType = null;
742 GroupDefinition groupDefinition = null;
743 Map<String, DataTypeDefinition> allDAtaTypes = null;
744 Either<GroupDefinition, ResponseFormat> result;
747 testSubject = createTestSubject();
753 public void testHandleProperty() throws Exception {
754 GroupBusinessLogic testSubject;
755 GroupProperty groupProperty = null;
756 PropertyDefinition prop = null;
758 Map<String, DataTypeDefinition> allDataTypes = null;
759 Either<GroupProperty, TitanOperationStatus> result;
762 testSubject = createTestSubject();