Add tests for X-FromMsId
[aai/gizmo.git] / src / test / java / org / onap / crud / dao / TestDao.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
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
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21 package org.onap.crud.dao;
22
23 import java.util.ArrayList;
24 import java.util.HashSet;
25 import java.util.List;
26 import java.util.Map;
27
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;
32
33 public class TestDao implements GraphDao {
34   
35   private final String champVertex = "{" +
36       "\"key\": \"test-uuid\"," +
37       "\"type\": \"pserver\"," +
38       "\"properties\": {" +
39       "\"fqdn\": \"myhost.onap.com\"," +
40       "\"hostname\": \"myhost\" } }";
41   
42   private final String champEdge = "{" +
43       "\"key\": \"test-uuid\"," +
44       "\"type\": \"tosca.relationships.HostedOn\"," +
45       "\"properties\": {" +
46       "\"prevent-delete\": \"NONE\" }," +
47       "\"source\": {" +
48       "\"key\": \"50bdab41-ad1c-4d00-952c-a0aa5d827811\", \"type\": \"vserver\"}," +
49       "\"target\": {" +
50       "\"key\": \"1d326bc7-b985-492b-9604-0d5d1f06f908\", \"type\": \"pserver\"}" +
51       " }";
52
53   @Override
54   public Vertex getVertex(String id, String version) throws CrudException {
55     return Vertex.fromJson(champVertex, "v11");
56   }
57
58   @Override
59   public Vertex getVertex(String id, String type, String version, Map<String, String> queryParams)
60       throws CrudException {
61     return Vertex.fromJson(champVertex, "v11");
62   }
63
64   @Override
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));
68     return list;
69   }
70
71   @Override
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"));
75     return list;
76   }
77
78   @Override
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"));
83     return list;
84   }
85
86   @Override
87   public Edge getEdge(String id, String type, Map<String, String> queryParams) throws CrudException {
88     return Edge.fromJson(champEdge);
89   }
90
91   @Override
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));
95     return list;
96   }
97
98   @Override
99   public Vertex addVertex(String type, Map<String, Object> properties, String version) throws CrudException {
100     return Vertex.fromJson(champVertex, "v11");
101   }
102
103   @Override
104   public Vertex updateVertex(String id, String type, Map<String, Object> properties, String version)
105       throws CrudException {
106     return Vertex.fromJson(champVertex, "v11");
107   }
108
109   @Override
110   public void deleteVertex(String id, String type) throws CrudException {
111     
112   }
113
114   @Override
115   public Edge addEdge(String type, Vertex source, Vertex target, Map<String, Object> properties, String version)
116       throws CrudException {
117     return Edge.fromJson(champEdge);
118   }
119
120   @Override
121   public Edge updateEdge(Edge edge) throws CrudException {
122     return Edge.fromJson(champEdge);
123   }
124
125   @Override
126   public void deleteEdge(String id, String type) throws CrudException {
127     
128   }
129
130   @Override
131   public String openTransaction() {
132     // TODO Auto-generated method stub
133     return null;
134   }
135
136   @Override
137   public void commitTransaction(String id) throws CrudException {
138     // TODO Auto-generated method stub
139     
140   }
141
142   @Override
143   public void rollbackTransaction(String id) throws CrudException {
144     // TODO Auto-generated method stub
145     
146   }
147
148   @Override
149   public boolean transactionExists(String id) throws CrudException {
150     // TODO Auto-generated method stub
151     return false;
152   }
153
154   @Override
155   public Vertex addVertex(String type, Map<String, Object> properties, String version, String txId)
156       throws CrudException {
157     return Vertex.fromJson(champVertex, "v11");
158   }
159
160   @Override
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);
164   }
165
166   @Override
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");
170   }
171
172   @Override
173   public Edge updateEdge(Edge edge, String txId) throws CrudException {
174     return Edge.fromJson(champEdge);
175   }
176
177   @Override
178   public void deleteVertex(String id, String type, String txId) throws CrudException {
179     // TODO Auto-generated method stub
180     
181   }
182
183   @Override
184   public void deleteEdge(String id, String type, String txId) throws CrudException {
185     // TODO Auto-generated method stub
186     
187   }
188
189   @Override
190   public Edge getEdge(String id, String type, String txId) throws CrudException {
191     return Edge.fromJson(champEdge);
192   }
193
194 }