Release 1.14.1 container image
[aai/model-loader.git] / src / test / java / org / onap / aai / modelloader / config / DistributionClientStartupConfigTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * 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
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.aai.modelloader.config;
21
22 import static org.mockito.ArgumentMatchers.any;
23 import static org.mockito.Mockito.mock;
24 import static org.mockito.Mockito.times;
25 import static org.mockito.Mockito.verify;
26 import static org.mockito.Mockito.when;
27
28 import org.junit.jupiter.api.Test;
29 import org.mockito.InjectMocks;
30 import org.mockito.Mock;
31 import org.onap.aai.modelloader.notification.EventCallback;
32 import org.onap.sdc.api.IDistributionClient;
33 import org.onap.sdc.api.results.IDistributionClientResult;
34 import org.onap.sdc.utils.DistributionActionResultEnum;
35 import org.springframework.boot.test.context.SpringBootTest;
36
37 @SpringBootTest
38 public class DistributionClientStartupConfigTest {
39
40   @Mock IDistributionClient distributionClient;
41   @Mock ModelLoaderConfig config;
42   @Mock EventCallback eventCallback;
43   @InjectMocks DistributionClientStartupConfig startupConfig;
44
45   @Test
46   public void thatClientIsInitialized() {
47     IDistributionClientResult initResult = mock(IDistributionClientResult.class);
48     when(distributionClient.init(any(), any())).thenReturn(initResult);
49     when(distributionClient.start()).thenReturn(initResult);
50     when(initResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS);
51     startupConfig.initSdcClient();
52     verify(distributionClient, times(1)).init(any(), any());
53     verify(distributionClient, times(1)).start();
54   }
55
56   @Test
57   public void thatClientIsStoppedOnPreDestroy() {
58     startupConfig.destroy();
59     verify(distributionClient, times(1)).stop();
60   }
61   
62 }