2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.aai.serialization.queryformats;
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;
26 import static org.junit.Assert.assertEquals;
28 import com.google.gson.JsonArray;
29 import com.google.gson.JsonObject;
31 public class GraphSONTest {
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() ;
45 jsonObj.addProperty("id", 0);
46 jsonObj.addProperty("label", "vertex");
48 idVal.addProperty("id", 1);
49 idVal.addProperty("value", "Sam");
52 properties.add("name",name);
53 jsonObj.add("properties", properties);
55 graph = TinkerGraph.open();
56 v1 = graph.addVertex("name", "Sam");
61 public void classGraphSONTestWithVertex(){
63 GraphSON graphSonObj1 = new GraphSON();
64 JsonObject obj = graphSonObj1.formatObject(v1);
66 assertEquals(jsonObj, obj);
70 public void parallelThresholdCehck(){
72 GraphSON graphSonObj2 = new GraphSON();
73 assertEquals(50, graphSonObj2.parallelThreshold());