2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.crud.service;
23 import java.util.ArrayList;
24 import java.util.HashSet;
25 import java.util.List;
28 import org.onap.crud.dao.GraphDao;
29 import org.onap.crud.entity.Edge;
30 import org.onap.crud.entity.Vertex;
31 import org.onap.crud.exception.CrudException;
33 public class TestDao implements GraphDao {
35 private final String champVertex = "{" +
36 "\"key\": \"test-uuid\"," +
37 "\"type\": \"pserver\"," +
39 "\"fqdn\": \"myhost.onap.com\"," +
40 "\"hostname\": \"myhost\" } }";
42 private final String champEdge = "{" +
43 "\"key\": \"test-uuid\"," +
44 "\"type\": \"tosca.relationships.HostedOn\"," +
46 "\"prevent-delete\": \"NONE\" }," +
48 "\"key\": \"50bdab41-ad1c-4d00-952c-a0aa5d827811\", \"type\": \"vserver\"}," +
50 "\"key\": \"1d326bc7-b985-492b-9604-0d5d1f06f908\", \"type\": \"pserver\"}" +
54 public Vertex getVertex(String id, String version) throws CrudException {
55 return Vertex.fromJson(champVertex, "v11");
59 public Vertex getVertex(String id, String type, String version, Map<String, String> queryParams)
60 throws CrudException {
61 return Vertex.fromJson(champVertex, "v11");
65 public List<Edge> getVertexEdges(String id, Map<String, String> queryParams) throws CrudException {
66 List<Edge> list = new ArrayList<Edge>();
67 list.add(Edge.fromJson(champEdge));
72 public List<Vertex> getVertices(String type, Map<String, Object> filter, String version) throws CrudException {
73 List<Vertex> list = new ArrayList<Vertex>();
74 list.add(Vertex.fromJson(champVertex, "v11"));
79 public List<Vertex> getVertices(String type, Map<String, Object> filter, HashSet<String> properties, String version)
80 throws CrudException {
81 List<Vertex> list = new ArrayList<Vertex>();
82 list.add(Vertex.fromJson(champVertex, "v11"));
87 public Edge getEdge(String id, String type, Map<String, String> queryParams) throws CrudException {
88 return Edge.fromJson(champEdge);
92 public List<Edge> getEdges(String type, Map<String, Object> filter) throws CrudException {
93 List<Edge> list = new ArrayList<Edge>();
94 list.add(Edge.fromJson(champEdge));
99 public Vertex addVertex(String type, Map<String, Object> properties, String version) throws CrudException {
100 return Vertex.fromJson(champVertex, "v11");
104 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version)
105 throws CrudException {
106 return Vertex.fromJson(champVertex, "v11");
110 public void deleteVertex(String id, String type) throws CrudException {
115 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version)
116 throws CrudException {
117 return Edge.fromJson(champEdge);
121 public Edge updateEdge(Edge edge) throws CrudException {
122 return Edge.fromJson(champEdge);
126 public void deleteEdge(String id, String type) throws CrudException {
131 public String openTransaction() {
132 // TODO Auto-generated method stub
137 public void commitTransaction(String id) throws CrudException {
138 // TODO Auto-generated method stub
143 public void rollbackTransaction(String id) throws CrudException {
144 // TODO Auto-generated method stub
149 public boolean transactionExists(String id) throws CrudException {
150 // TODO Auto-generated method stub
155 public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId)
156 throws CrudException {
157 return Vertex.fromJson(champVertex, "v11");
161 public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version,
162 String txId) throws CrudException {
163 return Edge.fromJson(champEdge);
167 public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version, String txId)
168 throws CrudException {
169 return Vertex.fromJson(champVertex, "v11");
173 public Edge updateEdge(Edge edge, String txId) throws CrudException {
174 return Edge.fromJson(champEdge);
178 public void deleteVertex(String id, String type, String txId) throws CrudException {
179 // TODO Auto-generated method stub
184 public void deleteEdge(String id, String type, String txId) throws CrudException {
185 // TODO Auto-generated method stub
190 public Edge getEdge(String id, String type, String txId) throws CrudException {
191 return Edge.fromJson(champEdge);