8f418a436310a5d0c1cb51fbec08ea04b7835df4
[aai/aai-common.git] / aai-core / src / test / java / org / onap / aai / serialization / queryformats / GraphSONTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  *
20  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  */
22 package org.onap.aai.serialization.queryformats;
23
24 import org.apache.tinkerpop.gremlin.structure.Graph;
25 import org.apache.tinkerpop.gremlin.structure.Vertex;
26 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
27 import org.junit.*;
28 import static org.junit.Assert.assertEquals;
29
30 import com.google.gson.JsonArray;
31 import com.google.gson.JsonObject;
32
33 public class GraphSONTest {
34
35         private Graph graph;
36         private Vertex v1;
37         
38         //private JsonObject jsonObj = new JsonParser().parse("{\"id\":0,\"label\":\"vertex\",\"properties\":{\"name\":[{\"id\":1,\"value\":\"Sam\"}]}}").getAsJsonObject();    
39         private JsonObject jsonObj = new JsonObject() ;
40         private JsonObject properties = new JsonObject();
41         private JsonArray name = new JsonArray() ;
42         private JsonObject idVal = new JsonObject() ;
43         
44         @Before
45         public void setUp() {
46                 
47                 jsonObj.addProperty("id", 0);
48                 jsonObj.addProperty("label", "vertex");
49                                 
50                 idVal.addProperty("id", 1);
51                 idVal.addProperty("value", "Sam");
52                                 
53                 name.add(idVal);
54                 properties.add("name",name);
55                 jsonObj.add("properties", properties);
56                                 
57                 graph = TinkerGraph.open();
58                 v1 = graph.addVertex("name", "Sam");
59                         
60         }
61         
62         @Test
63         public void classGraphSONTestWithVertex(){
64                 
65                 GraphSON graphSonObj1 = new GraphSON();
66                 JsonObject obj = graphSonObj1.formatObject(v1);
67                                 
68                 assertEquals(jsonObj, obj);
69         }
70
71         @Test
72         public void parallelThresholdCehck(){
73                 
74                 GraphSON graphSonObj2 = new GraphSON();
75                 assertEquals(50, graphSonObj2.parallelThreshold());
76         
77         }
78
79
80 }