Improve test coverage
[sdc.git] / catalog-model / src / test / java / org / openecomp / sdc / be / model / operations / impl / PropertyOperationTest.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.model.operations.impl;
22
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;
47
48 import java.util.*;
49
50 import static org.junit.Assert.*;
51 import static org.mockito.Mockito.mock;
52
53 public class PropertyOperationTest extends ModelTestBase {
54
55     HealingJanusGraphGenericDao janusGraphGenericDao = mock(HealingJanusGraphGenericDao.class);
56
57     PropertyOperation propertyOperation = new PropertyOperation(janusGraphGenericDao, null);
58
59     @Before
60     public void setup() {
61         propertyOperation.setJanusGraphGenericDao(janusGraphGenericDao);
62
63     }
64
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());
70         return property;
71     }
72
73     @Test
74     public void convertConstraintsTest() {
75
76         List<PropertyConstraint> constraints = buildConstraints();
77         List<String> convertedStringConstraints = propertyOperation.convertConstraintsToString(constraints);
78         assertEquals("constraints size", constraints.size(), convertedStringConstraints.size());
79
80         List<PropertyConstraint> convertedConstraints = propertyOperation.convertConstraints(convertedStringConstraints);
81         assertEquals("check size of constraints", constraints.size(), convertedConstraints.size());
82
83         Set<String> constraintsClasses = new HashSet<>();
84         for (PropertyConstraint propertyConstraint : constraints) {
85             constraintsClasses.add(propertyConstraint.getClass().getName());
86         }
87
88         for (PropertyConstraint propertyConstraint : convertedConstraints) {
89             assertTrue("check all classes generated", constraintsClasses.contains(propertyConstraint.getClass().getName()));
90         }
91     }
92
93     @Test
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));
99     }
100
101     @Test
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));
108     }
109
110     @Test
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));
117     }
118
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<>();
124         range.add("0");
125         range.add("100");
126         InRangeConstraint propertyConstraint3 = new InRangeConstraint(range);
127         constraints.add(propertyConstraint1);
128         constraints.add(propertyConstraint2);
129         constraints.add(propertyConstraint3);
130         return constraints;
131     }
132
133     @Test
134     public void findPropertyValueBestMatch1() {
135
136         String propertyUniqueId = "x1";
137         ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
138         instanceProperty.setValue("v1");
139         instanceProperty.setDefaultValue("vv1");
140         List<String> path = new ArrayList<>();
141         path.add("node1");
142         path.add("node2");
143         path.add("node3");
144         instanceProperty.setPath(path);
145
146         Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
147         ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
148         instanceProperty1.setValue("v1node1");
149         instanceIdToValue.put("node1", instanceProperty1);
150
151         ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
152         instanceProperty2.setValue("v1node2");
153         instanceIdToValue.put("node2", instanceProperty2);
154
155         ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
156         instanceProperty3.setValue("v1node3");
157         instanceIdToValue.put("node3", instanceProperty3);
158
159         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
160
161         assertEquals("check value", "v1node1", instanceProperty.getValue());
162         assertEquals("check default value", "v1node2", instanceProperty.getDefaultValue());
163
164     }
165
166     @Test
167     public void findPropertyValueBestMatch2() {
168
169         String propertyUniqueId = "x1";
170         ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
171         instanceProperty.setValue("v1");
172         instanceProperty.setDefaultValue("vv1");
173         List<String> path = new ArrayList<>();
174         path.add("node1");
175         path.add("node2");
176         path.add("node3");
177         instanceProperty.setPath(path);
178
179         Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
180
181         ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
182         instanceProperty2.setValue("v1node2");
183         instanceProperty2.setValueUniqueUid("aaaa");
184         instanceIdToValue.put("node2", instanceProperty2);
185
186         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
187
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());
191
192     }
193
194     @Test
195     public void findPropertyValueBestMatch3() {
196
197         String propertyUniqueId = "x1";
198         ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
199         instanceProperty.setValue("v1");
200         instanceProperty.setDefaultValue("vv1");
201         List<String> path = new ArrayList<>();
202         path.add("node1");
203         path.add("node2");
204         path.add("node3");
205         instanceProperty.setPath(path);
206
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);
212
213         ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
214         instanceProperty3.setValue("v1node3");
215         instanceIdToValue.put("node3", instanceProperty3);
216
217         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
218
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());
222
223     }
224
225     @Test
226     public void findPropertyValueBestMatch1Rules() {
227
228         String propertyUniqueId = "x1";
229         ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
230         instanceProperty.setValue("v1");
231         instanceProperty.setDefaultValue("vv1");
232         List<String> path = new ArrayList<>();
233         path.add("node1");
234         path.add("node2");
235         path.add("node3");
236         instanceProperty.setPath(path);
237
238         Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
239         ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
240         instanceProperty1.setValue("v1node1");
241
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);
250
251         instanceIdToValue.put("node1", instanceProperty1);
252
253         ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
254         instanceProperty2.setValue("v1node2");
255         instanceIdToValue.put("node2", instanceProperty2);
256
257         ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
258         instanceProperty3.setValue("v1node3");
259         instanceIdToValue.put("node3", instanceProperty3);
260
261         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
262
263         assertEquals("check value", propertyRule.getValue(), instanceProperty.getValue());
264         assertEquals("check default value", "v1node2", instanceProperty.getDefaultValue());
265
266     }
267
268     @Test
269     public void findPropertyValueBestMatch2Rules() {
270
271         String propertyUniqueId = "x1";
272         ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
273         instanceProperty.setValue("v1");
274         instanceProperty.setDefaultValue("vv1");
275         List<String> path = new ArrayList<>();
276         path.add("node1");
277         path.add("node2");
278         path.add("node3");
279         instanceProperty.setPath(path);
280
281         Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
282         ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
283         instanceProperty1.setValue("v1node1");
284
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");
291
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");
297
298         rules.add(propertyRule2);
299         rules.add(propertyRule1);
300
301         instanceProperty1.setRules(rules);
302
303         instanceIdToValue.put("node1", instanceProperty1);
304
305         ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
306         instanceProperty2.setValue("v1node2");
307         instanceIdToValue.put("node2", instanceProperty2);
308
309         ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
310         instanceProperty3.setValue("v1node3");
311         instanceIdToValue.put("node3", instanceProperty3);
312
313         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
314
315         assertEquals("check value", propertyRule2.getValue(), instanceProperty.getValue());
316         assertEquals("check default value", "v1node2", instanceProperty.getDefaultValue());
317
318     }
319
320     @Test
321     public void findPropertyValueBestMatch1RuleLowLevel() {
322
323         String propertyUniqueId = "x1";
324         ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
325         instanceProperty.setValue("v1");
326         instanceProperty.setDefaultValue("vv1");
327         List<String> path = new ArrayList<>();
328         path.add("node1");
329         path.add("node2");
330         path.add("node3");
331         instanceProperty.setPath(path);
332
333         Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
334         ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
335         instanceProperty1.setValue("v1node1");
336
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");
343
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");
349
350         rules.add(propertyRule2);
351         rules.add(propertyRule1);
352
353         instanceProperty1.setRules(rules);
354
355         instanceIdToValue.put("node1", instanceProperty1);
356
357         ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
358         instanceProperty2.setValue("v1node2");
359
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);
367
368         instanceProperty2.setRules(rules3);
369         instanceIdToValue.put("node2", instanceProperty2);
370
371         ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
372         instanceProperty3.setValue("v1node3");
373         instanceIdToValue.put("node3", instanceProperty3);
374
375         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
376
377         assertEquals("check value", propertyRule2.getValue(), instanceProperty.getValue());
378         assertEquals("check default value", propertyRule3.getValue(), instanceProperty.getDefaultValue());
379
380     }
381
382     @Test
383     public void findPropertyValueBestMatchDefaultValueNotChanged() {
384
385         String propertyUniqueId = "x1";
386         ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
387         instanceProperty.setValue("v1");
388         instanceProperty.setDefaultValue("vv1");
389         List<String> path = new ArrayList<>();
390         path.add("node1");
391         path.add("node2");
392         path.add("node3");
393         instanceProperty.setPath(path);
394
395         Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
396         ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
397         instanceProperty1.setValue("v1node1");
398
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");
405
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");
411
412         rules.add(propertyRule2);
413         rules.add(propertyRule1);
414
415         instanceProperty1.setRules(rules);
416
417         instanceIdToValue.put("node1", instanceProperty1);
418
419         ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
420         instanceProperty2.setValue("v1node2");
421
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);
429
430         instanceProperty2.setRules(rules3);
431         instanceIdToValue.put("node2", instanceProperty2);
432
433         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
434
435         assertEquals("check value", propertyRule2.getValue(), instanceProperty.getValue());
436         assertEquals("check default value", "vv1", instanceProperty.getDefaultValue());
437
438         }
439
440         private PropertyOperation createTestSubject() {
441                 return new PropertyOperation(new HealingJanusGraphGenericDao(new JanusGraphClient()), null);
442         }
443
444         @Test
445         public void testConvertPropertyDataToPropertyDefinition() throws Exception {
446                 PropertyOperation testSubject;
447                 PropertyData propertyDataResult = new PropertyData();
448                 String propertyName = "";
449                 String resourceId = "";
450                 PropertyDefinition result;
451
452                 // default test
453                 testSubject = createTestSubject();
454                 result = testSubject.convertPropertyDataToPropertyDefinition(propertyDataResult, propertyName, resourceId);
455         }
456         
457         @Test
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;
464
465                 // default test
466                 testSubject = createTestSubject();
467                 result = testSubject.addProperty(propertyName, propertyDefinition, resourceId);
468         }
469
470         
471         @Test
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;
478
479                 // default test
480                 testSubject = createTestSubject();
481                 result = testSubject.validateAndUpdateProperty(propertyDefinition, dataTypes);
482         }
483
484         
485         @Test
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;
492
493                 // default test
494                 testSubject = createTestSubject();
495                 result = testSubject.addPropertyToGraph(propertyName, propertyDefinition, resourceId);
496         }
497
498         
499         @Test
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;
507
508                 // default test
509                 testSubject = createTestSubject();
510                 result = testSubject.addPropertyToGraphByVertex(metadataVertex, propertyName, propertyDefinition, resourceId);
511         }
512
513         
514         @Test
515         public void testGetJanusGraphGenericDao() throws Exception {
516                 PropertyOperation testSubject;
517                 JanusGraphGenericDao result;
518
519                 // default test
520                 testSubject = createTestSubject();
521                 result = testSubject.getJanusGraphGenericDao();
522         }
523
524         @Test
525         public void testDeletePropertyFromGraph() throws Exception {
526                 PropertyOperation testSubject;
527                 String propertyId = "";
528                 Either<PropertyData, JanusGraphOperationStatus> result;
529
530                 // default test
531                 testSubject = createTestSubject();
532                 result = testSubject.deletePropertyFromGraph(propertyId);
533         }
534
535         
536         @Test
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;
543
544                 // default test
545                 testSubject = createTestSubject();
546                 result = testSubject.updateProperty(propertyId, newPropertyDefinition, dataTypes);
547         }
548
549         
550         @Test
551         public void testUpdatePropertyFromGraph() throws Exception {
552                 PropertyOperation testSubject;
553                 String propertyId = "";
554                 PropertyDefinition propertyDefinition = null;
555                 Either<PropertyData, JanusGraphOperationStatus> result;
556
557                 // default test
558                 testSubject = createTestSubject();
559                 result = testSubject.updatePropertyFromGraph(propertyId, propertyDefinition);
560         }
561
562
563         @Test
564         public void testSetJanusGraphGenericDao()  {
565
566                 PropertyOperation testSubject;
567         HealingJanusGraphGenericDao janusGraphGenericDao = null;
568
569                 // default test
570                 testSubject = createTestSubject();
571                 testSubject.setJanusGraphGenericDao(janusGraphGenericDao);
572         }
573
574         
575         @Test
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;
583
584                 // default test
585                 testSubject = createTestSubject();
586                 result = testSubject.addPropertyToNodeType(propertyName, propertyDefinition, nodeType, uniqueId);
587         }
588
589         
590         @Test
591         public void testFindPropertiesOfNode() throws Exception {
592                 PropertyOperation testSubject;
593                 NodeTypeEnum nodeType = null;
594                 String uniqueId = "";
595                 Either<Map<String, PropertyDefinition>, JanusGraphOperationStatus> result;
596
597                 // default test
598                 testSubject = createTestSubject();
599                 result = testSubject.findPropertiesOfNode(nodeType, uniqueId);
600         }
601
602         
603         @Test
604         public void testDeletePropertiesAssociatedToNode() throws Exception {
605                 PropertyOperation testSubject;
606                 NodeTypeEnum nodeType = null;
607                 String uniqueId = "";
608                 Either<Map<String, PropertyDefinition>, StorageOperationStatus> result;
609
610                 // default test
611                 testSubject = createTestSubject();
612                 result = testSubject.deletePropertiesAssociatedToNode(nodeType, uniqueId);
613         }
614
615         
616         @Test
617         public void testDeleteAllPropertiesAssociatedToNode() throws Exception {
618                 PropertyOperation testSubject;
619                 NodeTypeEnum nodeType = null;
620                 String uniqueId = "";
621                 Either<Map<String, PropertyDefinition>, StorageOperationStatus> result;
622
623                 // default test
624                 testSubject = createTestSubject();
625                 result = testSubject.deleteAllPropertiesAssociatedToNode(nodeType, uniqueId);
626         }
627
628         
629         @Test
630         public void testIsPropertyExist() throws Exception {
631                 PropertyOperation testSubject;
632                 List<PropertyDefinition> properties = null;
633                 String resourceUid = "";
634                 String propertyName = "";
635                 String propertyType = "";
636                 boolean result;
637
638                 // default test
639                 testSubject = createTestSubject();
640                 result = testSubject.isPropertyExist(properties, resourceUid, propertyName, propertyType);
641         }
642
643         
644         @Test
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;
653
654                 // test 1
655                 testSubject = createTestSubject();
656                 rules = null;
657                 result = testSubject.validateAndUpdateRules(propertyType, rules, innerType, dataTypes, isValidate);
658         }
659
660         
661         @Test
662         public void testAddRulesToNewPropertyValue() throws Exception {
663                 PropertyOperation testSubject;
664                 PropertyValueData propertyValueData = new PropertyValueData();
665                 ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
666                 String resourceInstanceId = "";
667
668                 // default test
669                 testSubject = createTestSubject();
670                 testSubject.addRulesToNewPropertyValue(propertyValueData, resourceInstanceProperty, resourceInstanceId);
671         }
672
673         
674         @Test
675         public void testFindPropertyValue() throws Exception {
676                 PropertyOperation testSubject;
677                 String resourceInstanceId = "";
678                 String propertyId = "";
679                 ImmutablePair<JanusGraphOperationStatus, String> result;
680
681                 // default test
682                 testSubject = createTestSubject();
683                 result = testSubject.findPropertyValue(resourceInstanceId, propertyId);
684         }
685
686         
687         @Test
688         public void testUpdateRulesInPropertyValue() throws Exception {
689                 PropertyOperation testSubject;
690                 PropertyValueData propertyValueData = new PropertyValueData();
691                 ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
692                 String resourceInstanceId = "";
693
694                 // default test
695                 testSubject = createTestSubject();
696                 testSubject.updateRulesInPropertyValue(propertyValueData, resourceInstanceProperty, resourceInstanceId);
697         }
698
699         
700         @Test
701         public void testGetAllPropertiesOfResourceInstanceOnlyPropertyDefId() throws Exception {
702                 PropertyOperation testSubject;
703                 String resourceInstanceUid = "";
704                 Either<List<ComponentInstanceProperty>, JanusGraphOperationStatus> result;
705
706                 // default test
707                 testSubject = createTestSubject();
708                 result = testSubject.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceUid);
709         }
710
711         
712         @Test
713         public void testRemovePropertyOfResourceInstance() throws Exception {
714                 PropertyOperation testSubject;
715                 String propertyValueUid = "";
716                 String resourceInstanceId = "";
717                 Either<PropertyValueData, JanusGraphOperationStatus> result;
718
719                 // default test
720                 testSubject = createTestSubject();
721                 result = testSubject.removePropertyOfResourceInstance(propertyValueUid, resourceInstanceId);
722         }
723
724         
725         @Test
726         public void testRemovePropertyValueFromResourceInstance() throws Exception {
727                 PropertyOperation testSubject;
728                 String propertyValueUid = "";
729                 String resourceInstanceId = "";
730                 boolean inTransaction = false;
731                 Either<ComponentInstanceProperty, StorageOperationStatus> result;
732
733                 // default test
734                 testSubject = createTestSubject();
735                 result = testSubject.removePropertyValueFromResourceInstance(propertyValueUid, resourceInstanceId,
736                                 inTransaction);
737         }
738
739         
740         @Test
741         public void testBuildResourceInstanceProperty() throws Exception {
742                 PropertyOperation testSubject;
743                 PropertyValueData propertyValueData = new PropertyValueData();
744                 ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
745                 ComponentInstanceProperty result;
746
747                 // default test
748                 testSubject = createTestSubject();
749                 result = testSubject.buildResourceInstanceProperty(propertyValueData, resourceInstanceProperty);
750         }
751
752         
753         @Test
754         public void testIsPropertyDefaultValueValid() throws Exception {
755                 PropertyOperation testSubject;
756                 IComplexDefaultValue propertyDefinition = null;
757                 Map<String, DataTypeDefinition> dataTypes = null;
758                 boolean result;
759
760                 // test 1
761                 testSubject = createTestSubject();
762                 propertyDefinition = null;
763                 result = testSubject.isPropertyDefaultValueValid(propertyDefinition, dataTypes);
764                 Assert.assertEquals(false, result);
765         }
766
767         
768         @Test
769         public void testIsPropertyTypeValid() throws Exception {
770                 PropertyOperation testSubject;
771                 IComplexDefaultValue property = null;
772                 boolean result;
773
774                 // test 1
775                 testSubject = createTestSubject();
776                 property = null;
777                 result = testSubject.isPropertyTypeValid(property);
778                 Assert.assertEquals(false, result);
779         }
780
781         
782         @Test
783         public void testIsPropertyInnerTypeValid() throws Exception {
784                 PropertyOperation testSubject;
785                 IComplexDefaultValue property = null;
786                 Map<String, DataTypeDefinition> dataTypes = null;
787                 ImmutablePair<String, Boolean> result;
788
789                 // test 1
790                 testSubject = createTestSubject();
791                 property = null;
792                 result = testSubject.isPropertyInnerTypeValid(property, dataTypes);
793         }
794
795         
796         @Test
797         public void testGetAllPropertiesOfResourceInstanceOnlyPropertyDefId_1() throws Exception {
798                 PropertyOperation testSubject;
799                 String resourceInstanceUid = "";
800                 NodeTypeEnum instanceNodeType = null;
801                 Either<List<ComponentInstanceProperty>, JanusGraphOperationStatus> result;
802
803                 // default test
804                 testSubject = createTestSubject();
805                 result = testSubject.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceUid, instanceNodeType);
806         }
807
808         
809         @Test
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;
816
817                 // test 1
818                 testSubject = createTestSubject();
819                 pathOfComponentInstances = null;
820                 result = testSubject.findDefaultValueFromSecondPosition(pathOfComponentInstances, propertyUniqueId,
821                                 defaultValue);
822         }
823
824         
825         @Test
826         public void testUpdatePropertyByBestMatch() throws Exception {
827                 PropertyOperation testSubject;
828                 String propertyUniqueId = "";
829                 ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
830                 List<String> path = new ArrayList<>();
831                 path.add("path");
832                 instanceProperty.setPath(path);
833                 Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
834                 instanceIdToValue.put("123", instanceProperty);
835
836                 // default test
837                 testSubject = createTestSubject();
838                 testSubject.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
839         }
840
841         
842         @Test
843         public void testGetDataTypeByUid() throws Exception {
844                 PropertyOperation testSubject;
845                 String uniqueId = "";
846                 Either<DataTypeDefinition, JanusGraphOperationStatus> result;
847
848                 // default test
849                 testSubject = createTestSubject();
850                 result = testSubject.getDataTypeByUid(uniqueId);
851         }
852
853         
854         @Test
855         public void testAddDataType() throws Exception {
856                 PropertyOperation testSubject;
857                 DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
858                 Either<DataTypeDefinition, StorageOperationStatus> result;
859
860                 // default test
861                 testSubject = createTestSubject();
862                 result = testSubject.addDataType(dataTypeDefinition);
863         }
864
865         
866         @Test
867         public void testGetDataTypeByName() throws Exception {
868                 PropertyOperation testSubject;
869                 String name = "";
870                 boolean inTransaction = false;
871                 Either<DataTypeDefinition, StorageOperationStatus> result;
872
873                 // default test
874                 testSubject = createTestSubject();
875                 result = testSubject.getDataTypeByName(name, inTransaction);
876         }
877
878         
879         @Test
880         public void testGetDataTypeByName_1() throws Exception {
881                 PropertyOperation testSubject;
882                 String name = "";
883                 Either<DataTypeDefinition, StorageOperationStatus> result;
884
885                 // default test
886                 testSubject = createTestSubject();
887                 result = testSubject.getDataTypeByName(name);
888         }
889
890         
891         @Test
892         public void testGetDataTypeByNameWithoutDerived() throws Exception {
893                 PropertyOperation testSubject;
894                 String name = "";
895                 Either<DataTypeDefinition, StorageOperationStatus> result;
896
897                 // default test
898                 testSubject = createTestSubject();
899                 result = testSubject.getDataTypeByNameWithoutDerived(name);
900         }
901
902         
903         @Test
904         public void testGetDataTypeByUidWithoutDerivedDataTypes() throws Exception {
905                 PropertyOperation testSubject;
906                 String uniqueId = "";
907                 Either<DataTypeDefinition, JanusGraphOperationStatus> result;
908
909                 // default test
910                 testSubject = createTestSubject();
911                 result = testSubject.getDataTypeByUidWithoutDerivedDataTypes(uniqueId);
912         }
913
914         
915         @Test
916         public void testIsDefinedInDataTypes() throws Exception {
917                 PropertyOperation testSubject;
918                 String propertyType = "";
919                 Either<Boolean, JanusGraphOperationStatus> result;
920
921                 // default test
922                 testSubject = createTestSubject();
923                 result = testSubject.isDefinedInDataTypes(propertyType);
924         }
925
926         
927         @Test
928         public void testGetAllDataTypes() throws Exception {
929                 PropertyOperation testSubject;
930                 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> result;
931
932                 // default test
933                 testSubject = createTestSubject();
934                 result = testSubject.getAllDataTypes();
935         }
936
937         
938         @Test
939         public void testCheckInnerType() throws Exception {
940                 PropertyOperation testSubject;
941                 PropertyDataDefinition propDataDef = new PropertyDataDefinition();
942                 Either<String, JanusGraphOperationStatus> result;
943
944                 // default test
945                 testSubject = createTestSubject();
946                 result = testSubject.checkInnerType(propDataDef);
947         }
948
949         
950         @Test
951         public void testGetAllDataTypeNodes() throws Exception {
952                 PropertyOperation testSubject;
953                 Either<List<DataTypeData>, JanusGraphOperationStatus> result;
954
955                 // default test
956                 testSubject = createTestSubject();
957                 result = testSubject.getAllDataTypeNodes();
958         }
959
960         
961         @Test
962         public void testValidateAndUpdatePropertyValue() throws Exception {
963                 PropertyOperation testSubject;
964                 String propertyType = "";
965                 String value = "";
966                 boolean isValidate = false;
967                 String innerType = "";
968                 Map<String, DataTypeDefinition> dataTypes = null;
969                 Either<Object, Boolean> result;
970
971                 // default test
972                 testSubject = createTestSubject();
973                 result = testSubject.validateAndUpdatePropertyValue(propertyType, value, isValidate, innerType, dataTypes);
974         }
975
976         
977         @Test
978         public void testValidateAndUpdatePropertyValue_1() throws Exception {
979                 PropertyOperation testSubject;
980                 String propertyType = "";
981                 String value = "";
982                 String innerType = "";
983                 Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
984                 dataTypes.put("", new DataTypeDefinition());
985                 Either<Object, Boolean> result;
986
987                 // default test
988                 testSubject = createTestSubject();
989                 result = testSubject.validateAndUpdatePropertyValue(propertyType, value, innerType, dataTypes);
990         }
991
992         
993
994
995         
996         @Test
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;
1003
1004                 // test 1
1005                 testSubject = createTestSubject();
1006                 properties = null;
1007                 result = testSubject.addPropertiesToElementType(uniqueId, elementType, properties);
1008         }
1009
1010         
1011         @Test
1012         public void testUpdateDataType() throws Exception {
1013                 PropertyOperation testSubject;
1014                 DataTypeDefinition newDataTypeDefinition = new DataTypeDefinition();
1015                 DataTypeDefinition oldDataTypeDefinition = new DataTypeDefinition();
1016                 Either<DataTypeDefinition, StorageOperationStatus> result;
1017
1018                 // default test
1019                 testSubject = createTestSubject();
1020                 result = testSubject.updateDataType(newDataTypeDefinition, oldDataTypeDefinition);
1021         }
1022 }