Unit tests
[vid.git] / vid-app-common / src / test / java / org / onap / vid / asdc / InMemoryClientTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID ASDC Client
4  * ================================================================================
5  * Copyright (C) 2017 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
21 package org.onap.vid.asdc;
22
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.net.URISyntaxException;
26
27 import org.codehaus.jackson.map.ObjectMapper;
28 import org.json.JSONObject;
29 import org.json.JSONTokener;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.onap.vid.asdc.memory.InMemoryAsdcClient;
33
34 /**
35  * The Class InMemoryClientTest.
36  */
37 public class InMemoryClientTest extends BaseClientTest {
38
39         /** The catalog. */
40         private JSONObject catalog;
41
42         /**
43          * Sets the up.
44          *
45          * @throws URISyntaxException the URI syntax exception
46          * @throws IOException Signals that an I/O exception has occurred.
47          */
48         @Before
49         public void setUp() throws URISyntaxException, IOException {
50                 final InputStream asdcCatalogFile = getClass().getClassLoader().getResourceAsStream("catalog.json");
51                 
52                 final JSONTokener tokener = new JSONTokener(asdcCatalogFile);
53                 
54                 catalog = new JSONObject(tokener);
55         }
56         
57         /**
58          * Test resources.
59          *
60          * @throws AsdcCatalogException the asdc catalog exception
61          */
62         @Test
63         public void testResources() throws AsdcCatalogException {
64                 
65                 runResourceTests(new InMemoryAsdcClient.Builder().catalog(catalog).mapper(new ObjectMapper()).build());
66         }
67         
68         /**
69          * Test services.
70          *
71          * @throws AsdcCatalogException the asdc catalog exception
72          * @throws URISyntaxException the URI syntax exception
73          */
74         @Test
75         public void testServices() throws AsdcCatalogException, URISyntaxException {
76
77                 runServiceTests(new InMemoryAsdcClient.Builder().catalog(catalog).build());
78         }
79 }