2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.be.model.operations.impl;
23 import org.janusgraph.core.JanusGraphVertex;
24 import fj.data.Either;
25 import org.apache.commons.lang3.tuple.ImmutablePair;
26 import org.junit.Assert;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
30 import org.openecomp.sdc.be.dao.janusgraph.HealingJanusGraphGenericDao;
31 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
32 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao;
33 import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
34 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
35 import org.openecomp.sdc.be.datatypes.elements.PropertyRule;
36 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
37 import org.openecomp.sdc.be.model.*;
38 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
39 import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
40 import org.openecomp.sdc.be.model.tosca.ToscaType;
41 import org.openecomp.sdc.be.model.tosca.constraints.GreaterThanConstraint;
42 import org.openecomp.sdc.be.model.tosca.constraints.InRangeConstraint;
43 import org.openecomp.sdc.be.model.tosca.constraints.LessOrEqualConstraint;
44 import org.openecomp.sdc.be.resources.data.DataTypeData;
45 import org.openecomp.sdc.be.resources.data.PropertyData;
46 import org.openecomp.sdc.be.resources.data.PropertyValueData;
50 import static org.junit.Assert.*;
51 import static org.mockito.Mockito.mock;
53 public class PropertyOperationTest extends ModelTestBase {
55 HealingJanusGraphGenericDao janusGraphGenericDao = mock(HealingJanusGraphGenericDao.class);
57 PropertyOperation propertyOperation = new PropertyOperation(janusGraphGenericDao, null);
61 propertyOperation.setJanusGraphGenericDao(janusGraphGenericDao);
65 private PropertyDefinition buildPropertyDefinition() {
66 PropertyDefinition property = new PropertyDefinition();
67 property.setDefaultValue("10");
68 property.setDescription("Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.");
69 property.setType(ToscaType.INTEGER.name().toLowerCase());
74 public void convertConstraintsTest() {
76 List<PropertyConstraint> constraints = buildConstraints();
77 List<String> convertedStringConstraints = propertyOperation.convertConstraintsToString(constraints);
78 assertEquals("constraints size", constraints.size(), convertedStringConstraints.size());
80 List<PropertyConstraint> convertedConstraints = propertyOperation.convertConstraints(convertedStringConstraints);
81 assertEquals("check size of constraints", constraints.size(), convertedConstraints.size());
83 Set<String> constraintsClasses = new HashSet<>();
84 for (PropertyConstraint propertyConstraint : constraints) {
85 constraintsClasses.add(propertyConstraint.getClass().getName());
88 for (PropertyConstraint propertyConstraint : convertedConstraints) {
89 assertTrue("check all classes generated", constraintsClasses.contains(propertyConstraint.getClass().getName()));
94 public void testIsPropertyDefaultValueValid_NoDefault() {
95 PropertyDefinition property = new PropertyDefinition();
96 property.setName("myProperty");
97 property.setType(ToscaPropertyType.BOOLEAN.getType());
98 assertTrue(propertyOperation.isPropertyDefaultValueValid(property, null));
102 public void testIsPropertyDefaultValueValid_ValidDefault() {
103 PropertyDefinition property = new PropertyDefinition();
104 property.setName("myProperty");
105 property.setType(ToscaPropertyType.INTEGER.getType());
106 property.setDefaultValue("50");
107 assertTrue(propertyOperation.isPropertyDefaultValueValid(property, null));
111 public void testIsPropertyDefaultValueValid_InvalidDefault() {
112 PropertyDefinition property = new PropertyDefinition();
113 property.setName("myProperty");
114 property.setType(ToscaPropertyType.BOOLEAN.getType());
115 property.setDefaultValue("50");
116 assertFalse(propertyOperation.isPropertyDefaultValueValid(property, null));
119 private List<PropertyConstraint> buildConstraints() {
120 List<PropertyConstraint> constraints = new ArrayList<>();
121 GreaterThanConstraint propertyConstraint1 = new GreaterThanConstraint("0");
122 LessOrEqualConstraint propertyConstraint2 = new LessOrEqualConstraint("10");
123 List<String> range = new ArrayList<>();
126 InRangeConstraint propertyConstraint3 = new InRangeConstraint(range);
127 constraints.add(propertyConstraint1);
128 constraints.add(propertyConstraint2);
129 constraints.add(propertyConstraint3);
134 public void findPropertyValueBestMatch1() {
136 String propertyUniqueId = "x1";
137 ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
138 instanceProperty.setValue("v1");
139 instanceProperty.setDefaultValue("vv1");
140 List<String> path = new ArrayList<>();
144 instanceProperty.setPath(path);
146 Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
147 ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
148 instanceProperty1.setValue("v1node1");
149 instanceIdToValue.put("node1", instanceProperty1);
151 ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
152 instanceProperty2.setValue("v1node2");
153 instanceIdToValue.put("node2", instanceProperty2);
155 ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
156 instanceProperty3.setValue("v1node3");
157 instanceIdToValue.put("node3", instanceProperty3);
159 propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
161 assertEquals("check value", "v1node1", instanceProperty.getValue());
162 assertEquals("check default value", "v1node2", instanceProperty.getDefaultValue());
167 public void findPropertyValueBestMatch2() {
169 String propertyUniqueId = "x1";
170 ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
171 instanceProperty.setValue("v1");
172 instanceProperty.setDefaultValue("vv1");
173 List<String> path = new ArrayList<>();
177 instanceProperty.setPath(path);
179 Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
181 ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
182 instanceProperty2.setValue("v1node2");
183 instanceProperty2.setValueUniqueUid("aaaa");
184 instanceIdToValue.put("node2", instanceProperty2);
186 propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
188 assertEquals("check value", "v1node2", instanceProperty.getValue());
189 assertEquals("check default value", "vv1", instanceProperty.getDefaultValue());
190 assertNull("check value unique id is null", instanceProperty.getValueUniqueUid());
195 public void findPropertyValueBestMatch3() {
197 String propertyUniqueId = "x1";
198 ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
199 instanceProperty.setValue("v1");
200 instanceProperty.setDefaultValue("vv1");
201 List<String> path = new ArrayList<>();
205 instanceProperty.setPath(path);
207 Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
208 ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
209 instanceProperty1.setValue("v1node1");
210 instanceProperty1.setValueUniqueUid("aaaa");
211 instanceIdToValue.put("node1", instanceProperty1);
213 ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
214 instanceProperty3.setValue("v1node3");
215 instanceIdToValue.put("node3", instanceProperty3);
217 propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
219 assertEquals("check value", "v1node1", instanceProperty.getValue());
220 assertEquals("check default value", "v1node3", instanceProperty.getDefaultValue());
221 assertEquals("check valid unique id", instanceProperty1.getValueUniqueUid(), instanceProperty.getValueUniqueUid());
226 public void findPropertyValueBestMatch1Rules() {
228 String propertyUniqueId = "x1";
229 ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
230 instanceProperty.setValue("v1");
231 instanceProperty.setDefaultValue("vv1");
232 List<String> path = new ArrayList<>();
236 instanceProperty.setPath(path);
238 Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
239 ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
240 instanceProperty1.setValue("v1node1");
242 List<PropertyRule> rules = new ArrayList<>();
243 PropertyRule propertyRule = new PropertyRule();
244 String[] ruleArr = { "node1", ".+", "node3" };
245 List<String> rule1 = new ArrayList<>(Arrays.asList(ruleArr));
246 propertyRule.setRule(rule1);
247 propertyRule.setValue("88");
248 rules.add(propertyRule);
249 instanceProperty1.setRules(rules);
251 instanceIdToValue.put("node1", instanceProperty1);
253 ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
254 instanceProperty2.setValue("v1node2");
255 instanceIdToValue.put("node2", instanceProperty2);
257 ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
258 instanceProperty3.setValue("v1node3");
259 instanceIdToValue.put("node3", instanceProperty3);
261 propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
263 assertEquals("check value", propertyRule.getValue(), instanceProperty.getValue());
264 assertEquals("check default value", "v1node2", instanceProperty.getDefaultValue());
269 public void findPropertyValueBestMatch2Rules() {
271 String propertyUniqueId = "x1";
272 ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
273 instanceProperty.setValue("v1");
274 instanceProperty.setDefaultValue("vv1");
275 List<String> path = new ArrayList<>();
279 instanceProperty.setPath(path);
281 Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
282 ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
283 instanceProperty1.setValue("v1node1");
285 List<PropertyRule> rules = new ArrayList<>();
286 PropertyRule propertyRule1 = new PropertyRule();
287 String[] ruleArr1 = { "node1", "node2", ".+" };
288 List<String> rule1 = new ArrayList<>(Arrays.asList(ruleArr1));
289 propertyRule1.setRule(rule1);
290 propertyRule1.setValue("88");
292 PropertyRule propertyRule2 = new PropertyRule();
293 String[] ruleArr2 = { "node1", "node2", "node3" };
294 List<String> rule2 = new ArrayList<>(Arrays.asList(ruleArr2));
295 propertyRule2.setRule(rule2);
296 propertyRule2.setValue("99");
298 rules.add(propertyRule2);
299 rules.add(propertyRule1);
301 instanceProperty1.setRules(rules);
303 instanceIdToValue.put("node1", instanceProperty1);
305 ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
306 instanceProperty2.setValue("v1node2");
307 instanceIdToValue.put("node2", instanceProperty2);
309 ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
310 instanceProperty3.setValue("v1node3");
311 instanceIdToValue.put("node3", instanceProperty3);
313 propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
315 assertEquals("check value", propertyRule2.getValue(), instanceProperty.getValue());
316 assertEquals("check default value", "v1node2", instanceProperty.getDefaultValue());
321 public void findPropertyValueBestMatch1RuleLowLevel() {
323 String propertyUniqueId = "x1";
324 ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
325 instanceProperty.setValue("v1");
326 instanceProperty.setDefaultValue("vv1");
327 List<String> path = new ArrayList<>();
331 instanceProperty.setPath(path);
333 Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
334 ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
335 instanceProperty1.setValue("v1node1");
337 List<PropertyRule> rules = new ArrayList<>();
338 PropertyRule propertyRule1 = new PropertyRule();
339 String[] ruleArr1 = { "node1", "node2", ".+" };
340 List<String> rule1 = new ArrayList<>(Arrays.asList(ruleArr1));
341 propertyRule1.setRule(rule1);
342 propertyRule1.setValue("88");
344 PropertyRule propertyRule2 = new PropertyRule();
345 String[] ruleArr2 = { "node1", "node2", "node3" };
346 List<String> rule2 = new ArrayList<>(Arrays.asList(ruleArr2));
347 propertyRule2.setRule(rule2);
348 propertyRule2.setValue("99");
350 rules.add(propertyRule2);
351 rules.add(propertyRule1);
353 instanceProperty1.setRules(rules);
355 instanceIdToValue.put("node1", instanceProperty1);
357 ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
358 instanceProperty2.setValue("v1node2");
360 List<PropertyRule> rules3 = new ArrayList<>();
361 PropertyRule propertyRule3 = new PropertyRule();
362 String[] ruleArr3 = { "node2", "node3" };
363 List<String> rule3 = new ArrayList<>(Arrays.asList(ruleArr3));
364 propertyRule3.setRule(rule3);
365 propertyRule3.setValue("77");
366 rules3.add(propertyRule3);
368 instanceProperty2.setRules(rules3);
369 instanceIdToValue.put("node2", instanceProperty2);
371 ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
372 instanceProperty3.setValue("v1node3");
373 instanceIdToValue.put("node3", instanceProperty3);
375 propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
377 assertEquals("check value", propertyRule2.getValue(), instanceProperty.getValue());
378 assertEquals("check default value", propertyRule3.getValue(), instanceProperty.getDefaultValue());
383 public void findPropertyValueBestMatchDefaultValueNotChanged() {
385 String propertyUniqueId = "x1";
386 ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
387 instanceProperty.setValue("v1");
388 instanceProperty.setDefaultValue("vv1");
389 List<String> path = new ArrayList<>();
393 instanceProperty.setPath(path);
395 Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
396 ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
397 instanceProperty1.setValue("v1node1");
399 List<PropertyRule> rules = new ArrayList<>();
400 PropertyRule propertyRule1 = new PropertyRule();
401 String[] ruleArr1 = { "node1", "node2", ".+" };
402 List<String> rule1 = new ArrayList<>(Arrays.asList(ruleArr1));
403 propertyRule1.setRule(rule1);
404 propertyRule1.setValue("88");
406 PropertyRule propertyRule2 = new PropertyRule();
407 String[] ruleArr2 = { "node1", "node2", "node3" };
408 List<String> rule2 = new ArrayList<>(Arrays.asList(ruleArr2));
409 propertyRule2.setRule(rule2);
410 propertyRule2.setValue("99");
412 rules.add(propertyRule2);
413 rules.add(propertyRule1);
415 instanceProperty1.setRules(rules);
417 instanceIdToValue.put("node1", instanceProperty1);
419 ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
420 instanceProperty2.setValue("v1node2");
422 List<PropertyRule> rules3 = new ArrayList<>();
423 PropertyRule propertyRule3 = new PropertyRule();
424 String[] ruleArr3 = { "node2", "node333" };
425 List<String> rule3 = new ArrayList<>(Arrays.asList(ruleArr3));
426 propertyRule3.setRule(rule3);
427 propertyRule3.setValue("77");
428 rules3.add(propertyRule3);
430 instanceProperty2.setRules(rules3);
431 instanceIdToValue.put("node2", instanceProperty2);
433 propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
435 assertEquals("check value", propertyRule2.getValue(), instanceProperty.getValue());
436 assertEquals("check default value", "vv1", instanceProperty.getDefaultValue());
440 private PropertyOperation createTestSubject() {
441 return new PropertyOperation(new HealingJanusGraphGenericDao(new JanusGraphClient()), null);
445 public void testConvertPropertyDataToPropertyDefinition() throws Exception {
446 PropertyOperation testSubject;
447 PropertyData propertyDataResult = new PropertyData();
448 String propertyName = "";
449 String resourceId = "";
450 PropertyDefinition result;
453 testSubject = createTestSubject();
454 result = testSubject.convertPropertyDataToPropertyDefinition(propertyDataResult, propertyName, resourceId);
458 public void testAddProperty() throws Exception {
459 PropertyOperation testSubject;
460 String propertyName = "";
461 PropertyDefinition propertyDefinition = new PropertyDefinition();
462 String resourceId = "";
463 Either<PropertyData, StorageOperationStatus> result;
466 testSubject = createTestSubject();
467 result = testSubject.addProperty(propertyName, propertyDefinition, resourceId);
472 public void testValidateAndUpdateProperty() throws Exception {
473 PropertyOperation testSubject;
474 IComplexDefaultValue propertyDefinition = new PropertyDefinition();
475 Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
476 dataTypes.put("", new DataTypeDefinition());
477 StorageOperationStatus result;
480 testSubject = createTestSubject();
481 result = testSubject.validateAndUpdateProperty(propertyDefinition, dataTypes);
486 public void testAddPropertyToGraph() throws Exception {
487 PropertyOperation testSubject;
488 String propertyName = "";
489 PropertyDefinition propertyDefinition = new PropertyDefinition();
490 String resourceId = "";
491 Either<PropertyData, JanusGraphOperationStatus> result;
494 testSubject = createTestSubject();
495 result = testSubject.addPropertyToGraph(propertyName, propertyDefinition, resourceId);
500 public void testAddPropertyToGraphByVertex() throws Exception {
501 PropertyOperation testSubject;
502 JanusGraphVertex metadataVertex = null;
503 String propertyName = "";
504 PropertyDefinition propertyDefinition = new PropertyDefinition();
505 String resourceId = "";
506 JanusGraphOperationStatus result;
509 testSubject = createTestSubject();
510 result = testSubject.addPropertyToGraphByVertex(metadataVertex, propertyName, propertyDefinition, resourceId);
515 public void testGetJanusGraphGenericDao() throws Exception {
516 PropertyOperation testSubject;
517 JanusGraphGenericDao result;
520 testSubject = createTestSubject();
521 result = testSubject.getJanusGraphGenericDao();
525 public void testDeletePropertyFromGraph() throws Exception {
526 PropertyOperation testSubject;
527 String propertyId = "";
528 Either<PropertyData, JanusGraphOperationStatus> result;
531 testSubject = createTestSubject();
532 result = testSubject.deletePropertyFromGraph(propertyId);
537 public void testUpdateProperty() throws Exception {
538 PropertyOperation testSubject;
539 String propertyId = "";
540 PropertyDefinition newPropertyDefinition = new PropertyDefinition();
541 Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
542 Either<PropertyData, StorageOperationStatus> result;
545 testSubject = createTestSubject();
546 result = testSubject.updateProperty(propertyId, newPropertyDefinition, dataTypes);
551 public void testUpdatePropertyFromGraph() throws Exception {
552 PropertyOperation testSubject;
553 String propertyId = "";
554 PropertyDefinition propertyDefinition = null;
555 Either<PropertyData, JanusGraphOperationStatus> result;
558 testSubject = createTestSubject();
559 result = testSubject.updatePropertyFromGraph(propertyId, propertyDefinition);
564 public void testSetJanusGraphGenericDao() {
566 PropertyOperation testSubject;
567 HealingJanusGraphGenericDao janusGraphGenericDao = null;
570 testSubject = createTestSubject();
571 testSubject.setJanusGraphGenericDao(janusGraphGenericDao);
576 public void testAddPropertyToNodeType() {
577 PropertyOperation testSubject;
578 String propertyName = "";
579 PropertyDefinition propertyDefinition = new PropertyDefinition();
580 NodeTypeEnum nodeType = NodeTypeEnum.Attribute;
581 String uniqueId = "";
582 Either<PropertyData, JanusGraphOperationStatus> result;
585 testSubject = createTestSubject();
586 result = testSubject.addPropertyToNodeType(propertyName, propertyDefinition, nodeType, uniqueId);
591 public void testFindPropertiesOfNode() throws Exception {
592 PropertyOperation testSubject;
593 NodeTypeEnum nodeType = null;
594 String uniqueId = "";
595 Either<Map<String, PropertyDefinition>, JanusGraphOperationStatus> result;
598 testSubject = createTestSubject();
599 result = testSubject.findPropertiesOfNode(nodeType, uniqueId);
604 public void testDeletePropertiesAssociatedToNode() throws Exception {
605 PropertyOperation testSubject;
606 NodeTypeEnum nodeType = null;
607 String uniqueId = "";
608 Either<Map<String, PropertyDefinition>, StorageOperationStatus> result;
611 testSubject = createTestSubject();
612 result = testSubject.deletePropertiesAssociatedToNode(nodeType, uniqueId);
617 public void testDeleteAllPropertiesAssociatedToNode() throws Exception {
618 PropertyOperation testSubject;
619 NodeTypeEnum nodeType = null;
620 String uniqueId = "";
621 Either<Map<String, PropertyDefinition>, StorageOperationStatus> result;
624 testSubject = createTestSubject();
625 result = testSubject.deleteAllPropertiesAssociatedToNode(nodeType, uniqueId);
630 public void testIsPropertyExist() throws Exception {
631 PropertyOperation testSubject;
632 List<PropertyDefinition> properties = null;
633 String resourceUid = "";
634 String propertyName = "";
635 String propertyType = "";
639 testSubject = createTestSubject();
640 result = testSubject.isPropertyExist(properties, resourceUid, propertyName, propertyType);
645 public void testValidateAndUpdateRules() throws Exception {
646 PropertyOperation testSubject;
647 String propertyType = "";
648 List<PropertyRule> rules = null;
649 String innerType = "";
650 Map<String, DataTypeDefinition> dataTypes = null;
651 boolean isValidate = false;
652 ImmutablePair<String, Boolean> result;
655 testSubject = createTestSubject();
657 result = testSubject.validateAndUpdateRules(propertyType, rules, innerType, dataTypes, isValidate);
662 public void testAddRulesToNewPropertyValue() throws Exception {
663 PropertyOperation testSubject;
664 PropertyValueData propertyValueData = new PropertyValueData();
665 ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
666 String resourceInstanceId = "";
669 testSubject = createTestSubject();
670 testSubject.addRulesToNewPropertyValue(propertyValueData, resourceInstanceProperty, resourceInstanceId);
675 public void testFindPropertyValue() throws Exception {
676 PropertyOperation testSubject;
677 String resourceInstanceId = "";
678 String propertyId = "";
679 ImmutablePair<JanusGraphOperationStatus, String> result;
682 testSubject = createTestSubject();
683 result = testSubject.findPropertyValue(resourceInstanceId, propertyId);
688 public void testUpdateRulesInPropertyValue() throws Exception {
689 PropertyOperation testSubject;
690 PropertyValueData propertyValueData = new PropertyValueData();
691 ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
692 String resourceInstanceId = "";
695 testSubject = createTestSubject();
696 testSubject.updateRulesInPropertyValue(propertyValueData, resourceInstanceProperty, resourceInstanceId);
701 public void testGetAllPropertiesOfResourceInstanceOnlyPropertyDefId() throws Exception {
702 PropertyOperation testSubject;
703 String resourceInstanceUid = "";
704 Either<List<ComponentInstanceProperty>, JanusGraphOperationStatus> result;
707 testSubject = createTestSubject();
708 result = testSubject.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceUid);
713 public void testRemovePropertyOfResourceInstance() throws Exception {
714 PropertyOperation testSubject;
715 String propertyValueUid = "";
716 String resourceInstanceId = "";
717 Either<PropertyValueData, JanusGraphOperationStatus> result;
720 testSubject = createTestSubject();
721 result = testSubject.removePropertyOfResourceInstance(propertyValueUid, resourceInstanceId);
726 public void testRemovePropertyValueFromResourceInstance() throws Exception {
727 PropertyOperation testSubject;
728 String propertyValueUid = "";
729 String resourceInstanceId = "";
730 boolean inTransaction = false;
731 Either<ComponentInstanceProperty, StorageOperationStatus> result;
734 testSubject = createTestSubject();
735 result = testSubject.removePropertyValueFromResourceInstance(propertyValueUid, resourceInstanceId,
741 public void testBuildResourceInstanceProperty() throws Exception {
742 PropertyOperation testSubject;
743 PropertyValueData propertyValueData = new PropertyValueData();
744 ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
745 ComponentInstanceProperty result;
748 testSubject = createTestSubject();
749 result = testSubject.buildResourceInstanceProperty(propertyValueData, resourceInstanceProperty);
754 public void testIsPropertyDefaultValueValid() throws Exception {
755 PropertyOperation testSubject;
756 IComplexDefaultValue propertyDefinition = null;
757 Map<String, DataTypeDefinition> dataTypes = null;
761 testSubject = createTestSubject();
762 propertyDefinition = null;
763 result = testSubject.isPropertyDefaultValueValid(propertyDefinition, dataTypes);
764 Assert.assertEquals(false, result);
769 public void testIsPropertyTypeValid() throws Exception {
770 PropertyOperation testSubject;
771 IComplexDefaultValue property = null;
775 testSubject = createTestSubject();
777 result = testSubject.isPropertyTypeValid(property);
778 Assert.assertEquals(false, result);
783 public void testIsPropertyInnerTypeValid() throws Exception {
784 PropertyOperation testSubject;
785 IComplexDefaultValue property = null;
786 Map<String, DataTypeDefinition> dataTypes = null;
787 ImmutablePair<String, Boolean> result;
790 testSubject = createTestSubject();
792 result = testSubject.isPropertyInnerTypeValid(property, dataTypes);
797 public void testGetAllPropertiesOfResourceInstanceOnlyPropertyDefId_1() throws Exception {
798 PropertyOperation testSubject;
799 String resourceInstanceUid = "";
800 NodeTypeEnum instanceNodeType = null;
801 Either<List<ComponentInstanceProperty>, JanusGraphOperationStatus> result;
804 testSubject = createTestSubject();
805 result = testSubject.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceUid, instanceNodeType);
810 public void testFindDefaultValueFromSecondPosition() throws Exception {
811 PropertyOperation testSubject;
812 List<String> pathOfComponentInstances = null;
813 String propertyUniqueId = "";
814 String defaultValue = "";
815 Either<String, JanusGraphOperationStatus> result;
818 testSubject = createTestSubject();
819 pathOfComponentInstances = null;
820 result = testSubject.findDefaultValueFromSecondPosition(pathOfComponentInstances, propertyUniqueId,
826 public void testUpdatePropertyByBestMatch() throws Exception {
827 PropertyOperation testSubject;
828 String propertyUniqueId = "";
829 ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
830 List<String> path = new ArrayList<>();
832 instanceProperty.setPath(path);
833 Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
834 instanceIdToValue.put("123", instanceProperty);
837 testSubject = createTestSubject();
838 testSubject.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
843 public void testGetDataTypeByUid() throws Exception {
844 PropertyOperation testSubject;
845 String uniqueId = "";
846 Either<DataTypeDefinition, JanusGraphOperationStatus> result;
849 testSubject = createTestSubject();
850 result = testSubject.getDataTypeByUid(uniqueId);
855 public void testAddDataType() throws Exception {
856 PropertyOperation testSubject;
857 DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
858 Either<DataTypeDefinition, StorageOperationStatus> result;
861 testSubject = createTestSubject();
862 result = testSubject.addDataType(dataTypeDefinition);
867 public void testGetDataTypeByName() throws Exception {
868 PropertyOperation testSubject;
870 boolean inTransaction = false;
871 Either<DataTypeDefinition, StorageOperationStatus> result;
874 testSubject = createTestSubject();
875 result = testSubject.getDataTypeByName(name, inTransaction);
880 public void testGetDataTypeByName_1() throws Exception {
881 PropertyOperation testSubject;
883 Either<DataTypeDefinition, StorageOperationStatus> result;
886 testSubject = createTestSubject();
887 result = testSubject.getDataTypeByName(name);
892 public void testGetDataTypeByNameWithoutDerived() throws Exception {
893 PropertyOperation testSubject;
895 Either<DataTypeDefinition, StorageOperationStatus> result;
898 testSubject = createTestSubject();
899 result = testSubject.getDataTypeByNameWithoutDerived(name);
904 public void testGetDataTypeByUidWithoutDerivedDataTypes() throws Exception {
905 PropertyOperation testSubject;
906 String uniqueId = "";
907 Either<DataTypeDefinition, JanusGraphOperationStatus> result;
910 testSubject = createTestSubject();
911 result = testSubject.getDataTypeByUidWithoutDerivedDataTypes(uniqueId);
916 public void testIsDefinedInDataTypes() throws Exception {
917 PropertyOperation testSubject;
918 String propertyType = "";
919 Either<Boolean, JanusGraphOperationStatus> result;
922 testSubject = createTestSubject();
923 result = testSubject.isDefinedInDataTypes(propertyType);
928 public void testGetAllDataTypes() throws Exception {
929 PropertyOperation testSubject;
930 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> result;
933 testSubject = createTestSubject();
934 result = testSubject.getAllDataTypes();
939 public void testCheckInnerType() throws Exception {
940 PropertyOperation testSubject;
941 PropertyDataDefinition propDataDef = new PropertyDataDefinition();
942 Either<String, JanusGraphOperationStatus> result;
945 testSubject = createTestSubject();
946 result = testSubject.checkInnerType(propDataDef);
951 public void testGetAllDataTypeNodes() throws Exception {
952 PropertyOperation testSubject;
953 Either<List<DataTypeData>, JanusGraphOperationStatus> result;
956 testSubject = createTestSubject();
957 result = testSubject.getAllDataTypeNodes();
962 public void testValidateAndUpdatePropertyValue() throws Exception {
963 PropertyOperation testSubject;
964 String propertyType = "";
966 boolean isValidate = false;
967 String innerType = "";
968 Map<String, DataTypeDefinition> dataTypes = null;
969 Either<Object, Boolean> result;
972 testSubject = createTestSubject();
973 result = testSubject.validateAndUpdatePropertyValue(propertyType, value, isValidate, innerType, dataTypes);
978 public void testValidateAndUpdatePropertyValue_1() throws Exception {
979 PropertyOperation testSubject;
980 String propertyType = "";
982 String innerType = "";
983 Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
984 dataTypes.put("", new DataTypeDefinition());
985 Either<Object, Boolean> result;
988 testSubject = createTestSubject();
989 result = testSubject.validateAndUpdatePropertyValue(propertyType, value, innerType, dataTypes);
997 public void testAddPropertiesToElementType() throws Exception {
998 PropertyOperation testSubject;
999 String uniqueId = "";
1000 NodeTypeEnum elementType = null;
1001 List<PropertyDefinition> properties = null;
1002 Either<Map<String, PropertyData>, JanusGraphOperationStatus> result;
1005 testSubject = createTestSubject();
1007 result = testSubject.addPropertiesToElementType(uniqueId, elementType, properties);
1012 public void testUpdateDataType() throws Exception {
1013 PropertyOperation testSubject;
1014 DataTypeDefinition newDataTypeDefinition = new DataTypeDefinition();
1015 DataTypeDefinition oldDataTypeDefinition = new DataTypeDefinition();
1016 Either<DataTypeDefinition, StorageOperationStatus> result;
1019 testSubject = createTestSubject();
1020 result = testSubject.updateDataType(newDataTypeDefinition, oldDataTypeDefinition);