Update the license for 2017-2018 license
[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-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.serialization.queryformats;
21
22 import org.apache.tinkerpop.gremlin.structure.Graph;
23 import org.apache.tinkerpop.gremlin.structure.Vertex;
24 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
25 import org.junit.*;
26 import static org.junit.Assert.assertEquals;
27
28 import com.google.gson.JsonArray;
29 import com.google.gson.JsonObject;
30
31 public class GraphSONTest {
32
33         private Graph graph;
34         private Vertex v1;
35         
36         //private JsonObject jsonObj = new JsonParser().parse("{\"id\":0,\"label\":\"vertex\",\"properties\":{\"name\":[{\"id\":1,\"value\":\"Sam\"}]}}").getAsJsonObject();    
37         private JsonObject jsonObj = new JsonObject() ;
38         private JsonObject properties = new JsonObject();
39         private JsonArray name = new JsonArray() ;
40         private JsonObject idVal = new JsonObject() ;
41         
42         @Before
43         public void setUp() {
44                 
45                 jsonObj.addProperty("id", 0);
46                 jsonObj.addProperty("label", "vertex");
47                                 
48                 idVal.addProperty("id", 1);
49                 idVal.addProperty("value", "Sam");
50                                 
51                 name.add(idVal);
52                 properties.add("name",name);
53                 jsonObj.add("properties", properties);
54                                 
55                 graph = TinkerGraph.open();
56                 v1 = graph.addVertex("name", "Sam");
57                         
58         }
59         
60         @Test
61         public void classGraphSONTestWithVertex(){
62                 
63                 GraphSON graphSonObj1 = new GraphSON();
64                 JsonObject obj = graphSonObj1.formatObject(v1);
65                                 
66                 assertEquals(jsonObj, obj);
67         }
68
69         @Test
70         public void parallelThresholdCehck(){
71                 
72                 GraphSON graphSonObj2 = new GraphSON();
73                 assertEquals(50, graphSonObj2.parallelThreshold());
74         
75         }
76
77
78 }