Upgrade SDC from Titan to Janus Graph
[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.mockito.Mockito;
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
52 public class PropertyOperationTest extends ModelTestBase {
53
54     HealingJanusGraphGenericDao janusGraphGenericDao = Mockito.mock(HealingJanusGraphGenericDao.class);
55
56     PropertyOperation propertyOperation = new PropertyOperation(janusGraphGenericDao, null);
57
58     @Before
59     public void setup() {
60         propertyOperation.setJanusGraphGenericDao(janusGraphGenericDao);
61
62     }
63
64     /*
65      * @Test public void addPropertyToResourceTest() {
66      *
67      * String propName = "myProp"; PropertyDefinition property = buildPropertyDefinition(); List<PropertyConstraint> constraints = buildConstraints(); property.setConstraints(constraints);
68      *
69      * PropertyData propertyData = new PropertyData(property, propertyOperation.convertConstraintsToString(constraints));
70      *
71      * Either<PropertyData, JanusGraphOperationStatus> either = Either.left(propertyData); //when(propertyDao.create((GraphNeighbourTable)anyObject(), eq(PropertyData.class), eq(NodeTypeEnum.Property))).thenReturn(either); GraphRelation graphRelation =
72      * new GraphRelation(); Either<GraphRelation, JanusGraphOperationStatus> relationResult = Either.left(graphRelation);
73      *
74      * when(janusGraphGenericDao.createNode((PropertyData)anyObject(), eq(PropertyData.class))).thenReturn(either); when(janusGraphGenericDao.createRelation((GraphNode)anyObject(), (GraphNode)anyObject(), eq(GraphEdgeLabels.PROPERTY),
75      * anyMap())).thenReturn(relationResult);
76      *
77      * Either<PropertyDefinition, StorageOperationStatus> result = propertyOperation.addPropertyToResource(propName, property, NodeTypeEnum.Resource, "my-resource.1.0");
78      *
79      * assertTrue(result.isLeft()); System.out.println(result.left().value()); PropertyDefinition propertyDefinition = result.left().value();
80      *
81      * List<PropertyConstraint> originalConstraints = property.getConstraints(); List<PropertyConstraint> propertyConstraintsResult = propertyDefinition.getConstraints(); assertEquals(propertyConstraintsResult.size(), originalConstraints.size());
82      *
83      * }
84      */
85     private PropertyDefinition buildPropertyDefinition() {
86         PropertyDefinition property = new PropertyDefinition();
87         property.setDefaultValue("10");
88         property.setDescription("Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.");
89         property.setType(ToscaType.INTEGER.name().toLowerCase());
90         return property;
91     }
92
93     @Test
94     public void addPropertiesToGraphTableTest() {
95
96         // Map<String, PropertyDefinition> properties = new HashMap<String,
97         // PropertyDefinition>();
98         // String propName = "myProp";
99         // PropertyDefinition property = buildPropertyDefinition();
100         //
101         // List<PropertyConstraint> constraints = buildConstraints();
102         // property.setConstraints(constraints);
103         //
104         // properties.put(propName, property);
105         //
106         // GraphNeighbourTable graphNeighbourTable = new GraphNeighbourTable();
107         // ResourceData resourceData = new ResourceData();
108         // String resourceName = "my-resource";
109         // String resourceVersion = "1.0";
110         // String resourceId = resourceName + "." + resourceVersion;
111         // resourceData.setUniqueId(resourceId);
112         // int resourceIndex = graphNeighbourTable.addNode(resourceData);
113         //
114         // heatParametersOperation.addPropertiesToGraphTable(properties,
115         // graphNeighbourTable, resourceIndex, resourceId);
116         //
117         // assertEquals(2, graphNeighbourTable.getNodes().size());
118         // assertEquals(1, graphNeighbourTable.getDirectedEdges().size());
119         // List<GraphNode> nodes = graphNeighbourTable.getNodes();
120         // boolean nodeFound = false;
121         // for (GraphNode neo4jNode : nodes) {
122         // if (neo4jNode instanceof PropertyData) {
123         // PropertyData propertyData = (PropertyData)neo4jNode;
124         // assertEquals("check property unique id", resourceId + "." + propName,
125         // propertyData.getUniqueId());
126         // assertEquals(property.getDescription(),
127         // propertyData.getPropertyDataDefinition().getDescription());
128         // nodeFound = true;
129         // }
130         // }
131         // assertEquals("looking for PropertyData object in table", true,
132         // nodeFound);
133         //
134         // NodeRelation nodeRelation =
135         // graphNeighbourTable.getDirectedEdges().get(0);
136         // assertEquals("check from index to index edge", 0,
137         // nodeRelation.getFromIndex());
138         // assertEquals("check from index to index edge", 1,
139         // nodeRelation.getToIndex());
140         // assertEquals("check edge type",
141         // GraphEdgePropertiesDictionary.PROPERTY,
142         // nodeRelation.getEdge().getEdgeType());
143         // assertEquals("check propert name on edge", true,
144         // nodeRelation.getEdge().getProperties().values().contains(propName));
145     }
146
147     @Test
148     public void convertConstraintsTest() {
149
150         List<PropertyConstraint> constraints = buildConstraints();
151         List<String> convertedStringConstraints = propertyOperation.convertConstraintsToString(constraints);
152         assertEquals("constraints size", constraints.size(), convertedStringConstraints.size());
153
154         List<PropertyConstraint> convertedConstraints = propertyOperation.convertConstraints(convertedStringConstraints);
155         assertEquals("check size of constraints", constraints.size(), convertedConstraints.size());
156
157         Set<String> constraintsClasses = new HashSet<>();
158         for (PropertyConstraint propertyConstraint : constraints) {
159             constraintsClasses.add(propertyConstraint.getClass().getName());
160         }
161
162         for (PropertyConstraint propertyConstraint : convertedConstraints) {
163             assertTrue("check all classes generated", constraintsClasses.contains(propertyConstraint.getClass().getName()));
164         }
165     }
166
167     @Test
168     public void testIsPropertyDefaultValueValid_NoDefault() {
169         PropertyDefinition property = new PropertyDefinition();
170         property.setName("myProperty");
171         property.setType(ToscaPropertyType.BOOLEAN.getType());
172         assertTrue(propertyOperation.isPropertyDefaultValueValid(property, null));
173     }
174
175     @Test
176     public void testIsPropertyDefaultValueValid_ValidDefault() {
177         PropertyDefinition property = new PropertyDefinition();
178         property.setName("myProperty");
179         property.setType(ToscaPropertyType.INTEGER.getType());
180         property.setDefaultValue("50");
181         assertTrue(propertyOperation.isPropertyDefaultValueValid(property, null));
182     }
183
184     @Test
185     public void testIsPropertyDefaultValueValid_InvalidDefault() {
186         PropertyDefinition property = new PropertyDefinition();
187         property.setName("myProperty");
188         property.setType(ToscaPropertyType.BOOLEAN.getType());
189         property.setDefaultValue("50");
190         assertFalse(propertyOperation.isPropertyDefaultValueValid(property, null));
191     }
192
193     private List<PropertyConstraint> buildConstraints() {
194         List<PropertyConstraint> constraints = new ArrayList<>();
195         GreaterThanConstraint propertyConstraint1 = new GreaterThanConstraint("0");
196         LessOrEqualConstraint propertyConstraint2 = new LessOrEqualConstraint("10");
197         List<String> range = new ArrayList<>();
198         range.add("0");
199         range.add("100");
200         InRangeConstraint propertyConstraint3 = new InRangeConstraint(range);
201         constraints.add(propertyConstraint1);
202         constraints.add(propertyConstraint2);
203         constraints.add(propertyConstraint3);
204         return constraints;
205     }
206
207     @Test
208     public void findPropertyValueBestMatch1() {
209
210         String propertyUniqueId = "x1";
211         ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
212         instanceProperty.setValue("v1");
213         instanceProperty.setDefaultValue("vv1");
214         List<String> path = new ArrayList<>();
215         path.add("node1");
216         path.add("node2");
217         path.add("node3");
218         instanceProperty.setPath(path);
219
220         Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
221         ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
222         instanceProperty1.setValue("v1node1");
223         instanceIdToValue.put("node1", instanceProperty1);
224
225         ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
226         instanceProperty2.setValue("v1node2");
227         instanceIdToValue.put("node2", instanceProperty2);
228
229         ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
230         instanceProperty3.setValue("v1node3");
231         instanceIdToValue.put("node3", instanceProperty3);
232
233         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
234
235         assertEquals("check value", "v1node1", instanceProperty.getValue());
236         assertEquals("check default value", "v1node2", instanceProperty.getDefaultValue());
237
238     }
239
240     @Test
241     public void findPropertyValueBestMatch2() {
242
243         String propertyUniqueId = "x1";
244         ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
245         instanceProperty.setValue("v1");
246         instanceProperty.setDefaultValue("vv1");
247         List<String> path = new ArrayList<>();
248         path.add("node1");
249         path.add("node2");
250         path.add("node3");
251         instanceProperty.setPath(path);
252
253         Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
254
255         ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
256         instanceProperty2.setValue("v1node2");
257         instanceProperty2.setValueUniqueUid("aaaa");
258         instanceIdToValue.put("node2", instanceProperty2);
259
260         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
261
262         assertEquals("check value", "v1node2", instanceProperty.getValue());
263         assertEquals("check default value", "vv1", instanceProperty.getDefaultValue());
264         assertNull("check value unique id is null", instanceProperty.getValueUniqueUid());
265
266     }
267
268     @Test
269     public void findPropertyValueBestMatch3() {
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         instanceProperty1.setValueUniqueUid("aaaa");
285         instanceIdToValue.put("node1", instanceProperty1);
286
287         ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
288         instanceProperty3.setValue("v1node3");
289         instanceIdToValue.put("node3", instanceProperty3);
290
291         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
292
293         assertEquals("check value", "v1node1", instanceProperty.getValue());
294         assertEquals("check default value", "v1node3", instanceProperty.getDefaultValue());
295         assertEquals("check valid unique id", instanceProperty1.getValueUniqueUid(), instanceProperty.getValueUniqueUid());
296
297     }
298
299     @Test
300     public void findPropertyValueBestMatch1Rules() {
301
302         String propertyUniqueId = "x1";
303         ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
304         instanceProperty.setValue("v1");
305         instanceProperty.setDefaultValue("vv1");
306         List<String> path = new ArrayList<>();
307         path.add("node1");
308         path.add("node2");
309         path.add("node3");
310         instanceProperty.setPath(path);
311
312         Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
313         ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
314         instanceProperty1.setValue("v1node1");
315
316         List<PropertyRule> rules = new ArrayList<>();
317         PropertyRule propertyRule = new PropertyRule();
318         String[] ruleArr = { "node1", ".+", "node3" };
319         List<String> rule1 = new ArrayList<>(Arrays.asList(ruleArr));
320         propertyRule.setRule(rule1);
321         propertyRule.setValue("88");
322         rules.add(propertyRule);
323         instanceProperty1.setRules(rules);
324
325         instanceIdToValue.put("node1", instanceProperty1);
326
327         ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
328         instanceProperty2.setValue("v1node2");
329         instanceIdToValue.put("node2", instanceProperty2);
330
331         ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
332         instanceProperty3.setValue("v1node3");
333         instanceIdToValue.put("node3", instanceProperty3);
334
335         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
336
337         assertEquals("check value", propertyRule.getValue(), instanceProperty.getValue());
338         assertEquals("check default value", "v1node2", instanceProperty.getDefaultValue());
339
340     }
341
342     @Test
343     public void findPropertyValueBestMatch2Rules() {
344
345         String propertyUniqueId = "x1";
346         ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
347         instanceProperty.setValue("v1");
348         instanceProperty.setDefaultValue("vv1");
349         List<String> path = new ArrayList<>();
350         path.add("node1");
351         path.add("node2");
352         path.add("node3");
353         instanceProperty.setPath(path);
354
355         Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
356         ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
357         instanceProperty1.setValue("v1node1");
358
359         List<PropertyRule> rules = new ArrayList<>();
360         PropertyRule propertyRule1 = new PropertyRule();
361         String[] ruleArr1 = { "node1", "node2", ".+" };
362         List<String> rule1 = new ArrayList<>(Arrays.asList(ruleArr1));
363         propertyRule1.setRule(rule1);
364         propertyRule1.setValue("88");
365
366         PropertyRule propertyRule2 = new PropertyRule();
367         String[] ruleArr2 = { "node1", "node2", "node3" };
368         List<String> rule2 = new ArrayList<>(Arrays.asList(ruleArr2));
369         propertyRule2.setRule(rule2);
370         propertyRule2.setValue("99");
371
372         rules.add(propertyRule2);
373         rules.add(propertyRule1);
374
375         instanceProperty1.setRules(rules);
376
377         instanceIdToValue.put("node1", instanceProperty1);
378
379         ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
380         instanceProperty2.setValue("v1node2");
381         instanceIdToValue.put("node2", instanceProperty2);
382
383         ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
384         instanceProperty3.setValue("v1node3");
385         instanceIdToValue.put("node3", instanceProperty3);
386
387         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
388
389         assertEquals("check value", propertyRule2.getValue(), instanceProperty.getValue());
390         assertEquals("check default value", "v1node2", instanceProperty.getDefaultValue());
391
392     }
393
394     @Test
395     public void findPropertyValueBestMatch1RuleLowLevel() {
396
397         String propertyUniqueId = "x1";
398         ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
399         instanceProperty.setValue("v1");
400         instanceProperty.setDefaultValue("vv1");
401         List<String> path = new ArrayList<>();
402         path.add("node1");
403         path.add("node2");
404         path.add("node3");
405         instanceProperty.setPath(path);
406
407         Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
408         ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
409         instanceProperty1.setValue("v1node1");
410
411         List<PropertyRule> rules = new ArrayList<>();
412         PropertyRule propertyRule1 = new PropertyRule();
413         String[] ruleArr1 = { "node1", "node2", ".+" };
414         List<String> rule1 = new ArrayList<>(Arrays.asList(ruleArr1));
415         propertyRule1.setRule(rule1);
416         propertyRule1.setValue("88");
417
418         PropertyRule propertyRule2 = new PropertyRule();
419         String[] ruleArr2 = { "node1", "node2", "node3" };
420         List<String> rule2 = new ArrayList<>(Arrays.asList(ruleArr2));
421         propertyRule2.setRule(rule2);
422         propertyRule2.setValue("99");
423
424         rules.add(propertyRule2);
425         rules.add(propertyRule1);
426
427         instanceProperty1.setRules(rules);
428
429         instanceIdToValue.put("node1", instanceProperty1);
430
431         ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
432         instanceProperty2.setValue("v1node2");
433
434         List<PropertyRule> rules3 = new ArrayList<>();
435         PropertyRule propertyRule3 = new PropertyRule();
436         String[] ruleArr3 = { "node2", "node3" };
437         List<String> rule3 = new ArrayList<>(Arrays.asList(ruleArr3));
438         propertyRule3.setRule(rule3);
439         propertyRule3.setValue("77");
440         rules3.add(propertyRule3);
441
442         instanceProperty2.setRules(rules3);
443         instanceIdToValue.put("node2", instanceProperty2);
444
445         ComponentInstanceProperty instanceProperty3 = new ComponentInstanceProperty();
446         instanceProperty3.setValue("v1node3");
447         instanceIdToValue.put("node3", instanceProperty3);
448
449         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
450
451         assertEquals("check value", propertyRule2.getValue(), instanceProperty.getValue());
452         assertEquals("check default value", propertyRule3.getValue(), instanceProperty.getDefaultValue());
453
454     }
455
456     @Test
457     public void findPropertyValueBestMatchDefaultValueNotChanged() {
458
459         String propertyUniqueId = "x1";
460         ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
461         instanceProperty.setValue("v1");
462         instanceProperty.setDefaultValue("vv1");
463         List<String> path = new ArrayList<>();
464         path.add("node1");
465         path.add("node2");
466         path.add("node3");
467         instanceProperty.setPath(path);
468
469         Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
470         ComponentInstanceProperty instanceProperty1 = new ComponentInstanceProperty();
471         instanceProperty1.setValue("v1node1");
472
473         List<PropertyRule> rules = new ArrayList<>();
474         PropertyRule propertyRule1 = new PropertyRule();
475         String[] ruleArr1 = { "node1", "node2", ".+" };
476         List<String> rule1 = new ArrayList<>(Arrays.asList(ruleArr1));
477         propertyRule1.setRule(rule1);
478         propertyRule1.setValue("88");
479
480         PropertyRule propertyRule2 = new PropertyRule();
481         String[] ruleArr2 = { "node1", "node2", "node3" };
482         List<String> rule2 = new ArrayList<>(Arrays.asList(ruleArr2));
483         propertyRule2.setRule(rule2);
484         propertyRule2.setValue("99");
485
486         rules.add(propertyRule2);
487         rules.add(propertyRule1);
488
489         instanceProperty1.setRules(rules);
490
491         instanceIdToValue.put("node1", instanceProperty1);
492
493         ComponentInstanceProperty instanceProperty2 = new ComponentInstanceProperty();
494         instanceProperty2.setValue("v1node2");
495
496         List<PropertyRule> rules3 = new ArrayList<>();
497         PropertyRule propertyRule3 = new PropertyRule();
498         String[] ruleArr3 = { "node2", "node333" };
499         List<String> rule3 = new ArrayList<>(Arrays.asList(ruleArr3));
500         propertyRule3.setRule(rule3);
501         propertyRule3.setValue("77");
502         rules3.add(propertyRule3);
503
504         instanceProperty2.setRules(rules3);
505         instanceIdToValue.put("node2", instanceProperty2);
506
507         propertyOperation.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
508
509         assertEquals("check value", propertyRule2.getValue(), instanceProperty.getValue());
510         assertEquals("check default value", "vv1", instanceProperty.getDefaultValue());
511
512         }
513
514         private PropertyOperation createTestSubject() {
515                 return new PropertyOperation(new HealingJanusGraphGenericDao(new JanusGraphClient()), null);
516         }
517
518         
519         @Test
520         public void testMain() throws Exception {
521                 String[] args = new String[] { "" };
522
523                 // default test
524                 PropertyOperation.main(args);
525         }
526
527         
528         @Test
529         public void testConvertPropertyDataToPropertyDefinition() throws Exception {
530                 PropertyOperation testSubject;
531                 PropertyData propertyDataResult = new PropertyData();
532                 String propertyName = "";
533                 String resourceId = "";
534                 PropertyDefinition result;
535
536                 // default test
537                 testSubject = createTestSubject();
538                 result = testSubject.convertPropertyDataToPropertyDefinition(propertyDataResult, propertyName, resourceId);
539         }
540         
541         @Test
542         public void testAddProperty() throws Exception {
543                 PropertyOperation testSubject;
544                 String propertyName = "";
545                 PropertyDefinition propertyDefinition = new PropertyDefinition();
546                 String resourceId = "";
547                 Either<PropertyData, StorageOperationStatus> result;
548
549                 // default test
550                 testSubject = createTestSubject();
551                 result = testSubject.addProperty(propertyName, propertyDefinition, resourceId);
552         }
553
554         
555         @Test
556         public void testValidateAndUpdateProperty() throws Exception {
557                 PropertyOperation testSubject;
558                 IComplexDefaultValue propertyDefinition = new PropertyDefinition();
559                 Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
560                 dataTypes.put("", new DataTypeDefinition());
561                 StorageOperationStatus result;
562
563                 // default test
564                 testSubject = createTestSubject();
565                 result = testSubject.validateAndUpdateProperty(propertyDefinition, dataTypes);
566         }
567
568         
569         @Test
570         public void testAddPropertyToGraph() throws Exception {
571                 PropertyOperation testSubject;
572                 String propertyName = "";
573                 PropertyDefinition propertyDefinition = new PropertyDefinition();
574                 String resourceId = "";
575                 Either<PropertyData, JanusGraphOperationStatus> result;
576
577                 // default test
578                 testSubject = createTestSubject();
579                 result = testSubject.addPropertyToGraph(propertyName, propertyDefinition, resourceId);
580         }
581
582         
583         @Test
584         public void testAddPropertyToGraphByVertex() throws Exception {
585                 PropertyOperation testSubject;
586                 JanusGraphVertex metadataVertex = null;
587                 String propertyName = "";
588                 PropertyDefinition propertyDefinition = new PropertyDefinition();
589                 String resourceId = "";
590                 JanusGraphOperationStatus result;
591
592                 // default test
593                 testSubject = createTestSubject();
594                 result = testSubject.addPropertyToGraphByVertex(metadataVertex, propertyName, propertyDefinition, resourceId);
595         }
596
597         
598         @Test
599         public void testGetJanusGraphGenericDao() throws Exception {
600                 PropertyOperation testSubject;
601                 JanusGraphGenericDao result;
602
603                 // default test
604                 testSubject = createTestSubject();
605                 result = testSubject.getJanusGraphGenericDao();
606         }
607
608         @Test
609         public void testDeletePropertyFromGraph() throws Exception {
610                 PropertyOperation testSubject;
611                 String propertyId = "";
612                 Either<PropertyData, JanusGraphOperationStatus> result;
613
614                 // default test
615                 testSubject = createTestSubject();
616                 result = testSubject.deletePropertyFromGraph(propertyId);
617         }
618
619         
620         @Test
621         public void testUpdateProperty() throws Exception {
622                 PropertyOperation testSubject;
623                 String propertyId = "";
624                 PropertyDefinition newPropertyDefinition = new PropertyDefinition();
625                 Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
626                 Either<PropertyData, StorageOperationStatus> result;
627
628                 // default test
629                 testSubject = createTestSubject();
630                 result = testSubject.updateProperty(propertyId, newPropertyDefinition, dataTypes);
631         }
632
633         
634         @Test
635         public void testUpdatePropertyFromGraph() throws Exception {
636                 PropertyOperation testSubject;
637                 String propertyId = "";
638                 PropertyDefinition propertyDefinition = null;
639                 Either<PropertyData, JanusGraphOperationStatus> result;
640
641                 // default test
642                 testSubject = createTestSubject();
643                 result = testSubject.updatePropertyFromGraph(propertyId, propertyDefinition);
644         }
645
646
647         @Test
648         public void testSetJanusGraphGenericDao()  {
649
650                 PropertyOperation testSubject;
651         HealingJanusGraphGenericDao janusGraphGenericDao = null;
652
653                 // default test
654                 testSubject = createTestSubject();
655                 testSubject.setJanusGraphGenericDao(janusGraphGenericDao);
656         }
657
658         
659         @Test
660         public void testAddPropertyToNodeType()  {
661                 PropertyOperation testSubject;
662                 String propertyName = "";
663                 PropertyDefinition propertyDefinition = new PropertyDefinition();
664                 NodeTypeEnum nodeType = NodeTypeEnum.Attribute;
665                 String uniqueId = "";
666                 Either<PropertyData, JanusGraphOperationStatus> result;
667
668                 // default test
669                 testSubject = createTestSubject();
670                 result = testSubject.addPropertyToNodeType(propertyName, propertyDefinition, nodeType, uniqueId);
671         }
672
673         
674         @Test
675         public void testFindPropertiesOfNode() throws Exception {
676                 PropertyOperation testSubject;
677                 NodeTypeEnum nodeType = null;
678                 String uniqueId = "";
679                 Either<Map<String, PropertyDefinition>, JanusGraphOperationStatus> result;
680
681                 // default test
682                 testSubject = createTestSubject();
683                 result = testSubject.findPropertiesOfNode(nodeType, uniqueId);
684         }
685
686         
687         @Test
688         public void testDeletePropertiesAssociatedToNode() throws Exception {
689                 PropertyOperation testSubject;
690                 NodeTypeEnum nodeType = null;
691                 String uniqueId = "";
692                 Either<Map<String, PropertyDefinition>, StorageOperationStatus> result;
693
694                 // default test
695                 testSubject = createTestSubject();
696                 result = testSubject.deletePropertiesAssociatedToNode(nodeType, uniqueId);
697         }
698
699         
700         @Test
701         public void testDeleteAllPropertiesAssociatedToNode() throws Exception {
702                 PropertyOperation testSubject;
703                 NodeTypeEnum nodeType = null;
704                 String uniqueId = "";
705                 Either<Map<String, PropertyDefinition>, StorageOperationStatus> result;
706
707                 // default test
708                 testSubject = createTestSubject();
709                 result = testSubject.deleteAllPropertiesAssociatedToNode(nodeType, uniqueId);
710         }
711
712         
713         @Test
714         public void testIsPropertyExist() throws Exception {
715                 PropertyOperation testSubject;
716                 List<PropertyDefinition> properties = null;
717                 String resourceUid = "";
718                 String propertyName = "";
719                 String propertyType = "";
720                 boolean result;
721
722                 // default test
723                 testSubject = createTestSubject();
724                 result = testSubject.isPropertyExist(properties, resourceUid, propertyName, propertyType);
725         }
726
727         
728         @Test
729         public void testValidateAndUpdateRules() throws Exception {
730                 PropertyOperation testSubject;
731                 String propertyType = "";
732                 List<PropertyRule> rules = null;
733                 String innerType = "";
734                 Map<String, DataTypeDefinition> dataTypes = null;
735                 boolean isValidate = false;
736                 ImmutablePair<String, Boolean> result;
737
738                 // test 1
739                 testSubject = createTestSubject();
740                 rules = null;
741                 result = testSubject.validateAndUpdateRules(propertyType, rules, innerType, dataTypes, isValidate);
742         }
743
744         
745         @Test
746         public void testAddRulesToNewPropertyValue() throws Exception {
747                 PropertyOperation testSubject;
748                 PropertyValueData propertyValueData = new PropertyValueData();
749                 ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
750                 String resourceInstanceId = "";
751
752                 // default test
753                 testSubject = createTestSubject();
754                 testSubject.addRulesToNewPropertyValue(propertyValueData, resourceInstanceProperty, resourceInstanceId);
755         }
756
757         
758         @Test
759         public void testFindPropertyValue() throws Exception {
760                 PropertyOperation testSubject;
761                 String resourceInstanceId = "";
762                 String propertyId = "";
763                 ImmutablePair<JanusGraphOperationStatus, String> result;
764
765                 // default test
766                 testSubject = createTestSubject();
767                 result = testSubject.findPropertyValue(resourceInstanceId, propertyId);
768         }
769
770         
771         @Test
772         public void testUpdateRulesInPropertyValue() throws Exception {
773                 PropertyOperation testSubject;
774                 PropertyValueData propertyValueData = new PropertyValueData();
775                 ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
776                 String resourceInstanceId = "";
777
778                 // default test
779                 testSubject = createTestSubject();
780                 testSubject.updateRulesInPropertyValue(propertyValueData, resourceInstanceProperty, resourceInstanceId);
781         }
782
783         
784         @Test
785         public void testGetAllPropertiesOfResourceInstanceOnlyPropertyDefId() throws Exception {
786                 PropertyOperation testSubject;
787                 String resourceInstanceUid = "";
788                 Either<List<ComponentInstanceProperty>, JanusGraphOperationStatus> result;
789
790                 // default test
791                 testSubject = createTestSubject();
792                 result = testSubject.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceUid);
793         }
794
795         
796         @Test
797         public void testRemovePropertyOfResourceInstance() throws Exception {
798                 PropertyOperation testSubject;
799                 String propertyValueUid = "";
800                 String resourceInstanceId = "";
801                 Either<PropertyValueData, JanusGraphOperationStatus> result;
802
803                 // default test
804                 testSubject = createTestSubject();
805                 result = testSubject.removePropertyOfResourceInstance(propertyValueUid, resourceInstanceId);
806         }
807
808         
809         @Test
810         public void testRemovePropertyValueFromResourceInstance() throws Exception {
811                 PropertyOperation testSubject;
812                 String propertyValueUid = "";
813                 String resourceInstanceId = "";
814                 boolean inTransaction = false;
815                 Either<ComponentInstanceProperty, StorageOperationStatus> result;
816
817                 // default test
818                 testSubject = createTestSubject();
819                 result = testSubject.removePropertyValueFromResourceInstance(propertyValueUid, resourceInstanceId,
820                                 inTransaction);
821         }
822
823         
824         @Test
825         public void testBuildResourceInstanceProperty() throws Exception {
826                 PropertyOperation testSubject;
827                 PropertyValueData propertyValueData = new PropertyValueData();
828                 ComponentInstanceProperty resourceInstanceProperty = new ComponentInstanceProperty();
829                 ComponentInstanceProperty result;
830
831                 // default test
832                 testSubject = createTestSubject();
833                 result = testSubject.buildResourceInstanceProperty(propertyValueData, resourceInstanceProperty);
834         }
835
836         
837         @Test
838         public void testIsPropertyDefaultValueValid() throws Exception {
839                 PropertyOperation testSubject;
840                 IComplexDefaultValue propertyDefinition = null;
841                 Map<String, DataTypeDefinition> dataTypes = null;
842                 boolean result;
843
844                 // test 1
845                 testSubject = createTestSubject();
846                 propertyDefinition = null;
847                 result = testSubject.isPropertyDefaultValueValid(propertyDefinition, dataTypes);
848                 Assert.assertEquals(false, result);
849         }
850
851         
852         @Test
853         public void testIsPropertyTypeValid() throws Exception {
854                 PropertyOperation testSubject;
855                 IComplexDefaultValue property = null;
856                 boolean result;
857
858                 // test 1
859                 testSubject = createTestSubject();
860                 property = null;
861                 result = testSubject.isPropertyTypeValid(property);
862                 Assert.assertEquals(false, result);
863         }
864
865         
866         @Test
867         public void testIsPropertyInnerTypeValid() throws Exception {
868                 PropertyOperation testSubject;
869                 IComplexDefaultValue property = null;
870                 Map<String, DataTypeDefinition> dataTypes = null;
871                 ImmutablePair<String, Boolean> result;
872
873                 // test 1
874                 testSubject = createTestSubject();
875                 property = null;
876                 result = testSubject.isPropertyInnerTypeValid(property, dataTypes);
877         }
878
879         
880         @Test
881         public void testGetAllPropertiesOfResourceInstanceOnlyPropertyDefId_1() throws Exception {
882                 PropertyOperation testSubject;
883                 String resourceInstanceUid = "";
884                 NodeTypeEnum instanceNodeType = null;
885                 Either<List<ComponentInstanceProperty>, JanusGraphOperationStatus> result;
886
887                 // default test
888                 testSubject = createTestSubject();
889                 result = testSubject.getAllPropertiesOfResourceInstanceOnlyPropertyDefId(resourceInstanceUid, instanceNodeType);
890         }
891
892         
893         @Test
894         public void testFindDefaultValueFromSecondPosition() throws Exception {
895                 PropertyOperation testSubject;
896                 List<String> pathOfComponentInstances = null;
897                 String propertyUniqueId = "";
898                 String defaultValue = "";
899                 Either<String, JanusGraphOperationStatus> result;
900
901                 // test 1
902                 testSubject = createTestSubject();
903                 pathOfComponentInstances = null;
904                 result = testSubject.findDefaultValueFromSecondPosition(pathOfComponentInstances, propertyUniqueId,
905                                 defaultValue);
906         }
907
908         
909         @Test
910         public void testUpdatePropertyByBestMatch() throws Exception {
911                 PropertyOperation testSubject;
912                 String propertyUniqueId = "";
913                 ComponentInstanceProperty instanceProperty = new ComponentInstanceProperty();
914                 List<String> path = new ArrayList<>();
915                 path.add("path");
916                 instanceProperty.setPath(path);
917                 Map<String, ComponentInstanceProperty> instanceIdToValue = new HashMap<>();
918                 instanceIdToValue.put("123", instanceProperty);
919
920                 // default test
921                 testSubject = createTestSubject();
922                 testSubject.updatePropertyByBestMatch(propertyUniqueId, instanceProperty, instanceIdToValue);
923         }
924
925         
926         @Test
927         public void testGetDataTypeByUid() throws Exception {
928                 PropertyOperation testSubject;
929                 String uniqueId = "";
930                 Either<DataTypeDefinition, JanusGraphOperationStatus> result;
931
932                 // default test
933                 testSubject = createTestSubject();
934                 result = testSubject.getDataTypeByUid(uniqueId);
935         }
936
937         
938         @Test
939         public void testAddDataType() throws Exception {
940                 PropertyOperation testSubject;
941                 DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
942                 Either<DataTypeDefinition, StorageOperationStatus> result;
943
944                 // default test
945                 testSubject = createTestSubject();
946                 result = testSubject.addDataType(dataTypeDefinition);
947         }
948
949         
950         @Test
951         public void testGetDataTypeByName() throws Exception {
952                 PropertyOperation testSubject;
953                 String name = "";
954                 boolean inTransaction = false;
955                 Either<DataTypeDefinition, StorageOperationStatus> result;
956
957                 // default test
958                 testSubject = createTestSubject();
959                 result = testSubject.getDataTypeByName(name, inTransaction);
960         }
961
962         
963         @Test
964         public void testGetDataTypeByName_1() throws Exception {
965                 PropertyOperation testSubject;
966                 String name = "";
967                 Either<DataTypeDefinition, StorageOperationStatus> result;
968
969                 // default test
970                 testSubject = createTestSubject();
971                 result = testSubject.getDataTypeByName(name);
972         }
973
974         
975         @Test
976         public void testGetDataTypeByNameWithoutDerived() throws Exception {
977                 PropertyOperation testSubject;
978                 String name = "";
979                 Either<DataTypeDefinition, StorageOperationStatus> result;
980
981                 // default test
982                 testSubject = createTestSubject();
983                 result = testSubject.getDataTypeByNameWithoutDerived(name);
984         }
985
986         
987         @Test
988         public void testGetDataTypeByUidWithoutDerivedDataTypes() throws Exception {
989                 PropertyOperation testSubject;
990                 String uniqueId = "";
991                 Either<DataTypeDefinition, JanusGraphOperationStatus> result;
992
993                 // default test
994                 testSubject = createTestSubject();
995                 result = testSubject.getDataTypeByUidWithoutDerivedDataTypes(uniqueId);
996         }
997
998         
999         @Test
1000         public void testIsDefinedInDataTypes() throws Exception {
1001                 PropertyOperation testSubject;
1002                 String propertyType = "";
1003                 Either<Boolean, JanusGraphOperationStatus> result;
1004
1005                 // default test
1006                 testSubject = createTestSubject();
1007                 result = testSubject.isDefinedInDataTypes(propertyType);
1008         }
1009
1010         
1011         @Test
1012         public void testGetAllDataTypes() throws Exception {
1013                 PropertyOperation testSubject;
1014                 Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> result;
1015
1016                 // default test
1017                 testSubject = createTestSubject();
1018                 result = testSubject.getAllDataTypes();
1019         }
1020
1021         
1022         @Test
1023         public void testCheckInnerType() throws Exception {
1024                 PropertyOperation testSubject;
1025                 PropertyDataDefinition propDataDef = new PropertyDataDefinition();
1026                 Either<String, JanusGraphOperationStatus> result;
1027
1028                 // default test
1029                 testSubject = createTestSubject();
1030                 result = testSubject.checkInnerType(propDataDef);
1031         }
1032
1033         
1034         @Test
1035         public void testGetAllDataTypeNodes() throws Exception {
1036                 PropertyOperation testSubject;
1037                 Either<List<DataTypeData>, JanusGraphOperationStatus> result;
1038
1039                 // default test
1040                 testSubject = createTestSubject();
1041                 result = testSubject.getAllDataTypeNodes();
1042         }
1043
1044         
1045         @Test
1046         public void testValidateAndUpdatePropertyValue() throws Exception {
1047                 PropertyOperation testSubject;
1048                 String propertyType = "";
1049                 String value = "";
1050                 boolean isValidate = false;
1051                 String innerType = "";
1052                 Map<String, DataTypeDefinition> dataTypes = null;
1053                 Either<Object, Boolean> result;
1054
1055                 // default test
1056                 testSubject = createTestSubject();
1057                 result = testSubject.validateAndUpdatePropertyValue(propertyType, value, isValidate, innerType, dataTypes);
1058         }
1059
1060         
1061         @Test
1062         public void testValidateAndUpdatePropertyValue_1() throws Exception {
1063                 PropertyOperation testSubject;
1064                 String propertyType = "";
1065                 String value = "";
1066                 String innerType = "";
1067                 Map<String, DataTypeDefinition> dataTypes = new HashMap<>();
1068                 dataTypes.put("", new DataTypeDefinition());
1069                 Either<Object, Boolean> result;
1070
1071                 // default test
1072                 testSubject = createTestSubject();
1073                 result = testSubject.validateAndUpdatePropertyValue(propertyType, value, innerType, dataTypes);
1074         }
1075
1076         
1077
1078
1079         
1080         @Test
1081         public void testAddPropertiesToElementType() throws Exception {
1082                 PropertyOperation testSubject;
1083                 String uniqueId = "";
1084                 NodeTypeEnum elementType = null;
1085                 List<PropertyDefinition> properties = null;
1086                 Either<Map<String, PropertyData>, JanusGraphOperationStatus> result;
1087
1088                 // test 1
1089                 testSubject = createTestSubject();
1090                 properties = null;
1091                 result = testSubject.addPropertiesToElementType(uniqueId, elementType, properties);
1092         }
1093
1094         
1095         @Test
1096         public void testUpdateDataType() throws Exception {
1097                 PropertyOperation testSubject;
1098                 DataTypeDefinition newDataTypeDefinition = new DataTypeDefinition();
1099                 DataTypeDefinition oldDataTypeDefinition = new DataTypeDefinition();
1100                 Either<DataTypeDefinition, StorageOperationStatus> result;
1101
1102                 // default test
1103                 testSubject = createTestSubject();
1104                 result = testSubject.updateDataType(newDataTypeDefinition, oldDataTypeDefinition);
1105         }
1106 }