b2aabb8464e6de08d9c5d41f122e325ec143d6b4
[appc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ============LICENSE_END=========================================================
22  */
23 package org.onap.appc.adapter.restHealthcheck.impl;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
28 import static org.junit.Assert.fail;
29
30 import java.io.IOException;
31 import java.lang.reflect.Field;
32 import java.util.HashMap;
33 import java.util.List;
34 import java.util.Map;
35 import java.util.Properties;
36 import java.util.Set;
37
38 import org.junit.Before;
39 import org.junit.BeforeClass;
40 import org.junit.Ignore;
41 import org.junit.Test;
42 import org.slf4j.MDC;
43
44 import org.onap.appc.Constants;
45 import org.onap.appc.adapter.restHealthcheck.*;
46 import org.onap.appc.configuration.ConfigurationFactory;
47 import org.onap.appc.exceptions.APPCException;
48 import org.onap.appc.exceptions.UnknownProviderException;
49 import com.att.cdp.exceptions.ZoneException;
50 import com.att.cdp.zones.ComputeService;
51 import com.att.cdp.zones.Context;
52 import com.att.cdp.zones.ContextFactory;
53 import com.att.cdp.zones.model.Server;
54 import com.att.cdp.zones.model.Server.Status;
55 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
56
57
58
59 public class TestRestHealthcheckAdapterImpl {
60
61     @SuppressWarnings("nls")
62     private static final String PROVIDER_NAME = "ILAB";
63
64     @SuppressWarnings("nls")
65     private static final String PROVIDER_TYPE = "OpenStackProvider";
66
67     private static String IDENTITY_URL;
68
69     private static String PRINCIPAL;
70
71     private static String CREDENTIAL;
72
73     private static String TENANT_NAME;
74
75     private static String TENANT_ID;
76
77     private static String USER_ID;
78
79     private static String REGION_NAME;
80
81     private static String SERVER_URL;
82
83     private static Class<?> providerAdapterImplClass;
84     private static Class<?> configurationFactoryClass;
85     private static Field providerCacheField;
86     private static Field configField;
87
88     private RestHealthcheckAdapterImpl adapter;
89
90
91     @SuppressWarnings("nls")
92     @BeforeClass
93     public static void once() throws NoSuchFieldException, SecurityException, NoSuchMethodException {
94
95     }
96
97     @Before
98     public void setup() throws IllegalArgumentException, IllegalAccessException {
99
100         adapter = new RestHealthcheckAdapterImpl();
101     }
102
103     @Test
104     public void testCheckHealth() throws IOException, IllegalStateException, IllegalArgumentException,
105         ZoneException, APPCException {
106
107             Map<String, String> params = new HashMap<>();
108             params.put("VNF.URI", "http://restHalthCheck.test");
109             params.put("VNF.endpoint", "health");
110             SvcLogicContext svcContext = new SvcLogicContext();
111             adapter.checkHealth(params, svcContext);
112             String statusCode=svcContext.getAttribute("healthcheck.result.code");
113             assertEquals("200",statusCode);
114     }
115
116
117
118 }