Update aai-common to 1.14.0 in graphadmin
[aai/graphadmin.git] / src / test / java / org / onap / aai / migration / v14 / PserverDedupWithDifferentSourcesOfTruthTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.aai.migration.v14;
21
22 import static org.junit.Assert.*;
23 import static org.mockito.Mockito.spy;
24 import static org.mockito.Mockito.when;
25
26 import java.util.List;
27
28 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
29 import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
30 import org.apache.tinkerpop.gremlin.structure.Vertex;
31 import org.junit.*;
32 import org.onap.aai.AAISetup;
33 import org.onap.aai.dbmap.DBConnectionType;
34 import org.onap.aai.introspection.Loader;
35 import org.onap.aai.introspection.ModelType;
36 import org.onap.aai.serialization.engines.QueryStyle;
37 import org.onap.aai.serialization.engines.JanusGraphDBEngine;
38 import org.onap.aai.serialization.engines.TransactionalGraphEngine;
39 import org.janusgraph.core.JanusGraphFactory;
40 import org.janusgraph.core.JanusGraph;
41 import org.janusgraph.core.JanusGraphTransaction;
42
43 public class  PserverDedupWithDifferentSourcesOfTruthTest extends AAISetup{
44
45     private final static ModelType introspectorFactoryType = ModelType.MOXY;
46     private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
47
48     Loader loader;
49     TransactionalGraphEngine dbEngine;
50     JanusGraph graph;
51     PserverDedupWithDifferentSourcesOfTruth migration;
52     JanusGraphTransaction tx;
53     GraphTraversalSource g;
54
55 //scn1
56     Vertex pIntRo;
57     Vertex lInterfaceRo;
58     Vertex pserverRCT;
59     Vertex complexRO;
60 //scn2
61
62     Vertex pserverRCTScn2;
63     Vertex pIntRoScn2;
64     Vertex lInterfaceRoScn2;
65     Vertex complexROScn2;
66     Vertex lInterfaceRctScn2;
67     Vertex pIntRctScn2;
68     Vertex complexRctScn2;
69     
70     //physical link
71     Vertex pintPlinkScn1;
72     Vertex samePintScn4RO;
73     Vertex samePintScn4RCT;
74     Vertex pserverRCTPlinkScn4;
75     
76     //Scn3
77     Vertex pserverRCTScn3;
78     Vertex complexScn3;
79     Vertex pserverROScn3;
80     
81     //ManyToOne edge scenario
82     Vertex pserverRCTScn6;
83     Vertex pserverROScn6;
84     Vertex zoneScn61;
85     Vertex zoneScn62;
86
87     @Before
88     public void setUp() throws Exception {
89         graph = JanusGraphFactory.build().set("storage.backend","inmemory").open();
90         tx = graph.newTransaction();
91         g = tx.traversal();
92         loader = loaderFactory.createLoaderForVersion(introspectorFactoryType,schemaVersions.getDefaultVersion());
93         dbEngine = new JanusGraphDBEngine(
94                 queryStyle,
95                 loader);
96 //Scn1 empty RCT move everything over
97         pserverRCT = g.addV().property("aai-node-type", "pserver")
98                 .property("hostname","pserverRCT")
99                 .property("source-of-truth","RCT")
100                 .property("fqdn","tttt.bbbb.cccc.dddd")
101                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCT")
102                 .property("resource-version","1")
103                 .next();
104
105         Vertex pserverRO = g.addV().property("aai-node-type", "pserver")
106                 .property("hostname","tttt.RoHostname")
107                 .property("source-of-truth","RO")
108                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/tttt.RoHostname")
109                 .property("resource-version","2")
110                 .next();
111         pIntRo = g.addV()
112                 .property("aai-node-type", "p-interface")
113                 .property("interface-name", "pIntRo")
114                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/tttt.RoHostname/p-interfaces/p-interface/pIntRo")
115                 .next();
116         lInterfaceRo = g.addV().property("aai-node-type", "l-interface")
117                 .property("interface-name", "lInterfaceRo")
118                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/tttt.RoHostname/p-interfaces/p-interface/pIntRo/l-interfaces/l-interface/lInterfaceRo")
119                 .next();
120         complexRO = g.addV().property("aai-node-type", "complex")
121                 .property("physical-location-id","complexRO")
122                 .property("aai-uri","/cloud-infrastructure/complexes/complex/complexRO")
123                 .next();
124         
125         // physical-link tests
126         //1. p-int does not exist on RCT, p-int and p-link moves from RO to RCT
127         pintPlinkScn1= g.addV()
128                 .property("aai-node-type", "p-interface")
129                 .property("interface-name", "pintPlinkScn1")
130                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/tttt.RoHostname/p-interfaces/p-interface/pintPlinkScn1")
131                 .next();
132
133         Vertex pLinkScn1 = g.addV().property("aai-node-type", "physical-link")
134                 .property("link-name", "pLinkScn1")
135                 .property("service-provider-bandwidth-up-value", 0)
136                 .property("service-provider-bandwidth-up-units", "empty")
137                 .property("service-provider-bandwidth-down-value", 0)
138                 .property("service-provider-bandwidth-down-units", "empty")
139                 .property("aai-uri","/network/physical-links/physical-link/pLinkScn1")
140                 .next();
141         edgeSerializer.addTreeEdge(g,pserverRO,pintPlinkScn1);
142         edgeSerializer.addEdge(g,pintPlinkScn1,pLinkScn1);
143         
144         //2. p-int matches on RCT, p-int and p-link don't move from RO to RCT
145         
146         Vertex pserverROSPlinkScn4 = g.addV().property("aai-node-type", "pserver")
147                 .property("hostname","Scn4.pserverROSPlinkScn4")
148                 .property("source-of-truth","RO")
149                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn4.pserverROSPlinkScn4")
150                 .property("resource-version","4")
151                 .next();
152         
153         pserverRCTPlinkScn4 = g.addV().property("aai-node-type", "pserver")
154                 .property("hostname","pserverRCTPlinkScn4")
155                 .property("source-of-truth","RCT")
156                 .property("fqdn","Scn4.pserverRCTPlinkScn4")
157                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTPlinkScn4")
158                 .property("resource-version","3")
159                 .next();
160         
161         samePintScn4RO= g.addV()
162                 .property("aai-node-type", "p-interface")
163                 .property("interface-name", "pintPlinkScn4")
164                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn4.pserverROSPlinkScn4/p-interfaces/p-interface/pintPlinkScn4")
165                 .next();
166
167         Vertex plinkScn2 = g.addV().property("aai-node-type", "physical-link")
168                 .property("link-name", "plinkScn2")
169                 .property("service-provider-bandwidth-up-value", 0)
170                 .property("service-provider-bandwidth-up-units", "empty")
171                 .property("service-provider-bandwidth-down-value", 0)
172                 .property("service-provider-bandwidth-down-units", "empty")
173                 .property("aai-uri","/network/physical-links/physical-link/pLinkScn2")
174                 .next();
175         
176         samePintScn4RCT= g.addV()
177                 .property("aai-node-type", "p-interface")
178                 .property("interface-name", "pintPlinkScn4")
179                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTPlinkScn4/p-interfaces/p-interface/pintPlinkScn4")
180                 .next();
181         
182         edgeSerializer.addTreeEdge(g,pserverROSPlinkScn4,samePintScn4RO);
183         edgeSerializer.addEdge(g,samePintScn4RO,plinkScn2);
184         edgeSerializer.addTreeEdge(g,pserverRCTPlinkScn4,samePintScn4RCT);
185         //End physical-links tests
186
187 //Scn2 RCT has children already
188
189         pserverRCTScn2 = g.addV().property("aai-node-type", "pserver")
190                 .property("hostname","pserverRCTScn2")
191                 .property("source-of-truth","RCT")
192                 .property("fqdn","Scn2.pserverRCTScn2")
193                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn2")
194                 .property("resource-version","3")
195                 .next();
196         pIntRctScn2 = g.addV()
197                 .property("aai-node-type", "p-interface")
198                 .property("interface-name", "pIntRctScn2")
199                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn2/p-interfaces/p-interface/pIntRctScn2")
200                 .next();
201         lInterfaceRctScn2 = g.addV().property("aai-node-type", "l-interface")
202                 .property("interface-name", "lInterfaceRctScn2")
203                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn2/p-interfaces/p-interface/pIntRctScn2/l-interfaces/l-interface/lInterfaceRctScn2")
204                 .next();
205         complexRctScn2 = g.addV().property("aai-node-type", "complex")
206                 .property("physical-location-id","complexRctScn2")
207                  .property("aai-uri","/cloud-infrastructure/complexes/complex/complexRctScn2")
208                 .next();
209         Vertex pserverROScn2 = g.addV().property("aai-node-type", "pserver")
210                 .property("hostname","Scn2.pserverROScn2")
211                 .property("source-of-truth","RO")
212                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn2.pserverROScn2")
213                 .property("resource-version","4")
214                 .next();
215         pIntRoScn2 = g.addV()
216                 .property("aai-node-type", "p-interface")
217                 .property("interface-name", "pIntRoScn2")
218                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn2.pserverROScn2/p-interfaces/p-interface/pIntRoScn2")
219                 .next();
220         lInterfaceRoScn2 = g.addV().property("aai-node-type", "l-interface")
221                 .property("interface-name", "lInterfaceRoScn2")
222                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn2.pserverROScn2/p-interfaces/p-interface/pIntRoScn2/l-interfaces/l-interface/lInterfaceRoScn2")
223                 .next();
224         complexROScn2 = g.addV().property("aai-node-type", "complex")
225                 .property("physical-location-id","complexROScn2")
226                  .property("aai-uri","/cloud-infrastructure/complexes/complex/complexROScn2")
227                 .next();
228
229
230         //Scn1
231         edgeSerializer.addTreeEdge(g,pserverRO,pIntRo);
232         edgeSerializer.addTreeEdge(g,pIntRo,lInterfaceRo);
233         edgeSerializer.addEdge(g,pserverRO,complexRO);
234         
235         
236
237         //Scn2
238         edgeSerializer.addTreeEdge(g,pserverRCTScn2,pIntRctScn2);
239         edgeSerializer.addTreeEdge(g,pIntRctScn2,lInterfaceRctScn2);
240         edgeSerializer.addEdge(g,pserverRCTScn2,complexRctScn2);
241         edgeSerializer.addTreeEdge(g,pserverROScn2,pIntRoScn2);
242         edgeSerializer.addTreeEdge(g,pIntRoScn2,lInterfaceRoScn2);
243         edgeSerializer.addEdge(g,pserverROScn2,complexROScn2);
244         
245         //Scn3
246         pserverRCTScn3 = g.addV().property("aai-node-type", "pserver")
247                 .property("hostname","pserverRCTScn3")
248                 .property("source-of-truth","RCT")
249                 .property("fqdn","Scn3.pserverRCTScn3")
250                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn3")
251                 .property("resource-version","3")
252                 .next();
253         
254         complexScn3 = g.addV().property("aai-node-type", "complex")
255                 .property("physical-location-id","complexScn3")
256                 .property("aai-uri","/cloud-infrastructure/complexes/complex/complexScn3")
257                 .next();
258         
259         pserverROScn3 = g.addV().property("aai-node-type", "pserver")
260                 .property("hostname","Scn3.pserverROScn3")
261                 .property("source-of-truth","RO")
262                 .property("fqdn","Scn2.pserverRCTScn2")
263                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn3.pserverROScn3")
264                 .property("resource-version","4")
265                 .next();
266         
267         edgeSerializer.addEdge(g, pserverRCTScn3, complexScn3);
268         edgeSerializer.addEdge(g, pserverROScn3, complexScn3);
269         
270         //Verify manytoOne edge scenario
271         pserverRCTScn6 = g.addV().property("aai-node-type", "pserver")
272                 .property("hostname","pserverRCTScn6")
273                 .property("source-of-truth","RCT")
274                 .property("fqdn","Scn6.pserverRCTScn6")
275                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserverRCTScn6")
276                 .property("resource-version","1")
277                 .next();
278         
279         zoneScn61 = g.addV().property("aai-node-type", "zone")
280                         .property("zone-id", "zone-61")
281                         .property("aai-uri","/network/zones/zone/zone-61")
282                         .next();
283         
284         pserverROScn6 = g.addV().property("aai-node-type", "pserver")
285                 .property("hostname","Scn6.pserverROScn6")
286                 .property("source-of-truth","RO")
287                 .property("fqdn","Scn6.pserverRCTScn6")
288                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn6.pserverROScn6")
289                 .property("resource-version","4")
290                 .next();
291         
292         zoneScn62 = g.addV().property("aai-node-type", "zone")
293                         .property("zone-id", "zone-62")
294                         .property("aai-uri","/network/zones/zone/zone-62")
295                         .next();
296         
297         edgeSerializer.addEdge(g,  pserverRCTScn6, zoneScn61);
298         edgeSerializer.addEdge(g,  pserverROScn6, zoneScn62);
299         
300         //Verify manyToMany edge scenario
301         Vertex gvnf1 = g.addV().property("aai-node-type", "generic-vnf")
302                         .property("vnf-id", "vnf-1")
303                         .property("aai-uri","/cloud-infrastructure/pservers/pserver/Scn6.pserverROScn6")
304                         .next();
305         
306         Vertex gvnf2 = g.addV().property("aai-node-type", "generic-vnf")
307                         .property("vnf-id", "vnf-2")
308                         .property("aai-uri","/network/generic-vnfs/generic-vnf/vnf-2")
309                         .next();
310         
311         edgeSerializer.addEdge(g,  pserverRCTScn6, gvnf1);
312         edgeSerializer.addEdge(g,  pserverROScn6, gvnf2);
313         
314         // Verify empty string scenario
315         Vertex pserver1EmptyFirstToken = g.addV().property("aai-node-type", "pserver")
316                 .property("hostname",".pserver1EmptyFirstToken")
317                 .property("source-of-truth","RO")
318                 .property("fqdn","sameScn1.rrrr.tttt.yyyy")
319                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/.pserver1EmptyFirstToken")
320                 .property("resource-version","1")
321                 .next();
322         
323         Vertex pserver1EmptyFirstTokenFqdn = g.addV().property("aai-node-type", "pserver")
324                 .property("hostname","pserver1EmptyFirstTokenFqdn")
325                 .property("source-of-truth","RCT")
326                 .property("fqdn",".rrrr.tttt.yyyy")
327                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver1EmptyFirstTokenFqdn")
328                 .property("resource-version","1")
329                 .next();
330
331       //lag-interfaces
332         
333         Vertex roP1 = g.addV().property("aai-node-type", "pserver")
334                 .property("hostname","pserver.ro")
335                 .property("source-of-truth","RO")
336                 .property("fqdn","pserver.rrrr.tttt.yyyy")
337                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/pserver.ro")
338                 .property("resource-version","1")
339                 .next();
340         
341         Vertex rctP1 = g.addV().property("aai-node-type", "pserver")
342                 .property("hostname","rctP1")
343                 .property("source-of-truth","RCT")
344                 .property("fqdn","pserver.rrrr.tttt.yyyy")
345                 .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1")
346                 .property("resource-version","3")
347                 .next();
348         
349         //lagint11 does not have a match on rctP1. So, expect this to move to rctP1. Add test
350           Vertex lagint11= g.addV()
351                   .property("aai-node-type", "lag-interface")
352                   .property("interface-name", "lagint11")
353                   .property("aai-uri","/cloud-infrastructure/pservers/pserver/roP1/lag-interfaces/lag-interface/lagint11")
354                   .next();
355           edgeSerializer.addTreeEdge(g, roP1, lagint11);
356           
357           //lagint12 matches with lagint31 on rctP3
358           Vertex lagint12= g.addV()
359                   .property("aai-node-type", "lag-interface")
360                   .property("interface-name", "lagint12")
361                   .property("aai-uri","/cloud-infrastructure/pservers/pserver/roP1/lag-interfaces/lag-interface/lagint12")
362                   .next();
363           Vertex lagint31= g.addV()
364                   .property("aai-node-type", "lag-interface")
365                   .property("interface-name", "lagint12")
366                   .property("aai-uri","/cloud-infrastructure/pservers/pserver/rctP3/lag-interfaces/lag-interface/lagint12")
367                   .next();
368           edgeSerializer.addTreeEdge(g, roP1, lagint12);
369           edgeSerializer.addTreeEdge(g, rctP1, lagint31);
370           
371         TransactionalGraphEngine spy = spy(dbEngine);
372         TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
373
374         GraphTraversalSource traversal = g;
375         GraphTraversalSource readOnly = graph.traversal().withStrategies(ReadOnlyStrategy.instance());
376         when (spy.tx()).thenReturn(tx);
377         when(spy.asAdmin()).thenReturn(adminSpy);
378         when(adminSpy.getTraversalSource()).thenReturn(traversal);
379         when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
380
381         migration = new PserverDedupWithDifferentSourcesOfTruth(spy,loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
382         migration.run();
383     }
384
385     @After
386     public void cleanUp() {
387         tx.tx().rollback();
388         graph.close();
389     }
390
391     @Test
392     public void rctSuccessfulMoveScn1() throws Exception {
393
394         assertEquals("tttt.RoHostname",pserverRCT.property("fqdn").value().toString());
395         assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCT").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").hasNext());
396         assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCT/p-interfaces/p-interface/pIntRo", pIntRo.property("aai-uri").value().toString());
397         assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCT/p-interfaces/p-interface/pIntRo/l-interfaces/l-interface/lInterfaceRo", lInterfaceRo.property("aai-uri").value().toString());
398         assertEquals(true,pserverRCT.property("pserver-id").isPresent());
399     }
400     
401     @Test
402     public void rctSuccessfulMovePlink() throws Exception {
403
404         assertEquals("tttt.RoHostname",pserverRCT.property("fqdn").value().toString());
405         assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCT").in("tosca.relationships.network.BindsTo")
406                         .has("aai-node-type","p-interface").has("interface-name","pintPlinkScn1").hasNext());
407         assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCT/p-interfaces/p-interface/pintPlinkScn1", pintPlinkScn1.property("aai-uri").value().toString());
408         assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCT").in("tosca.relationships.network.BindsTo")
409                         .has("aai-node-type","p-interface").has("interface-name","pintPlinkScn1").out("tosca.relationships.network.LinksTo").has("link-name","pLinkScn1").hasNext());
410     }
411     
412     @Test
413     public void rctNoChangeSamePIntScenario() throws Exception {
414
415         assertEquals("Scn4.pserverROSPlinkScn4",pserverRCTPlinkScn4.property("fqdn").value().toString());
416         assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTPlinkScn4").in("tosca.relationships.network.BindsTo")
417                         .has("aai-node-type","p-interface").has("interface-name","pintPlinkScn4").hasNext());
418         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")
419                         .has("aai-node-type","p-interface").has("interface-name","pintPlinkScn4").count().next());
420         assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCTPlinkScn4/p-interfaces/p-interface/pintPlinkScn4", samePintScn4RCT.property("aai-uri").value().toString());
421         //plink is not  moved from RO to RCT when p-int matches
422         assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCT").in("tosca.relationships.network.BindsTo")
423                         .has("aai-node-type","p-interface").has("interface-name","pintPlinkScn4").out("tosca.relationships.network.LinksTo").hasNext());
424         assertEquals(false, g.V().has("aai-node-type", "pserver").has("hostname","pserverROPlinkScn4").hasNext());
425         //Verify that no orphan nodes are present in the graph
426         assertEquals(false, g.V().has("aai-node-type","p-interface").has("interface-name","pintPlinkScn4").out("tosca.relationships.network.LinksTo").has("link-name","pLinkScn2").hasNext());
427         assertEquals(false, g.V().has("aai-node-type","physical-link").has("link-name","pLinkScn2").hasNext());
428     }
429
430     @Test
431     public void rctSuccessfulMoveScn2() throws Exception {
432
433         assertEquals("Scn2.pserverROScn2",pserverRCTScn2.property("fqdn").value().toString());
434         assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTScn2").in("tosca.relationships.network.BindsTo").has("aai-node-type","p-interface").hasNext());
435         assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCTScn2/p-interfaces/p-interface/pIntRoScn2", pIntRoScn2.property("aai-uri").value().toString());
436         assertEquals("/cloud-infrastructure/pservers/pserver/pserverRCTScn2/p-interfaces/p-interface/pIntRoScn2/l-interfaces/l-interface/lInterfaceRoScn2", lInterfaceRoScn2.property("aai-uri").value().toString());
437         assertEquals(true,pserverRCTScn2.property("pserver-id").isPresent());
438         assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTScn2").out("org.onap.relationships.inventory.LocatedIn")
439                 .has("aai-node-type","complex").has("physical-location-id","complexRctScn2").hasNext());
440     }
441     
442     @Test
443     public void checkRCTPserverHasRelnToOnly1Complex() throws Exception {
444
445                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")
446                 .has("aai-node-type","complex").count().next());
447     }
448     
449     @Test
450     public void checkRCTPserverHasRelnToOnly1Zone() throws Exception {
451
452                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")
453                 .has("aai-node-type","zone").count().next());
454                assertEquals(true, g.V().has("aai-node-type", "zone").has("zone-id","zone-62").hasNext());
455                //Verify no edge exists from zone62 to RO pserver
456                assertEquals(false, g.V().has("aai-node-type", "zone").has("zone-id","zone-62").in().has("aai-node-type", "pserver").hasNext());
457                
458     }
459     
460     @Test
461     public void checkRCTPserverHasRelnTo2GenericVnfs() throws Exception {
462
463                assertEquals("Edge to 2 generic-vnfs exists", new Long(2L), g.V().has("aai-node-type", "pserver").has("hostname","pserverRCTScn6").in("tosca.relationships.HostedOn")
464                 .has("aai-node-type","generic-vnf").count().next());
465                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());
466                //Verify no edge exists from zone62 to RO pserver
467                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());
468     }
469     
470     @Test
471     public void ignoreEmptyStringFirstTokenFqdn() throws Exception {
472 //      List<Vertex> pserverList = g.V().has("aai-node-type", "pserver").has("hostname").toList();
473 //      pserverList.forEach(v ->System.out.println(v.property("hostname").value().toString()));
474         assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","pserver1EmptyFirstTokenFqdn").hasNext());
475         assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname",".pserver1EmptyFirstToken").hasNext());
476         
477     }
478     
479     @Test
480     public void testLagInterfaces() throws Exception {
481         //1. lagint11 from roP1 moves to rctP1
482         assertEquals(true, g.V().has("aai-node-type", "pserver").has("hostname","rctP1").in("tosca.relationships.network.BindsTo")
483                         .has("aai-node-type","lag-interface").has("interface-name","lagint11").hasNext());
484         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());
485         assertEquals(true, g.V().has("aai-node-type", "lag-interface").has("aai-uri","/cloud-infrastructure/pservers/pserver/rctP1/lag-interfaces/lag-interface/lagint11").hasNext());
486
487         
488         //2. lagint12 int-name matches with lagint31. So, verify that lag-int does not move from rctP1 to rctP3
489         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")
490                         .has("aai-node-type","lag-interface").has("interface-name","lagint12").count().next());
491         
492     }
493
494 }