1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 Wipro Limited.
6 * Copyright (C) 2022 Huawei Canada Limited.
7 * ==============================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 *******************************************************************************/
22 package org.onap.slice.analysis.ms.dmaap;
24 import com.fasterxml.jackson.databind.ObjectMapper;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.mockito.InjectMocks;
29 import org.mockito.Mockito;
30 import org.mockito.Spy;
31 import org.onap.slice.analysis.ms.models.Configuration;
32 import org.springframework.boot.test.context.SpringBootTest;
33 import org.springframework.test.context.junit4.SpringRunner;
34 import com.google.gson.Gson;
35 import com.google.gson.JsonObject;
36 import java.io.IOException;
37 import java.nio.file.Files;
38 import java.nio.file.Paths;
40 @RunWith(SpringRunner.class)
41 @SpringBootTest(classes = VesNotificationCallbackTest.class)
42 public class VesNotificationCallbackTest {
43 ObjectMapper obj = new ObjectMapper();
47 VesNotificationCallback vesNotificationCallback;
50 public void init() throws IOException {
51 Configuration configuration = Configuration.getInstance();
52 String configAllJson = new String(Files.readAllBytes(Paths.get("src/test/resources/config_all.json")));
53 JsonObject configAll = new Gson().fromJson(configAllJson, JsonObject.class);
54 JsonObject config = configAll.getAsJsonObject("config");
55 configuration.updateConfigurationFromJsonObject(config);
56 vesNotificationCallback.init();
60 public void initTest() {
61 Mockito.verify(vesNotificationCallback, Mockito.atLeastOnce()).init();
65 public void activateCallBackTest() throws Exception{
66 String input = new String(Files.readAllBytes(Paths.get("src/test/resources/vesCCVPNNotiModel.json")));
67 vesNotificationCallback.activateCallBack(input);
68 Mockito.verify(vesNotificationCallback, Mockito.atLeastOnce()).activateCallBack(Mockito.anyString());