beb11998b43c7a7c0ce43a107754ac5d85119291
[dcaegen2/services.git] /
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  slice-analysis-ms
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
11  *
12  *          http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  *
21  *******************************************************************************/
22 package org.onap.slice.analysis.ms.dmaap;
23
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;
39
40 @RunWith(SpringRunner.class)
41 @SpringBootTest(classes = VesNotificationCallbackTest.class)
42 public class VesNotificationCallbackTest {
43     ObjectMapper obj = new ObjectMapper();
44
45     @Spy
46     @InjectMocks
47     VesNotificationCallback vesNotificationCallback;
48
49     @Before
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();
57     }
58
59     @Test
60     public void initTest() {
61         Mockito.verify(vesNotificationCallback, Mockito.atLeastOnce()).init();
62     }
63
64     @Test
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());
69     }
70
71 }