fa289aa4b4c42fd5d762a169d9b16f5f0e2a4eb3
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * Copyright (C) 2021 Samsung Electronics Intellectual Property. All rights reserved.
7  * =================================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
9  * in compliance with the License. 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 distributed under the License
14  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
15  * or implied. See the License for the specific language governing permissions and limitations under
16  * the License.
17  * ============LICENSE_END==========================================================================
18  */
19
20 package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test;
21
22 import static org.junit.Assert.assertTrue;
23 import java.io.IOException;
24 import java.util.Map;
25 import javax.annotation.Nonnull;
26 import org.junit.Test;
27 import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPResponse;
28 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.FaultNotificationClient;
29
30 public class TestFaultNotificationClient extends FaultNotificationClient {
31
32     public static String baseUrl = "http://localhost:8181";
33     FaultNotificationClient testClient;
34
35
36     public TestFaultNotificationClient() {
37         super(baseUrl);
38
39     }
40
41     @Test
42     public void testFaultNotificationClient() {
43         testClient = new TestFaultNotificationClient();
44         testClient.setAuthorization("admin", "admin");
45         Map<String, String> payloadMap = FaultNotificationClient.createFaultNotificationPayloadMap(
46                 "TEST_50001", "1", "2019-11-20T09:25:19.948Z",
47                 "SEDNKSAHQ01M01nSky01", "lossOfSignal", "Critical");
48         String msg = testClient.prepareMessageFromPayloadMap(payloadMap);
49         assertTrue(testClient.sendNotification(msg));
50         assertTrue(testClient.sendNotification(msg));
51     }
52
53     @Override
54     @Nonnull
55     public BaseHTTPResponse sendRequest(String uri, String method, String body, Map<String, String> headers)
56             throws IOException {
57         System.out.println("In overridden sendRequest in TestFaultNotificationClient");
58         return new BaseHTTPResponse(200, body);
59     }
60 }