First part of onap rename
[appc.git] / appc-adapters / appc-rest-healthcheck-adapter / appc-rest-healthcheck-adapter-bundle / src / test / java / org / onap / appc / adapter / restHealthcheck / impl / TestRestHealthcheckAdapterImpl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24 package org.onap.appc.adapter.restHealthcheck.impl;
25
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertNotNull;
28 import static org.junit.Assert.assertTrue;
29 import static org.junit.Assert.fail;
30
31 import java.io.IOException;
32 import java.lang.reflect.Field;
33 import java.util.HashMap;
34 import java.util.List;
35 import java.util.Map;
36 import java.util.Properties;
37 import java.util.Set;
38
39 import org.junit.Before;
40 import org.junit.BeforeClass;
41 import org.junit.Ignore;
42 import org.junit.Test;
43 import org.slf4j.MDC;
44
45 import org.onap.appc.Constants;
46 import org.onap.appc.adapter.restHealthcheck.*;
47 import org.onap.appc.configuration.ConfigurationFactory;
48 import org.onap.appc.exceptions.APPCException;
49 import org.onap.appc.exceptions.UnknownProviderException;
50 import com.att.cdp.exceptions.ZoneException;
51 import com.att.cdp.zones.ComputeService;
52 import com.att.cdp.zones.Context;
53 import com.att.cdp.zones.ContextFactory;
54 import com.att.cdp.zones.model.Server;
55 import com.att.cdp.zones.model.Server.Status;
56 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
57
58
59
60 public class TestRestHealthcheckAdapterImpl {
61
62     @SuppressWarnings("nls")
63     private static final String PROVIDER_NAME = "ILAB";
64
65     @SuppressWarnings("nls")
66     private static final String PROVIDER_TYPE = "OpenStackProvider";
67
68     private static String IDENTITY_URL;
69
70     private static String PRINCIPAL;
71
72     private static String CREDENTIAL;
73
74     private static String TENANT_NAME;
75
76     private static String TENANT_ID;
77
78     private static String USER_ID;
79
80     private static String REGION_NAME;
81
82     private static String SERVER_URL;
83
84     private static Class<?> providerAdapterImplClass;
85     private static Class<?> configurationFactoryClass;
86     private static Field providerCacheField;
87     private static Field configField;
88
89     private RestHealthcheckAdapterImpl adapter;
90
91
92     @SuppressWarnings("nls")
93     @BeforeClass
94     public static void once() throws NoSuchFieldException, SecurityException, NoSuchMethodException {
95
96     }
97
98     @Before
99     public void setup() throws IllegalArgumentException, IllegalAccessException {
100
101         adapter = new RestHealthcheckAdapterImpl();
102     }
103
104     @Test
105     public void testCheckHealth() throws IOException, IllegalStateException, IllegalArgumentException,
106         ZoneException, APPCException {
107
108             Map<String, String> params = new HashMap<>();
109             params.put("VNF.URI", "http://restHalthCheck.test");
110             params.put("VNF.endpoint", "health");
111             SvcLogicContext svcContext = new SvcLogicContext();
112             adapter.checkHealth(params, svcContext);
113             String statusCode=svcContext.getAttribute("healthcheck.result.code");
114             assertEquals("200",statusCode);
115     }
116
117
118
119 }