aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/aai/migration/v14/PserverDedupWithDifferentSourcesOfTruthTest.java
blob: a541eca49f819d17c566428b0200ab9d889b004c (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
/**
 * ============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 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.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  PserverDedupWithDifferentSourcesOfTruthTest extends AAISetup{

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

    Loader loader;
    TransactionalGraphEngine dbEngine;
    JanusGraph graph;
    PserverDedupWithDifferentSourcesOfTruth migration;
    JanusGraphTransaction tx;
    GraphTraversalSource g;

//scn1
    Vertex pIntRo;
    Vertex lInterfaceRo;
    Vertex pserverRCT;
    Vertex complexRO;
//scn2

    Vertex pserverRCTScn2;
    Vertex pIntRoScn2;
    Vertex lInterfaceRoScn2;
    Vertex complexROScn2;
    Vertex lInterfaceRctScn2;
    Vertex pIntRctScn2;
    Vertex complexRctScn2;
    
    //physical link
    Vertex pintPlinkScn1;
    Vertex samePintScn4RO;
    Vertex samePintScn4RCT;
    Vertex pserverRCTPlinkScn4;
    
    //Scn3
    Vertex pserverRCTScn3;
    Vertex complexScn3;
    Vertex pserverROScn3;
    
    //ManyToOne edge scenario
    Vertex pserverRCTScn6;
    Vertex pserverROScn6;
    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,
                type,
                loader);
//Scn1 empty RCT move everything over
        pserverRCT = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverRCT")
                .property("source-of-truth","RCT")
                .property("fqdn","tttt.bbbb.cccc.dddd")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCT")
                .property("resource-version","1")
                .next();

        Vertex pserverRO = g.addV().property("aai-node-type", "pserver")
                .property("hostname","tttt.RoHostname")
                .property("source-of-truth","RO")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/tttt.RoHostname")
                .property("resource-version","2")
                .next();
        pIntRo = g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pIntRo")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/tttt.RoHostname/p-interfaces/p-interface/pIntRo")
                .next();
        lInterfaceRo = g.addV().property("aai-node-type", "l-interface")
                .property("interface-name", "lInterfaceRo")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/tttt.RoHostname/p-interfaces/p-interface/pIntRo/l-interfaces/l-interface/lInterfaceRo")
                .next();
        complexRO = g.addV().property("aai-node-type", "complex")
                .property("physical-location-id","complexRO")
                .property("aai-uri","/cloud-infrastructure/complexes/complex/complexRO")
                .next();
        
        // physical-link tests
        //1. p-int does not exist on RCT, p-int and p-link moves from RO to RCT
        pintPlinkScn1= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintPlinkScn1")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/tttt.RoHostname/p-interfaces/p-interface/pintPlinkScn1")
                .next();

        Vertex pLinkScn1 = g.addV().property("aai-node-type", "physical-link")
                .property("link-name", "pLinkScn1")
                .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","/network/physical-links/physical-link/pLinkScn1")
                .next();
        edgeSerializer.addTreeEdge(g,pserverRO,pintPlinkScn1);
        edgeSerializer.addEdge(g,pintPlinkScn1,pLinkScn1);
        
        //2. p-int matches on RCT, p-int and p-link don't move from RO to RCT
        
        Vertex pserverROSPlinkScn4 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","Scn4.pserverROSPlinkScn4")
                .property("source-of-truth","RO")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn4.pserverROSPlinkScn4")
                .property("resource-version","4")
                .next();
        
        pserverRCTPlinkScn4 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverRCTPlinkScn4")
                .property("source-of-truth","RCT")
                .property("fqdn","Scn4.pserverRCTPlinkScn4")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTPlinkScn4")
                .property("resource-version","3")
                .next();
        
        samePintScn4RO= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintPlinkScn4")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn4.pserverROSPlinkScn4/p-interfaces/p-interface/pintPlinkScn4")
                .next();

        Vertex plinkScn2 = g.addV().property("aai-node-type", "physical-link")
                .property("link-name", "plinkScn2")
                .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","/network/physical-links/physical-link/pLinkScn2")
                .next();
        
        samePintScn4RCT= g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pintPlinkScn4")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTPlinkScn4/p-interfaces/p-interface/pintPlinkScn4")
                .next();
        
        edgeSerializer.addTreeEdge(g,pserverROSPlinkScn4,samePintScn4RO);
        edgeSerializer.addEdge(g,samePintScn4RO,plinkScn2);
        edgeSerializer.addTreeEdge(g,pserverRCTPlinkScn4,samePintScn4RCT);
        //End physical-links tests

//Scn2 RCT has children already

        pserverRCTScn2 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverRCTScn2")
                .property("source-of-truth","RCT")
                .property("fqdn","Scn2.pserverRCTScn2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn2")
                .property("resource-version","3")
                .next();
        pIntRctScn2 = g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pIntRctScn2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn2/p-interfaces/p-interface/pIntRctScn2")
                .next();
        lInterfaceRctScn2 = g.addV().property("aai-node-type", "l-interface")
                .property("interface-name", "lInterfaceRctScn2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn2/p-interfaces/p-interface/pIntRctScn2/l-interfaces/l-interface/lInterfaceRctScn2")
                .next();
        complexRctScn2 = g.addV().property("aai-node-type", "complex")
                .property("physical-location-id","complexRctScn2")
                 .property("aai-uri","/cloud-infrastructure/complexes/complex/complexRctScn2")
                .next();
        Vertex pserverROScn2 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","Scn2.pserverROScn2")
                .property("source-of-truth","RO")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn2.pserverROScn2")
                .property("resource-version","4")
                .next();
        pIntRoScn2 = g.addV()
                .property("aai-node-type", "p-interface")
                .property("interface-name", "pIntRoScn2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn2.pserverROScn2/p-interfaces/p-interface/pIntRoScn2")
                .next();
        lInterfaceRoScn2 = g.addV().property("aai-node-type", "l-interface")
                .property("interface-name", "lInterfaceRoScn2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn2.pserverROScn2/p-interfaces/p-interface/pIntRoScn2/l-interfaces/l-interface/lInterfaceRoScn2")
                .next();
        complexROScn2 = g.addV().property("aai-node-type", "complex")
                .property("physical-location-id","complexROScn2")
                 .property("aai-uri","/cloud-infrastructure/complexes/complex/complexROScn2")
                .next();


        //Scn1
        edgeSerializer.addTreeEdge(g,pserverRO,pIntRo);
        edgeSerializer.addTreeEdge(g,pIntRo,lInterfaceRo);
        edgeSerializer.addEdge(g,pserverRO,complexRO);
        
        

        //Scn2
        edgeSerializer.addTreeEdge(g,pserverRCTScn2,pIntRctScn2);
        edgeSerializer.addTreeEdge(g,pIntRctScn2,lInterfaceRctScn2);
        edgeSerializer.addEdge(g,pserverRCTScn2,complexRctScn2);
        edgeSerializer.addTreeEdge(g,pserverROScn2,pIntRoScn2);
        edgeSerializer.addTreeEdge(g,pIntRoScn2,lInterfaceRoScn2);
        edgeSerializer.addEdge(g,pserverROScn2,complexROScn2);
        
        //Scn3
        pserverRCTScn3 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserverRCTScn3")
                .property("source-of-truth","RCT")
                .property("fqdn","Scn3.pserverRCTScn3")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn3")
                .property("resource-version","3")
                .next();
        
        complexScn3 = g.addV().property("aai-node-type", "complex")
                .property("physical-location-id","complexScn3")
                .property("aai-uri","/cloud-infrastructure/complexes/complex/complexScn3")
                .next();
        
        pserverROScn3 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","Scn3.pserverROScn3")
                .property("source-of-truth","RO")
                .property("fqdn","Scn2.pserverRCTScn2")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn3.pserverROScn3")
                .property("resource-version","4")
                .next();
        
        edgeSerializer.addEdge(g, pserverRCTScn3, complexScn3);
        edgeSerializer.addEdge(g, pserverROScn3, complexScn3);
        
        //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")
        		.property("aai-uri","/network/zones/zone/zone-61")
        		.next();
        
        pserverROScn6 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","Scn6.pserverROScn6")
                .property("source-of-truth","RO")
                .property("fqdn","Scn6.pserverRCTScn6")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn6.pserverROScn6")
                .property("resource-version","4")
                .next();
        
        zoneScn62 = g.addV().property("aai-node-type", "zone")
        		.property("zone-id", "zone-62")
        		.property("aai-uri","/network/zones/zone/zone-62")
        		.next();
        
        edgeSerializer.addEdge(g,  pserverRCTScn6, zoneScn61);
        edgeSerializer.addEdge(g,  pserverROScn6, zoneScn62);
        
        //Verify manyToMany edge scenario
        Vertex gvnf1 = g.addV().property("aai-node-type", "generic-vnf")
        		.property("vnf-id", "vnf-1")
        		.property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn6.pserverROScn6")
        		.next();
        
        Vertex gvnf2 = g.addV().property("aai-node-type", "generic-vnf")
        		.property("vnf-id", "vnf-2")
        		.property("aai-uri","/network/generic-vnfs/generic-vnf/vnf-2")
        		.next();
        
        edgeSerializer.addEdge(g,  pserverRCTScn6, gvnf1);
        edgeSerializer.addEdge(g,  pserverROScn6, gvnf2);
        
        // Verify empty string scenario
        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 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();

      //lag-interfaces
        
        Vertex roP1 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","pserver.ro")
                .property("source-of-truth","RO")
                .property("fqdn","pserver.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver.ro")
                .property("resource-version","1")
                .next();
        
        Vertex rctP1 = g.addV().property("aai-node-type", "pserver")
                .property("hostname","rctP1")
                .property("source-of-truth","RCT")
                .property("fqdn","pserver.rrrr.tttt.yyyy")
                .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1")
                .property("resource-version","3")
                .next();
        
        //lagint11 does not have a match on rctP1. So, expect this to move to rctP1. Add test
          Vertex lagint11= g.addV()
                  .property("aai-node-type", "lag-interface")
                  .property("interface-name", "lagint11")
                  .property("aai-uri","/cloud-infrastructure/pservers/pserver/roP1/lag-interfaces/lag-interface/lagint11")
                  .next();
          edgeSerializer.addTreeEdge(g, roP1, 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/roP1/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, roP1, lagint12);
          edgeSerializer.addTreeEdge(g, rctP1, lagint31);
          
        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 PserverDedupWithDifferentSourcesOfTruth(spy,loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
        migration.run();
    }

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

    @Test
    public void rctSuccessfulMoveScn1() throws Exception {

        assertEquals("tttt.RoHostname",pserverRCT.property("fqdn").value().toString());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCT").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").hasNext());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCT/p-interfaces/p-interface/pIntRo", pIntRo.property("aai-uri").value().toString());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCT/p-interfaces/p-interface/pIntRo/l-interfaces/l-interface/lInterfaceRo", lInterfaceRo.property("aai-uri").value().toString());
        assertEquals(true,pserverRCT.property("pserver-id").isPresent());
    }
    
    @Test
    public void rctSuccessfulMovePlink() throws Exception {

        assertEquals("tttt.RoHostname",pserverRCT.property("fqdn").value().toString());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCT").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").has("interface-name","pintPlinkScn1").hasNext());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCT/p-interfaces/p-interface/pintPlinkScn1", pintPlinkScn1.property("aai-uri").value().toString());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCT").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").has("interface-name","pintPlinkScn1").out("tosca.relationships.network.LinksTo").has("link-name","pLinkScn1").hasNext());
    }
    
    @Test
    public void rctNoChangeSamePIntScenario() throws Exception {

        assertEquals("Scn4.pserverROSPlinkScn4",pserverRCTPlinkScn4.property("fqdn").value().toString());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTPlinkScn4").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").has("interface-name","pintPlinkScn4").hasNext());
        assertEquals("only 1 p-int is present on RCT pserver", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTPlinkScn4").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").has("interface-name","pintPlinkScn4").count().next());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCTPlinkScn4/p-interfaces/p-interface/pintPlinkScn4", samePintScn4RCT.property("aai-uri").value().toString());
        //plink is not  moved from RO to RCT when p-int matches
        assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCT").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","p-interface").has("interface-name","pintPlinkScn4").out("tosca.relationships.network.LinksTo").hasNext());
        assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","pserverROPlinkScn4").hasNext());
        //Verify that no orphan nodes are present in the graph
        assertEquals(false, g.V().has("aai-node-type","p-interface").has("interface-name","pintPlinkScn4").out("tosca.relationships.network.LinksTo").has("link-name","pLinkScn2").hasNext());
        assertEquals(false, g.V().has("aai-node-type","physical-link").has("link-name","pLinkScn2").hasNext());
    }

    @Test
    public void rctSuccessfulMoveScn2() throws Exception {

        assertEquals("Scn2.pserverROScn2",pserverRCTScn2.property("fqdn").value().toString());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTScn2").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").hasNext());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCTScn2/p-interfaces/p-interface/pIntRoScn2", pIntRoScn2.property("aai-uri").value().toString());
        assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCTScn2/p-interfaces/p-interface/pIntRoScn2/l-interfaces/l-interface/lInterfaceRoScn2", lInterfaceRoScn2.property("aai-uri").value().toString());
        assertEquals(true,pserverRCTScn2.property("pserver-id").isPresent());
        assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTScn2").out("org.onap.relationships.inventory.LocatedIn")
                .has("aai-node-type","complex").has("physical-location-id","complexRctScn2").hasNext());
    }
    
    @Test
    public void checkRCTPserverHasRelnToOnly1Complex() throws Exception {

               assertEquals("Edge to only 1 complex exists", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTScn3").out("org.onap.relationships.inventory.LocatedIn")
                .has("aai-node-type","complex").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","pserverRCTScn6").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 zone62 to RO pserver
               assertEquals(false, g.V().has("aai-node-type", "zone").has("zone-id","zone-62").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","pserverRCTScn6").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-2").out().has("aai-node-type", "pserver").has("hostname", "pserverRCTScn6").hasNext());
               //Verify no edge exists from zone62 to RO pserver
               assertEquals(false, g.V().has("aai-node-type", "generic-vnf").has("vnf-id","vnf-2").out().has("aai-node-type", "pserver").has("hostname", "pserverROScn6").hasNext());
    }
    
    @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());
    	
    }
    
    @Test
    public void testLagInterfaces() throws Exception {
    	//1. lagint11 from roP1 moves to rctP1
    	assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","rctP1").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/pserver.ro/lag-interfaces/lag-interface/lagint11").hasNext());
    	assertEquals(true, g.V().has("aai-node-type", "lag-interface").has("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/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("rctP1 has only 1 lag-interface with name lagint12", new Long(1L), g.V().has("aai-node-type", "pserver").has("hostname","rctP1").in("tosca.relationships.network.BindsTo")
        		.has("aai-node-type","lag-interface").has("interface-name","lagint12").count().next());
    	
    }

}