re base code
[sdc.git] / catalog-dao / src / test / java / org / openecomp / sdc / be / dao / jsongraph / TitanDaoTest.java
1 package org.openecomp.sdc.be.dao.jsongraph;
2
3 import com.thinkaurelius.titan.core.TitanGraph;
4 import fj.data.Either;
5 import org.apache.tinkerpop.gremlin.structure.Edge;
6 import org.apache.tinkerpop.gremlin.structure.Element;
7 import org.apache.tinkerpop.gremlin.structure.Property;
8 import org.apache.tinkerpop.gremlin.structure.Vertex;
9 import org.junit.After;
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.mockito.Mockito;
13 import org.openecomp.sdc.be.dao.DAOTitanStrategy;
14 import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
15 import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum;
16 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
17 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
18 import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
19 import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
20 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
21 import org.openecomp.sdc.be.utils.DAOConfDependentTest;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 import java.util.Iterator;
26 import java.util.List;
27 import java.util.Map;
28
29 public class TitanDaoTest extends DAOConfDependentTest{
30         
31         
32         private static Logger logger = LoggerFactory.getLogger(TitanDaoTest.class);
33         private TitanDao dao = new TitanDao(new TitanGraphClient(new DAOTitanStrategy()));
34         
35         @Before
36         public void init(){
37         dao.titanClient.createGraph();
38         }
39         
40         @After
41         public void end(){
42                 dao.titanClient.cleanupGraph();
43         }
44
45         @Test
46         public void testCreateVertex() throws Exception {
47                 Either<GraphVertex, TitanOperationStatus> result;
48
49                 // default test
50                 GraphVertex graphVertex = new GraphVertex(VertexTypeEnum.REQUIREMENTS);
51                 result = dao.createVertex(graphVertex);
52                 
53                 graphVertex = new GraphVertex();
54                 result = dao.createVertex(graphVertex);
55         }
56         
57         @Test
58         public void testGetVertexByLabel() throws Exception {
59                 Either<GraphVertex, TitanOperationStatus> result;
60
61                 // default test
62                 result = dao.getVertexByLabel(VertexTypeEnum.ADDITIONAL_INFORMATION);
63         }
64         
65         @Test
66         public void testCommit() throws Exception {
67                 TitanOperationStatus result;
68
69                 // default test
70                 
71                 result = dao.commit();
72         }
73
74         
75         @Test
76         public void testRollback() throws Exception {
77                 
78                 TitanOperationStatus result;
79
80                 // default test
81                 
82                 result = dao.rollback();
83         }
84
85         @Test
86         public void testGetGraph() throws Exception {
87                 
88                 Either<TitanGraph, TitanOperationStatus> result;
89
90                 // default test
91                 
92                 result = dao.getGraph();
93         }
94
95         @Test
96         public void testGetVertexByPropertyAndLabel() throws Exception {
97                 
98                 GraphPropertyEnum name = null;
99                 Object value = null;
100                 VertexTypeEnum label = null;
101                 Either<GraphVertex, TitanOperationStatus> result;
102
103                 // default test
104                 
105                 result = dao.getVertexByPropertyAndLabel(name, value, label);
106                 
107                 result = dao.getVertexByPropertyAndLabel(GraphPropertyEnum.COMPONENT_TYPE, new Object(), VertexTypeEnum.ADDITIONAL_INFORMATION);
108         }
109
110         @Test
111         public void testGetVertexByPropertyAndLabel_1() throws Exception {
112                 
113                 GraphPropertyEnum name = null;
114                 Object value = null;
115                 VertexTypeEnum label = null;
116                 JsonParseFlagEnum parseFlag = null;
117                 Either<GraphVertex, TitanOperationStatus> result;
118
119                 // default test
120                 
121                 result = dao.getVertexByPropertyAndLabel(name, value, label, parseFlag);
122         }
123
124         
125         @Test
126         public void testGetVertexById() throws Exception {
127                 
128                 String id = "";
129                 Either<GraphVertex, TitanOperationStatus> result;
130
131                 // default test
132                 
133                 result = dao.getVertexById(id);
134         }
135
136         @Test
137         public void testGetVertexById_1() throws Exception {
138                 
139                 String id = "";
140                 JsonParseFlagEnum parseFlag = null;
141                 Either<GraphVertex, TitanOperationStatus> result;
142
143                 // test 1
144                 
145                 id = null;
146                 result = dao.getVertexById(id, parseFlag);
147
148                 // test 2
149                 
150                 id = "";
151                 result = dao.getVertexById(id, parseFlag);
152         }
153
154         @Test
155         public void testGetVertexProperties() throws Exception {
156                 
157                 Element element = null;
158                 Map<GraphPropertyEnum, Object> result;
159
160                 // test 1
161                 
162                 element = null;
163                 result = dao.getVertexProperties(element);
164         }
165
166         
167         @Test
168         public void testGetEdgeProperties() throws Exception {
169                 
170                 Element element = null;
171                 Map<EdgePropertyEnum, Object> result;
172
173                 // test 1
174                 
175                 element = null;
176                 result = dao.getEdgeProperties(element);
177         }
178
179         @Test
180         public void testGetByCriteria() throws Exception {
181                 
182                 VertexTypeEnum type = null;
183                 Map<GraphPropertyEnum, Object> props = null;
184                 Either<List<GraphVertex>, TitanOperationStatus> result;
185
186                 // default test
187                 
188                 result = dao.getByCriteria(type, props);
189         }
190
191         @Test
192         public void testGetByCriteria_1() throws Exception {
193                 
194                 VertexTypeEnum type = null;
195                 Map<GraphPropertyEnum, Object> props = null;
196                 JsonParseFlagEnum parseFlag = null;
197                 Either<List<GraphVertex>, TitanOperationStatus> result;
198
199                 // default test
200                 
201                 result = dao.getByCriteria(type, props, parseFlag);
202         }
203
204         
205         @Test
206         public void testGetByCriteria_2() throws Exception {
207                 
208                 VertexTypeEnum type = null;
209                 Map<GraphPropertyEnum, Object> props = null;
210                 Map<GraphPropertyEnum, Object> hasNotProps = null;
211                 JsonParseFlagEnum parseFlag = null;
212                 Either<List<GraphVertex>, TitanOperationStatus> result;
213
214                 // default test
215                 
216                 result = dao.getByCriteria(type, props, hasNotProps, parseFlag);
217         }
218
219         @Test
220         public void testGetCatalogVerticies() throws Exception {
221                 
222                 Either<Iterator<Vertex>, TitanOperationStatus> result;
223
224                 // default test
225                 
226                 result = dao.getCatalogOrArchiveVerticies(true);
227         }
228         
229         @Test
230         public void testGetParentVertecies_1() throws Exception {
231                 
232                 Vertex parentVertex = null;
233                 EdgeLabelEnum edgeLabel = null;
234                 JsonParseFlagEnum parseFlag = null;
235                 Either<List<Vertex>, TitanOperationStatus> result;
236
237                 // default test
238                 
239                 result = dao.getParentVertecies(parentVertex, edgeLabel, parseFlag);
240         }
241
242         @Test
243         public void testGetChildrenVertecies_1() throws Exception {
244                 
245                 Vertex parentVertex = null;
246                 EdgeLabelEnum edgeLabel = null;
247                 JsonParseFlagEnum parseFlag = null;
248                 Either<List<Vertex>, TitanOperationStatus> result;
249
250                 // default test
251                 
252                 result = dao.getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
253         }
254
255         @Test
256         public void testUpdateVertexMetadataPropertiesWithJson() throws Exception {
257                 
258                 Vertex vertex = null;
259                 Map<GraphPropertyEnum, Object> properties = null;
260                 TitanOperationStatus result;
261
262                 // default test
263                 
264                 result = dao.updateVertexMetadataPropertiesWithJson(vertex, properties);
265         }
266
267         @Test
268         public void testGetProperty() throws Exception {
269                 Edge edge = Mockito.mock(Edge.class);;
270                 Object result;
271                 
272                 Property<Object> value = Mockito.mock(Property.class);
273                 Mockito.when(edge.property(Mockito.any())).thenReturn(value);
274                 
275                 // default test
276                 result = dao.getProperty(edge, EdgePropertyEnum.STATE);
277         }
278         
279         @Test
280         public void testGetProperty_1() throws Exception {
281                 Edge edge = Mockito.mock(Edge.class);;
282                 Object result;
283
284                 // default test
285                 result = dao.getProperty(edge, EdgePropertyEnum.STATE);
286         }
287
288         @Test
289         public void testGetPropertyexception() throws Exception {
290                 Edge edge = Mockito.mock(Edge.class);;
291                 Object result;
292                 
293                 Property<Object> value = Mockito.mock(Property.class);
294                 Mockito.when(edge.property(Mockito.any())).thenThrow(RuntimeException.class);
295                 
296                 // default test
297                 result = dao.getProperty(edge, EdgePropertyEnum.STATE);
298         }
299         
300         @Test
301         public void testGetBelongingEdgeByCriteria_1() throws Exception {
302                 
303                 String parentId = "";
304                 EdgeLabelEnum label = null;
305                 Map<GraphPropertyEnum, Object> properties = null;
306                 Either<Edge, TitanOperationStatus> result;
307
308                 // default test
309                 
310                 result = dao.getBelongingEdgeByCriteria(parentId, label, properties);
311         }
312 }