aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org/onap/vid/asdc/rest/RestfulAsdcClientTest.java
blob: c1833bb759ae33ea4fa5ca97f22b8e8da710003c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
package org.onap.vid.asdc.rest;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collection;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

import org.junit.Before;
import org.junit.Test;
import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.asdc.beans.Artifact;
import org.onap.vid.asdc.beans.Resource;
import org.onap.vid.asdc.beans.Service;

import nu.xom.Builder;

public class RestfulAsdcClientTest {

    private RestfulAsdcClient createTestSubject() {
        return new RestfulAsdcClient.Builder(restClient, uri).auth(auth)
                .build();
    }

    /** The rest client. */
    private Client restClient;

    /** The uri. */
    private URI uri;

    /** The properties. */
    private Properties properties;

    /** The auth. */
    private String auth;

    /**
     * Sets the up.
     *
     * @throws URISyntaxException
     *             the URI syntax exception
     * @throws IOException
     *             Signals that an I/O exception has occurred.
     */
    @Before
    public void setUp() throws URISyntaxException, IOException {
        final InputStream propertiesFile = getClass().getClassLoader()
                .getResourceAsStream("asdc.properties");

        properties = new Properties();
        properties.load(propertiesFile);

        final String protocol = properties.getProperty("protocol", "http");

        restClient = ClientBuilder.newBuilder()
                .hostnameVerifier(new HostnameVerifier() {

                    @Override
                    public boolean verify(String arg0, SSLSession arg1) {
                        return true;
                    }
                })
                .build();
        uri = new URI(protocol + "://" + properties.getProperty("host", "localhost") + ":"
                + properties.getProperty("port", "80") + "/");
        auth = properties.getProperty("auth");
    }

    @Test
    public void testGetResource() throws Exception {
        RestfulAsdcClient testSubject;
        UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-556642440000");
        Resource result;

        // default test
        testSubject = createTestSubject();
        try {
            result = testSubject.getResource(uuid);
        } catch (Exception e) {

        }
    }

    @Test
    public void testGetResourceArtifact() throws Exception {
        RestfulAsdcClient testSubject;
        UUID resourceUuid = UUID.fromString("123e4567-e89b-12d3-a456-556642440000");
        UUID artifactUuid = UUID.fromString("123e4567-e89b-12d3-a456-556642440000");
        Artifact result;

        // default test
        testSubject = createTestSubject();
        try {
            result = testSubject.getResourceArtifact(resourceUuid, artifactUuid);
        } catch (Exception e) {

        }
    }

    @Test
    public void testGetResources() throws Exception {
        RestfulAsdcClient testSubject;
        Collection<Resource> result;

        // default test
        testSubject = createTestSubject();
        try {
            result = testSubject.getResources();
        } catch (Exception e) {

        }
    }

    @Test
    public void testGetResources_1() throws Exception {
        RestfulAsdcClient testSubject;
        Map<String, String[]> filter = null;
        Collection<Resource> result;

        // default test
        testSubject = createTestSubject();
        try {
            result = testSubject.getResources(filter);
        } catch (Exception e) {

        }
    }

    @Test
    public void testGetResourceToscaModel() throws Exception {
        RestfulAsdcClient testSubject;
        UUID resourceUuid = UUID.fromString("123e4567-e89b-12d3-a456-556642440000");

        // default test
        testSubject = createTestSubject();
        try {
            testSubject.getResourceToscaModel(resourceUuid);
        } catch (Exception e) {

        }
    }

    @Test
    public void testGetService() throws Exception {
        RestfulAsdcClient testSubject;
        UUID uuid = UUID.fromString("123e4567-e89b-12d3-a456-556642440000");
        Service result;

        // default test
        testSubject = createTestSubject();
        try {
            result = testSubject.getService(uuid);
        } catch (Exception e) {

        }
    }

    @Test
    public void testGetServiceArtifact() throws Exception {
        RestfulAsdcClient testSubject;
        UUID serviceUuid = UUID.fromString("123e4567-e89b-12d3-a456-556642440000");
        UUID artifactUuid = UUID.fromString("123e4567-e89b-12d3-a456-556642440000");
        Artifact result;

        // default test
        testSubject = createTestSubject();
        try {
            result = testSubject.getServiceArtifact(serviceUuid, artifactUuid);
        } catch (Exception e) {

        }
    }

    @Test
    public void testGetServices() throws Exception {
        RestfulAsdcClient testSubject;
        Collection<Service> result;

        // default test
        testSubject = createTestSubject();
        try {
            result = testSubject.getServices();
        } catch (Exception e) {

        }
    }

    @Test
    public void testGetServices_1() throws Exception {
        RestfulAsdcClient testSubject;
        Map<String, String[]> filter = null;
        Collection<Service> result;

        // default test
        testSubject = createTestSubject();
        try {
            result = testSubject.getServices(filter);
        } catch (Exception e) {

        }
    }

    @Test
    public void testGetServiceToscaModel() throws Exception {
        RestfulAsdcClient testSubject;
        UUID serviceUuid = UUID.fromString("123e4567-e89b-12d3-a456-556642440000");

        // default test
        testSubject = createTestSubject();
        try {
            testSubject.getServiceToscaModel(serviceUuid);
        } catch (Exception e) {

        }
    }

}