Upgrade spring-boot to 2.7.X in model-loader
[aai/model-loader.git] / src / test / java / org / onap / aai / modelloader / notification / TestNotificationPublisher.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 European Software Marketing Ltd.
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 package org.onap.aai.modelloader.notification;
22
23 import static org.junit.jupiter.api.Assertions.assertTrue;
24 import static org.mockito.ArgumentMatchers.any;
25 import static org.mockito.ArgumentMatchers.anyString;
26 import static org.mockito.Mockito.when;
27
28 import org.junit.jupiter.api.BeforeEach;
29 import org.junit.jupiter.api.Test;
30 import org.mockito.Mock;
31 import org.mockito.MockitoAnnotations;
32 import org.onap.sdc.api.IDistributionClient;
33 import org.onap.sdc.api.consumer.IConfiguration;
34 import org.onap.sdc.api.notification.IArtifactInfo;
35 import org.onap.sdc.api.notification.INotificationData;
36 import org.onap.sdc.api.results.IDistributionClientResult;
37 import org.onap.sdc.utils.DistributionActionResultEnum;
38
39 /**
40  * Test the Notification Publisher using Mocks
41  *
42  */
43 public class TestNotificationPublisher {
44
45     @Mock
46     private IDistributionClient client;
47
48     @Mock
49     private INotificationData data;
50
51     @Mock
52     private IArtifactInfo artifact;
53
54     @Mock
55     private IConfiguration config;
56
57     @Mock
58     private IDistributionClientResult clientResult;
59
60     static {
61         System.setProperty("CONFIG_HOME", "src/test/resources");
62     }
63
64     @BeforeEach
65     public void setupMocks() {
66         MockitoAnnotations.openMocks(this);
67         when(client.getConfiguration()).thenReturn(config);
68         when(client.sendDownloadStatus(any())).thenReturn(clientResult);
69         when(client.sendComponentDoneStatus(any())).thenReturn(clientResult);
70         when(client.sendComponentDoneStatus(any(), anyString())).thenReturn(clientResult);
71         when(client.sendDeploymentStatus(any())).thenReturn(clientResult);
72         when(clientResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS);
73     }
74
75     @Test
76     public void testPublisher() {
77         NotificationPublisher publisher = new NotificationPublisher();
78         publisher.publishDownloadSuccess(client, data, artifact);
79         publisher.publishDownloadFailure(client, data, artifact, "");
80         publisher.publishComponentSuccess(client, data);
81         publisher.publishComponentFailure(client, data, "");
82         publisher.publishDeploySuccess(client, data, artifact);
83         publisher.publishDeployFailure(client, data, artifact);
84         assertTrue(true);
85     }
86
87 }
88