aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/aai/migration/v14/MigrateSameSourcedRCTROPServerDataTest.java
blob: e09b36bb3fb19eccd54c116a3f9f754e566b0e32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
/**
 * ============LICENSE_START=======================================================
 * org.onap.aai
 * ================================================================================
 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */
package org.onap.aai.migration.v14;

import static org.junit.Assert.*;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

import java.util.List;
import java.util.UUID;

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.*;
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.migration.v14.MigrateSameSourcedRCTROPserverData;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.janusgraph.core.JanusGraphFactory;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphTransaction;

public class MigrateSameSourcedRCTROPServerDataTest extends AAISetup{

    private final static ModelType introspectorFactoryType = ModelType.MOXY;
    private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;

     Loader loader;
     TransactionalGraphEngine dbEngine;
     JanusGraph graph;
     MigrateSameSourcedRCTROPserverData migration;
     JanusGraphTransaction tx;
     GraphTraversalSource g;
     Vertex pintOld;
     Vertex lInterfaceold;
     Vertex pintOldRo;
     Vertex lInterfaceoldRo;
     Vertex pintOldRo1;
     Vertex pintNewRo1;
     Vertex plinkROonOldRo1;

     Vertex pintOldScn3;
     Vertex pintNewScn3;
     Vertex pLinkOldScn3;
     Vertex  pLinkNewScn3;

     Vertex  pintOldScn2;
     Vertex  pintNewScn2;
     Vertex  pLinkOldScn2;
     Vertex  pintOld2Scn2;
     Vertex sriovPfOld;
      Vertex sriovVfOld;

     Vertex lInterfaceold2;
     Vertex pintOld2;

     Vertex pLinkMoveScn2;
     Vertex pLinkMoveScn1;
     
     Vertex pint1ROOld;
     Vertex pint2ROOld;
     Vertex pint2RONew;
     Vertex pint3ROOld;
     Vertex pint3RONew;
     Vertex pint1ROOldPlink;
     
   //ManyToOne edge scenario
     Vertex pserverRCTScn6;
     Vertex pserverRCT1Scn6;
     Vertex zoneScn61;
     Vertex zoneScn62;

    @Before
    public void setUp() throws Exception {
        graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
        tx = graph.newTransaction();
        g = tx.traversal();
        loader = loaderFactory.createLoaderForVersion(introspectorFactoryType,schemaVersions.getDefaultVersion());
        dbEngine = new JanusGraphDBEngine(
                queryStyle,
                loader);
//rct
        Vertex pserverOld = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverOld")
                .property("source-of-truth","RCT")
                .property("fqdn","tttt.bbbb.cccc.dddd")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld")
                .property("resource-version","1")
                .next();
        Vertex pserverNew = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverNew")
                .property("source-of-truth","RCT")
                .property("fqdn","tttt.cccc.cccc.dddd")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverNew")
                .property("resource-version","2")
                .next();
        pintOld = g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintOld")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld/p-interfaces/p-interface/pintOld")
                .next();

        lInterfaceold = g.addV().property("aai-node-type", "l-interface")
                .property("interface-name", "linterfaceold")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld/p-interfaces/p-interface/pintOld/l-interfaces/l-interface/linterfaceold")
                .next();

        pintOld2 = g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintOld2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld/p-interfaces/p-interface/pintOld2")
                .next();
        lInterfaceold2 = g.addV().property("aai-node-type", "l-interface")
                .property("interface-name", "linterfaceold2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld/p-interfaces/p-interface/pintOld2/l-interfaces/l-interface/linterfaceold2")
                .next();

        sriovPfOld = g.addV().property("aai-node-type", "sriov-pf")
                .property("pf-pci-id","sriovPfOld")
                .property("source-of-truth","RCT")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld/p-interfaces/p-interface/pintOld2/sriov-pfs/sriov-pf/sriovPfOld")
                .next();

        sriovVfOld = g.addV().property("aai-node-type", "sriov-vf")
                .property("pci-id","sriovVfOld")
                .property("source-of-truth","RCT")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOld/p-interfaces/p-interface/pintOld2/l-interfaces/l-interface/linterfaceold2/sriov-vfs/sriov-vf/sriovVfOld")
                .next();
        
        

        Vertex vserver3 = g.addV().property("aai-node-type", "vserver")
                .property("vserver-id", "vserver1")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/vserver3")
                .next();
        Vertex lInterface3 = g.addV().property("aai-node-type", "l-interface")
                .property("interface-name", "linterfaceold3")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/vserver3")
                .next();
        Vertex sriovVfOld3 = g.addV().property("aai-node-type", "sriov-vf")
                .property("pci-id","sriovVfOld3")
                .property("source-of-truth","RCT")
//                .property("aai-uri","/cloud-infrastructure/pservers/pserver/vserver3")
                .next();
        Vertex complexOld = g.addV().property("aai-node-type", "complex")
        		.property("physical-location-id", "complexOld")
        		.property("aai-uri","/cloud-infrastructure/complex/complexOld")
                .next();


//ro
        Vertex pserverRoOld = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverRo.OldOne.aaaa.bbbbb")
                .property("source-of-truth","RO")
                .property("fqdn","aaaa.bbbb.cccc.dddd")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb")
                .property("resource-version","1")
                .next();
        Vertex pserverRoNew = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverRo.NewOne.aaaa.ccccccccccc")
                .property("source-of-truth","RO")
                .property("fqdn","aaaa.cccc.cccc.dddd")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc")
                .property("resource-version","2")
                .next();
        
        Vertex pserverRo3 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverRo3")
                .property("source-of-truth","RO")
                .property("fqdn","aaaa.cccc.cccc.dddd")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo3")
                .property("resource-version","2")
                .next();
        
        Vertex pserverRo4 =  g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverRoComplexTest.aaa")
                .property("source-of-truth","RO")
                .property("fqdn","aaaa.cccc.cccc.dddd")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRoComplexTest.aaa")
                .property("resource-version","2")
                .next();
        
        Vertex pserverRo5 =  g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverRoComplexTest.aaaaa")
                .property("source-of-truth","RO")
                .property("fqdn","aaaa.cccc.cccc.eeee")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRoComplexTest.aaaaa")
                .property("resource-version","2")
                .next();
        
        pintOldRo = g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintOldRo")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pintOldRo")
                .next();
        lInterfaceoldRo = g.addV().property("aai-node-type", "l-interface")
                .property("interface-name", "linterfaceoldRo")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pintOld/l-interfaces/l-interface/linterfaceold")
                .next();
        Vertex complexOldRO = g.addV().property("aai-node-type", "complex")
        		.property("physical-location-id", "complexOldRO")
        		.property("aai-uri","/cloud-infrastructure/complexes/complex/vserver3")
                .next();

        pintOldRo1 = g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintRo1")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pintRo1")
                .next();
        
        pintNewRo1 = g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintRo1")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pintRo1")
                .next();
        
        plinkROonOldRo1 = g.addV()
        		.property("aai-node-type", "physical-link")
        		.property("link-name", "plinkROonOldRo1")
        		.next();
        
        Vertex pintNew31 = g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintRo1")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo3/p-interfaces/p-interface/pintRo1")
                .next();

        Vertex pintOld41 = g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintOld41")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRoComplexTest.aaa/p-interfaces/p-interface/pintOld41")
                .next();
        
        Vertex sriovpfOldRo1= g.addV()
                 .property("aai-node-type", "sriov-pf")
                 .property("pf-pci-id", "sriovpfOldRo1")
                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pintRo1/sriov-pfs/sriov-pf/sriovpfOldRo1")
                 .next();

        //Scenario 3 same p interface name, new interface has a seprate plink

        Vertex pserverOldScn3 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverOldScn3")
                .property("source-of-truth","RCT")
                .property("fqdn","eeee.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOldScn3")
                .property("resource-version","1")
                .next();
        Vertex pserverNewScn3= g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverNewScn3")
                .property("source-of-truth","RCT")
                .property("fqdn","eeee.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverNewScn3")
                .property("resource-version","2")
                .next();

        pintOldScn3= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintOldScn3")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOldScn3/p-interfaces/p-interface/pintOldScn3")
                .next();
        pintNewScn3= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintNewScn3")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverNewScn3/p-interfaces/p-interface/pintNewScn3")
                .next();

        pLinkOldScn3 = g.addV().property("aai-node-type", "physical-link")
                .property("link-name", "pLinkOldScn3")
                .property("service-provider-bandwidth-up-value", 0)
                .property("service-provider-bandwidth-up-units", "empty")
                .property("service-provider-bandwidth-down-value", 0)
                .property("service-provider-bandwidth-down-units", "empty")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/vserver3")
                .next();
        pLinkNewScn3 = g.addV().property("aai-node-type", "physical-link")
                .property("link-name", "pLinkNewScn3")
                .property("service-provider-bandwidth-up-value", 0)
                .property("service-provider-bandwidth-up-units", "empty")
                .property("service-provider-bandwidth-down-value", 0)
                .property("service-provider-bandwidth-down-units", "empty")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/vserver3")
                .next();





//        Scenario 2 missing plink in new pserver same pinterface name

        Vertex pserverOldScn2 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverOldScn2")
                .property("source-of-truth","RCT")
                .property("fqdn","vvvv.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOldScn2")
                .property("resource-version","1")
                .next();
        Vertex pserverNewScn2= g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverNewScn2")
                .property("source-of-truth","RCT")
                .property("fqdn","vvvv.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverNewScn2")
                .property("resource-version","2")
                .next();

        pintOldScn2= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintScn2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOldScn2/p-interfaces/p-interface/pintScn2")
                .next();
        pintOld2Scn2= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintOld2Scn2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverOldScn2/p-interfaces/p-interface/pintOld2Scn2")
                .next();

        pintNewScn2= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintScn2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverNewScn2/p-interfaces/p-interface/pintScn2")
                .next();

        pLinkOldScn2 = g.addV().property("aai-node-type", "physical-link")
                .property("link-name", "pLinkOldScn2")
                .property("service-provider-bandwidth-up-value", 0)
                .property("service-provider-bandwidth-up-units", "empty")
                .property("service-provider-bandwidth-down-value", 0)
                .property("service-provider-bandwidth-down-units", "empty")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/vserver3")
                .next();

//   Scnario 2 RCT Pinter face match moving plink and updating the name
        Vertex pserver1Scn2 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserver1Scn2")
                .property("source-of-truth","RCT")
                .property("fqdn","same.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1Scn2")
                .property("resource-version","1")
                .next();
        Vertex pserver2Scn2= g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserver2Scn2")
                .property("source-of-truth","RCT")
                .property("fqdn","same.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver2Scn2")
                .property("resource-version","2")
                .next();
        Vertex pserver3Scn2= g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserver3Scn2")
                .property("source-of-truth","RCT")
                .property("fqdn","jkkdahfkjashf.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver3Scn2")
                .property("resource-version","2")
                .next();


        Vertex pint1Scn2= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pint1Scn2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1Scn2/p-interfaces/p-interface/pint1Scn2")
                .next();
        Vertex pint2NewScn2= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pint1Scn2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver2Scn2/p-interfaces/p-interface/pint1Scn2")
                .next();
        Vertex pint3Scn2= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pint3Scn2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver3Scn2/p-interfaces/p-interface/pint3Scn2")
                .next();

         pLinkMoveScn2= g.addV().property("aai-node-type", "physical-link")
                .property("link-name", "pserver1Scn2:pint1Scn2|pserver3Scn2:pint3Scn2")
                .property("aai-uri","/cloud-infrastructure/plink/pLinkMoveScn2")
                .next();


// Scenario 1 RCT  plink name change move everything from old pserver to new pserver, new pserver has no plink
        Vertex pserver1Scn1 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserver1Scn1")
                .property("source-of-truth","RCT")
                .property("fqdn","sameScn1.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1Scn1")
                .property("resource-version","1")
                .next();
        Vertex pserver2Scn1= g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserver2Scn1")
                .property("source-of-truth","RCT")
                .property("fqdn","sameScn1.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver2Scn1")
                .property("resource-version","2")
                .next();
        Vertex pserver3Scn1= g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserver3Scn1")
                .property("source-of-truth","RCT")
                .property("fqdn","jkkdahfkjashf.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver3Scn1")
                .property("resource-version","2")
                .next();


        Vertex pint1Scn1= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pint1Scn1")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1Scn1/p-interfaces/p-interface/pint1Scn1")
                .next();

        Vertex pint3Scn1= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pint3Scn1")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver3Scn1/p-interfaces/p-interface/pint3Scn1")
                .next();


        pLinkMoveScn1= g.addV().property("aai-node-type", "physical-link")
                .property("link-name", "pserver1Scn1:pint1Scn1|pserver3Scn1:pint3Scn1")
                .property("aai-uri","/cloud-infrastructure/plink/pLinkMoveScn1")
                .next();


        //Scnario 2 RCT Pinter face match moving plink and updating the name
        edgeSerializer.addTreeEdge(g,pserver1Scn2,pint1Scn2);

        edgeSerializer.addTreeEdge(g,pserver2Scn2,pint2NewScn2);

        edgeSerializer.addTreeEdge(g,pserver3Scn2,pint3Scn2);

        edgeSerializer.addEdge(g,pint1Scn2,pLinkMoveScn2);
        edgeSerializer.addEdge(g,pint3Scn2,pLinkMoveScn2);


        // Scenario 1 RCT  plink name change move everything from old pserver to new pserver, new pserver has no plink
        edgeSerializer.addTreeEdge(g, pserver1Scn1,pint1Scn1);
        edgeSerializer.addTreeEdge(g, pserver3Scn1,pint3Scn1);

        edgeSerializer.addEdge(g,pint1Scn1,pLinkMoveScn1);
        edgeSerializer.addEdge(g,pint3Scn1,pLinkMoveScn1);


//RCT
        edgeSerializer.addTreeEdge(g, pserverOld,pintOld);
        edgeSerializer.addTreeEdge(g, pintOld,lInterfaceold);
//        rules.addTreeEdge(g, pintOld,sriovPfOld);
//        rules.addTreeEdge(g, lInterfaceold,sriovVfOld);

        edgeSerializer.addTreeEdge(g, pserverOld,pintOld2);
        edgeSerializer.addTreeEdge(g, pintOld2,lInterfaceold2);
        edgeSerializer.addTreeEdge(g, pintOld2,sriovPfOld);
        edgeSerializer.addTreeEdge(g, sriovVfOld,lInterfaceold2);

        edgeSerializer.addTreeEdge(g,vserver3,lInterface3);
        edgeSerializer.addTreeEdge(g,lInterface3,sriovVfOld3);

        edgeSerializer.addEdge(g,sriovPfOld,sriovVfOld3);
        edgeSerializer.addEdge(g,pserverOld,complexOld);



//ro
        edgeSerializer.addTreeEdge(g,pserverRoOld,pintOldRo);
        edgeSerializer.addTreeEdge(g,pintOldRo,lInterfaceoldRo);
        edgeSerializer.addEdge(g,pserverRoOld,complexOldRO);
        edgeSerializer.addTreeEdge(g,pserverRoOld,  pintOldRo1);
        edgeSerializer.addTreeEdge(g,pserverRoNew,  pintNewRo1);
        edgeSerializer.addEdge(g, pintOldRo1, plinkROonOldRo1);
        
        edgeSerializer.addTreeEdge(g, pserverRo3, pintNew31);
        edgeSerializer.addEdge(g, pintNew31, plinkROonOldRo1);
        
        edgeSerializer.addTreeEdge(g, pserverRo4, pintOld41);
        
        edgeSerializer.addTreeEdge(g, pintOldRo1, sriovpfOldRo1);
        
        
        // physical-link tests
        //1. p-int does not exist on longer hostname RO, p-int and p-link moves from shorter to longer
        pint1ROOld= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pint1ROOld")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pint1ROOld")
                .next();

        Vertex pLink1ROOld = g.addV().property("aai-node-type", "physical-link")
                .property("link-name", "pLink1ROOld")
                .property("service-provider-bandwidth-up-value", 0)
                .property("service-provider-bandwidth-up-units", "empty")
                .property("service-provider-bandwidth-down-value", 0)
                .property("service-provider-bandwidth-down-units", "empty")
                .next();
        edgeSerializer.addTreeEdge(g,pserverRoOld,pint1ROOld);
        edgeSerializer.addEdge(g,pint1ROOld,pLink1ROOld);
        
        //2. p-int matches on shorter and longer hostname ROP pservers, p-link does not exist on longer RO. p-link moves from shorter to longer hostname
        pint2ROOld= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pint2RO")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pint2RO")
                .next();

        Vertex pLink2ROOld = g.addV().property("aai-node-type", "physical-link")
                .property("link-name", "pLink2ROOld")
                .property("service-provider-bandwidth-up-value", 0)
                .property("service-provider-bandwidth-up-units", "empty")
                .property("service-provider-bandwidth-down-value", 0)
                .property("service-provider-bandwidth-down-units", "empty")
                .next();
        
        pint2RONew= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pint2RO")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pint2RO")
                .next();

        edgeSerializer.addTreeEdge(g,pserverRoOld,pint2ROOld);
        edgeSerializer.addEdge(g,pint2ROOld,pLink2ROOld);
        edgeSerializer.addTreeEdge(g,pserverRoNew,pint2RONew);
        
        //3. p-int matches on shorter and longer hostname ROP pservers, p-link exists on both, no change in plink or p-int on longer
        pint3ROOld= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pint3RO")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pint3RO")
                .next();

        Vertex pLink3ROOld = g.addV().property("aai-node-type", "physical-link")
                .property("link-name", "pLink3ROOld")
                .property("service-provider-bandwidth-up-value", 0)
                .property("service-provider-bandwidth-up-units", "empty")
                .property("service-provider-bandwidth-down-value", 0)
                .property("service-provider-bandwidth-down-units", "empty")
                .next();
        
        pint3RONew= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pint3RO")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pint3RO")
                .next();
        
        Vertex pLink3RONew = g.addV().property("aai-node-type", "physical-link")
                .property("link-name", "pLink3RONew")
                .property("service-provider-bandwidth-up-value", 0)
                .property("service-provider-bandwidth-up-units", "empty")
                .property("service-provider-bandwidth-down-value", 0)
                .property("service-provider-bandwidth-down-units", "empty")
                .next();

        edgeSerializer.addTreeEdge(g,pserverRoOld,pint3ROOld);
        edgeSerializer.addEdge(g,pint3ROOld,pLink3ROOld);
        edgeSerializer.addTreeEdge(g,pserverRoNew,pint3RONew);
        edgeSerializer.addEdge(g,pint3RONew,pLink3RONew);
        //End physical-links tests


//sc3
        edgeSerializer.addTreeEdge(g,pserverOldScn3,pintOldScn3);
        edgeSerializer.addTreeEdge(g,pserverNewScn3,pintNewScn3);
        edgeSerializer.addEdge(g,pintNewScn3,pLinkNewScn3);
        edgeSerializer.addEdge(g,pintOldScn3,pLinkOldScn3);

//sc2
        edgeSerializer.addTreeEdge(g,pserverOldScn2,pintOldScn2);
        edgeSerializer.addTreeEdge(g,pserverOldScn2,pintOld2Scn2);
        edgeSerializer.addTreeEdge(g,pserverNewScn2,pintNewScn2);
        edgeSerializer.addEdge(g,pintOldScn2,pLinkOldScn2);

//RCT fqdn not set new tests
    
        Vertex rctP1 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","rctP1")
                .property("source-of-truth","RCT")
                .property("fqdn","sameFqdnScn1.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1")
                .property("resource-version","1")
                .next();
        
        // Don't throw null pointer with fqdn not set
        Vertex rctP2 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","rctP2")
                .property("source-of-truth","RCT")
//                .property("fqdn","sameScn1.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP2")
                .property("resource-version","2")
                .next();
        
        Vertex rctP3 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","rctP3")
                .property("source-of-truth","RCT")
                .property("fqdn","sameFqdnScn1.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3")
                .property("resource-version","3")
                .next();

        Vertex rctP4 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","rctP4")
                .property("source-of-truth","RCT")
                .property("fqdn","")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP4")
                .property("resource-version","4")
                .next();
        
        Vertex rctP5 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","rctP5")
                .property("source-of-truth","RCT")
                .property("fqdn","")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP5")
                .property("resource-version","5")
                .next();
        
        //pint11 does not have a match on rctP3. So, expect this to move to rctP3. Add test
        Vertex pint11= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pint11")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/p-interfaces/p-interface/pint11")
                .next();
        
        // matching interface-name on pint12 and pint31. Delete pint12. Don't move it to rctP3. Add test
	        //interface-name matches b/w vertices pint12 and pint31
	        Vertex pint12= g.addV()
	                .property("aai-node-type", "p-interface")
	                .property("interface-name", "pint12")
	                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/p-interfaces/p-interface/pint12")
	                .next();
	        
	        //int-name on pint31 is same as pint12
	        Vertex pint31= g.addV()
	                .property("aai-node-type", "p-interface")
	                .property("interface-name", "pint12")
	                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3/p-interfaces/p-interface/pint12")
	                .next();
        //End matching interface-name on pint12 and pint31. Delete pint12. Don't move it to rctP3.
        
        
        // Plink exists on both matching pints. Delete old pint, old plink, and edge b/w them - add test
	        // Vertex pint23 has physical link connected to pint14
		    Vertex pint14= g.addV()
		                .property("aai-node-type", "p-interface")
		                .property("interface-name", "pint14")
		                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/p-interfaces/p-interface/pint14")
		                .next();
	        Vertex pint23= g.addV()
	                .property("aai-node-type", "p-interface")
	                .property("interface-name", "pint3RCTFqdn2")
	                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP2/p-interfaces/p-interface/pint23")
	                .next();
	        Vertex plink1423 = g.addV()
	                .property("aai-node-type", "physical-link")
	                .property("link-name", "rctP1:pint14|rctP2:pint23")
	                .property("aai-uri","/network/physical-links/physical-link/plink1423")
	                .next();
	        
	        // Vertex pint24 has physical link connected to pint33 (Plink exists on both old and new p-int, no change)
	        // Vertex pint33 has same interface-name as pint14
	        Vertex pint33= g.addV()
	                .property("aai-node-type", "p-interface")
	                .property("interface-name", "pint14")
	                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pint33/p-interfaces/p-interface/pint14")
	                .next();        
	        Vertex pint24= g.addV()
	                .property("aai-node-type", "p-interface")
	                .property("interface-name", "pint24")
	                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP2/p-interfaces/p-interface/pint24")
	                .next();
	        Vertex plink2433 = g.addV()
	                .property("aai-node-type", "physical-link")
	                .property("link-name", "rctP2:pint24|rctP3:pint14")
	                .property("aai-uri","/network/physical-links/physical-link/plinkFqdn2443")
	                .next();
	     // End Plink exists on both matching pints. Delete old pint, old plink, and edge b/w them - add test
        
        Vertex pint41= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pserver1RCTFqdn4")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1RCTFqdn4/p-interfaces/p-interface/pserver1RCTFqdn4")
                .next();
        
        Vertex pint51= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pserver1RCTFqdn5")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1RCTFqdn4/p-interfaces/p-interface/pserver1RCTFqdn5")
                .next();
        
      //Case physical link moves from pint13 on rctP1 to pint32 on rctP3 since latest pserver does not have plink - Add test
	      //Vertex pint13 has plink connected to pint21
	        Vertex pint21= g.addV()
	                .property("aai-node-type", "p-interface")
	                .property("interface-name", "pint21")
	                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP2/p-interfaces/p-interface/pint21")
	                .next();
	        Vertex pint13= g.addV()
	                .property("aai-node-type", "p-interface")
	                .property("interface-name", "pint13")
	                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/p-interfaces/p-interface/pint13")
	                .next();
	        Vertex plink1321 = g.addV()
	                .property("aai-node-type", "physical-link")
	                .property("link-name", "rctP1:pint13|rctP2:pint21")
	                .property("aai-uri","/network/physical-links/physical-link/plink1321")
	                .next();
	        
	      //int-name on pint32 is same pint13
	        Vertex pint32= g.addV()
	                .property("aai-node-type", "p-interface")
	                .property("interface-name", "pint13")
	                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3/p-interfaces/p-interface/pint13")
	                .next();
	        
	        edgeSerializer.addTreeEdge(g,rctP1,pint13);
	        edgeSerializer.addTreeEdge(g,rctP2,pint21);
	        edgeSerializer.addTreeEdge(g, rctP3, pint32);
	        edgeSerializer.addEdge(g, plink1321, pint13);
	        edgeSerializer.addEdge(g, plink1321, pint21);
	        
	    // End Case physical link moves from pint13 on rctP1 to pint32 on rctP3 since latest pserver does not have plink
        
        
        edgeSerializer.addTreeEdge(g,rctP1,pint11);
        edgeSerializer.addTreeEdge(g,rctP1,pint12);
        edgeSerializer.addTreeEdge(g,rctP3,pint31);
        edgeSerializer.addTreeEdge(g,rctP3,pint33);
        edgeSerializer.addTreeEdge(g,rctP4,pint41);
        edgeSerializer.addTreeEdge(g,rctP5,pint51);
        
        edgeSerializer.addTreeEdge(g, rctP2, pint23);
        edgeSerializer.addTreeEdge(g, rctP1, pint14);
        edgeSerializer.addTreeEdge(g, rctP2, pint24);
        
        
        edgeSerializer.addEdge(g, plink1423, pint14);
        edgeSerializer.addEdge(g, plink1423, pint23);
        
        edgeSerializer.addEdge(g, plink2433, pint24);
        edgeSerializer.addEdge(g, plink2433, pint33);

 //lag-interfaces
      //lagint11 does not have a match on rctP3. So, expect this to move to rctP3. Add test
        Vertex lagint11= g.addV()
                .property("aai-node-type", "lag-interface")
                .property("interface-name", "lagint11")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/lag-interfaces/lag-interface/lagint11")
                .next();
        edgeSerializer.addTreeEdge(g, rctP1, lagint11);
        
        //lagint12 matches with lagint31 on rctP3
        Vertex lagint12= g.addV()
                .property("aai-node-type", "lag-interface")
                .property("interface-name", "lagint12")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/lag-interfaces/lag-interface/lagint12")
                .next();
        Vertex lagint31= g.addV()
                .property("aai-node-type", "lag-interface")
                .property("interface-name", "lagint12")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3/lag-interfaces/lag-interface/lagint12")
                .next();
        edgeSerializer.addTreeEdge(g, rctP1, lagint12);
        edgeSerializer.addTreeEdge(g, rctP3, lagint31);
        
      //Verify manytoOne edge scenario
        pserverRCTScn6 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverRCTScn6")
                .property("source-of-truth","RCT")
                .property("fqdn","Scn6.pserverRCTScn6")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn6")
                .property("resource-version","1")
                .next();
        
        zoneScn61 = g.addV().property("aai-node-type", "zone")
        		.property("zone-id", "zone-61")
        		.next();
        
        pserverRCT1Scn6 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","Scn6.pserverRCT1Scn6")
                .property("source-of-truth","RCT")
                .property("fqdn","Scn6.pserverRCT1Scn6")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCT1Scn6")
                .property("resource-version","4")
                .next();
        
        zoneScn62 = g.addV().property("aai-node-type", "zone")
        		.property("zone-id", "zone-62")
        		.next();
        
        edgeSerializer.addEdge(g,  pserverRCTScn6, zoneScn61);
        edgeSerializer.addEdge(g,  pserverRCT1Scn6, zoneScn62);
        
        //Verify manyToMany edge scenario
        Vertex gvnf1 = g.addV().property("aai-node-type", "generic-vnf")
        		.property("vnf-id", "vnf-1")
        		.next();
        
        Vertex gvnf2 = g.addV().property("aai-node-type", "generic-vnf")
        		.property("vnf-id", "vnf-2")
        		.next();
        
        edgeSerializer.addEdge(g,  pserverRCTScn6, gvnf1);
        edgeSerializer.addEdge(g,  pserverRCT1Scn6, gvnf2);
        
        
        // Empty string first token test
        Vertex pserver1EmptyFirstToken = g.addV().property("aai-node-type", "pserver")
                .property("hostname",".pserver1EmptyFirstToken")
                .property("source-of-truth","RO")
                .property("fqdn","sameScn1.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/.pserver1EmptyFirstToken")
                .property("resource-version","1")
                .next();
        Vertex pserver2EmptyFirstToken= g.addV().property("aai-node-type", "pserver")
                .property("hostname",".pserver2EmptyFirstToken.1")
                .property("source-of-truth","RO")
                .property("fqdn","sameScn1.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/.pserver2EmptyFirstToken")
                .property("resource-version","2")
                .next();
        
        Vertex pserver1EmptyFirstTokenFqdn = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserver1EmptyFirstTokenFqdn")
                .property("source-of-truth","RCT")
                .property("fqdn",".rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1EmptyFirstTokenFqdn")
                .property("resource-version","1")
                .next();
        Vertex pserver2EmptyFirstTokenFqdn= g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserver2EmptyFirstTokenFqdn")
                .property("source-of-truth","RCT")
                .property("fqdn",".rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver2EmptyFirstTokenFqdn")
                .property("resource-version","2")
                .next();
        
        TransactionalGraphEngine spy = spy(dbEngine);
        TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());

        GraphTraversalSource traversal = g;
        GraphTraversalSource readOnly = tx.traversal(GraphTraversalSource.build().with(ReadOnlyStrategy.instance()));
        when (spy.tx()).thenReturn(tx);
        when(spy.asAdmin()).thenReturn(adminSpy);
        when(adminSpy.getTraversalSource()).thenReturn(traversal);
        when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);

        migration = new MigrateSameSourcedRCTROPserverData(spy,loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
        migration.run();
    }

    @After
    public void cleanUp() {
        tx.tx().rollback();
        graph.close();
    }

    @Test
    public void RCT() throws Exception {
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverNew").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").hasNext());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverNew/p-interfaces/p-interface/pintOld", pintOld.property("aai-uri").value().toString());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverNew/p-interfaces/p-interface/pintOld/l-interfaces/l-interface/linterfaceold", lInterfaceold.property("aai-uri").value().toString());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverNew/p-interfaces/p-interface/pintOld2/l-interfaces/l-interface/linterfaceold2", lInterfaceold2.property("aai-uri").value().toString());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverNew/p-interfaces/p-interface/pintOld2/sriov-pfs/sriov-pf/sriovPfOld",sriovPfOld.property("aai-uri").value().toString());
        assertEquals(true, g.V().has("aai-node-type", "sriov-pf").has("pf-pci-id","sriovPfOld").in("org.onap.relationships.inventory.Uses").has("aai-node-type","sriov-vf").hasNext());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverNew/p-interfaces/p-interface/pintOld2/l-interfaces/l-interface/linterfaceold2/sriov-vfs/sriov-vf/sriovVfOld",sriovVfOld.property("aai-uri").value().toString());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverNew").out("org.onap.relationships.inventory.LocatedIn").has("aai-node-type","complex").hasNext());

    }
    @Test
    public void RO() throws Exception {
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").has("interface-name","pintOldRo").hasNext());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pintOldRo", pintOldRo.property("aai-uri").value().toString());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pintOldRo/l-interfaces/l-interface/linterfaceoldRo", lInterfaceoldRo.property("aai-uri").value().toString());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").out("org.onap.relationships.inventory.LocatedIn").has("aai-node-type","complex").hasNext());
//        System.out.println("************** SRIOV-PF *************"+g.V().has("aai-node-type","pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo")
//        		.has("aai-node-type","p-interface").has("interface-name","pintRo1").in().has("aai-node-type", "sriov-pf").toList().get(0).property("pf-pci-id").value().toString());
        assertEquals(true, g.V().has("aai-node-type","pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").has("interface-name","pintRo1").in().has("aai-node-type", "sriov-pf").hasNext());
        //.has("pf-pci-id","sriovpfOldRo1")
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pintRo1/sriov-pfs/sriov-pf/sriovpfOldRo1",
        		g.V().has("aai-node-type","sriov-pf").has("pf-pci-id","sriovpfOldRo1").toList().get(0).property("aai-uri").value().toString());
        assertNotEquals("/cloud-infrastructure/pservers/pserver/pserverRo.OldOne.aaaa.bbbbb/p-interfaces/p-interface/pintRo1/sriov-pfs/sriov-pf/sriovpfOldRo1",
        		g.V().has("aai-node-type","sriov-pf").has("pf-pci-id","sriovpfOldRo1").toList().get(0).property("aai-uri").value().toString());
    }

    @Test
    public void RCTplinkScenario3() throws Exception {
        assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","pserverNewplink").in("tosca.relationships.network.BindsTo")
                .has("aai-node-type","p-interface").out("tosca.relationships.network.LinksTo").has("aai-node-type","physical-link").has("link-name","pLinkOld").hasNext());

    }

    @Test
    public void RCTpLinkMoveScn2NameChange() throws Exception {
        assertEquals("pserver2Scn2:pint1Scn2|pserver3Scn2:pint3Scn2", pLinkMoveScn2.property("link-name").value().toString());

    }

    @Test
    public void RCTpLinkMoveScn1NameChange() throws Exception {
        assertEquals("pserver2Scn1:pint1Scn1|pserver3Scn1:pint3Scn1", pLinkMoveScn1.property("link-name").value().toString());

    }

    @Test
    public void RCTplinkScenario2() throws Exception {
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverNewScn2").in("tosca.relationships.network.BindsTo")
                .has("aai-node-type","p-interface").out("tosca.relationships.network.LinksTo").has("aai-node-type","physical-link").has("link-name","pLinkOldScn2").hasNext());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverNewScn2/p-interfaces/p-interface/pintOld2Scn2", pintOld2Scn2.property("aai-uri").value().toString());

    }
    
    @Test
    public void roSuccessfulMovePlinkScn1() throws Exception {
        assertEquals("aaaa.cccc.cccc.dddd",g.V().has("aai-node-type","pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").next().value("fqdn").toString());
        assertEquals(false, g.V().has("aai-node-type", "pserver").has("pserverRo.OldOne.aaaa.bbbbb").hasNext());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").has("interface-name","pint1ROOld").hasNext());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pint1ROOld", pint1ROOld.property("aai-uri").value().toString());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").has("interface-name","pint1ROOld").out("tosca.relationships.network.LinksTo").has("link-name","pLink1ROOld").hasNext());
    }
    
    @Test
    public void roSuccessfulSamePIntScn() throws Exception {
        assertEquals("aaaa.cccc.cccc.dddd",g.V().has("aai-node-type","pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").next().value("fqdn").toString());
        assertEquals(false, g.V().has("aai-node-type", "pserver").has("pserverRo.OldOne.aaaa.bbbbb").hasNext());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").has("interface-name","pint2RO").hasNext());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pint2RO", pint2RONew.property("aai-uri").value().toString());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").has("interface-name","pint2RO").out("tosca.relationships.network.LinksTo").has("link-name","pLink2ROOld").hasNext());
    }
    
    @Test
    public void roSuccessfulSamePIntScnPlinkExistsOnBoth() throws Exception {
        assertEquals("aaaa.cccc.cccc.dddd",g.V().has("aai-node-type","pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").next().value("fqdn").toString());
        assertEquals(false, g.V().has("aai-node-type", "pserver").has("pserverRo.OldOne.aaaa.bbbbb").hasNext());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").has("interface-name","pint3RO").hasNext());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverRo.NewOne.aaaa.ccccccccccc/p-interfaces/p-interface/pint3RO", pint3RONew.property("aai-uri").value().toString());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").has("interface-name","pint3RO").out("tosca.relationships.network.LinksTo").has("link-name","pLink3RONew").hasNext());
    }

    @Test
    public void RCThandleNullFqdnSamePints() throws Exception {
    	//1. pint11 from rctP1 moves to rctP3
    	assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","rctP3").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").has("interface-name","pint11").hasNext());
    	assertEquals(false, g.V().has("aai-node-type", "p-interface").has("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/p-interfaces/p-interface/pint11").hasNext());
    	assertEquals(true, g.V().has("aai-node-type", "p-interface").has("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3/p-interfaces/p-interface/pint11").hasNext());
    	
    	//2. pint12 int-name matches with pint31. So, verify that p-int does not move from rctP1 to rctP3
    	assertEquals("rctP3 has only 1 pint with name pint12", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","rctP3").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").has("interface-name","pint12").count().next());
    	
    	//3. Verify that the p-interface from pserver is not moved to another pserver that has null fqdn
    	assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","rctP2").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").has("interface-name","pint11").hasNext());
        		
    	//4. If the fqdn is "" within 2 RCT pservers, ignore that case. Don't move the p-int from old resource-version to new resource-version pserver
    	assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","rctP5").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").has("interface-name","pint41").hasNext());
    	assertEquals("rctP5 has only 1 p-interface", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","rctP5").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").count().next());		
       
    	//5. plink is moved from pint3 on pserver fqdn1 to pint2 on pserver fqdn3. Both p-ints have the same interface-name
    	assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","rctP3").in("tosca.relationships.network.BindsTo")
    			.has("aai-node-type","p-interface").has("interface-name","pint13").out().has("aai-node-type", "physical-link").hasNext());
    	System.out.println("plink on pint13 is "+  g.V().has("aai-node-type", "pserver").has("hostname","rctP3").in("tosca.relationships.network.BindsTo")
		.has("aai-node-type","p-interface").has("interface-name","pint13").out().has("aai-node-type", "physical-link").next().property("link-name").value().toString());
    	
    	assertEquals(true, g.V().has("aai-node-type","physical-link").has("link-name","rctP2:pint21|rctP3:pint13").hasNext());
    	
    	//6. plink is not moved from pint4 on pserver fqdn1 to pint3 on pserver fqdn3. Both p-ints have the same interface-name
    	assertEquals(true, g.V().has("aai-node-type","physical-link").has("link-name","rctP2:pint24|rctP3:pint14").hasNext());
    	assertEquals(false, g.V().has("aai-node-type","physical-link").has("link-name","rctP1:pint14|rctP2:pint23").hasNext());
    	
    }
    
    @Test
    public void testRCTLagInterfaces() throws Exception {
    	//1. lagint11 from rctP1 moves to rctP3
    	assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","rctP3").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","lag-interface").has("interface-name","lagint11").hasNext());
    	assertEquals(false, g.V().has("aai-node-type", "lag-interface").has("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/lag-interfaces/lag-interface/lagint11").hasNext());
    	assertEquals(true, g.V().has("aai-node-type", "lag-interface").has("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3/lag-interfaces/lag-interface/lagint11").hasNext());

    	
    	//2. lagint12 int-name matches with lagint31. So, verify that lag-int does not move from rctP1 to rctP3
    	assertEquals("rctP3 has only 1 lag-interface with name lagint12", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","rctP3").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","lag-interface").has("interface-name","lagint12").count().next());
    	
    }
    
    @Test
    public void checkRCTPserverHasRelnToOnly1Zone() throws Exception {

               assertEquals("Edge to only 1 Zone exists", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","Scn6.pserverRCT1Scn6").out("org.onap.relationships.inventory.LocatedIn")
                .has("aai-node-type","zone").count().next());
               assertEquals(true, g.V().has("aai-node-type", "zone").has("zone-id","zone-62").hasNext());
               //Verify no edge exists from zone61 to lower resource-version RCT pserver
               assertEquals(false, g.V().has("aai-node-type", "zone").has("zone-id","zone-61").in().has("aai-node-type", "pserver").hasNext());
    }
    
    @Test
    public void checkRCTPserverHasRelnTo2GenericVnfs() throws Exception {

               assertEquals("Edge to 2 generic-vnfs exists", new Long(2L), g.V().has("aai-node-type", "pserver").has("hostname","Scn6.pserverRCT1Scn6").in("tosca.relationships.HostedOn")
                .has("aai-node-type","generic-vnf").count().next());
               assertEquals(true, g.V().has("aai-node-type", "generic-vnf").has("vnf-id","vnf-1").out().has("aai-node-type", "pserver").has("hostname", "Scn6.pserverRCT1Scn6").hasNext());
               //Verify no edge exists from vnf-1 to lower resource-version pserver
               assertEquals(false, g.V().has("aai-node-type", "generic-vnf").has("vnf-id","vnf-1").out().has("aai-node-type", "pserver").has("hostname", "Scn6.pserverRCTScn6").hasNext());
    }
    
    @Test
    public void roPlinkNewMovesToLongerHostNameROPserver() throws Exception {

    	assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").has("interface-name","pintOldRo1").hasNext());
    	assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.OldOne.aaaa.bbbbb").hasNext());
    	assertEquals(false, g.V().has("id", "pintOldRo1").hasNext());
    	//Verify that the physical link moves to the new pserver
    	assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRo.NewOne.aaaa.ccccccccccc").in("tosca.relationships.network.BindsTo")
    			.has("aai-node-type","p-interface").has("interface-name","pintRo1").out().has("link-name","plinkROonOldRo1").hasNext());
    	//Verify complex does not get attached to pserverRO5
    	assertEquals("Complex is related to only 1 pserver", new Long(1L), g.V().has("physical-location-id", "complexOldRO").in("org.onap.relationships.inventory.LocatedIn").count().next());
    }
    
    @Test
    public void ignoreEmptyStringFirstTokenFqdn() throws Exception {
    	List<Vertex> pserverList = g.V().has("aai-node-type", "pserver").has("hostname").toList();
    	pserverList.forEach(v ->System.out.println(v.property("hostname").value().toString()));
    	assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserver1EmptyFirstTokenFqdn").hasNext());
    	assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname",".pserver1EmptyFirstToken").hasNext());
    	
    	
    	System.out.println(UUID.randomUUID().toString());
    	System.out.println(UUID.randomUUID().toString());
    	
    }
    
}