Convert project from AJSC to Spring Boot
[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.mockito.Matchers.any;
24 import static org.mockito.Matchers.anyString;
25 import static org.mockito.Mockito.when;
26
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.mockito.Mock;
30 import org.mockito.MockitoAnnotations;
31 import org.onap.sdc.api.IDistributionClient;
32 import org.onap.sdc.api.consumer.IConfiguration;
33 import org.onap.sdc.api.notification.IArtifactInfo;
34 import org.onap.sdc.api.notification.INotificationData;
35 import org.onap.sdc.api.results.IDistributionClientResult;
36 import org.onap.sdc.utils.DistributionActionResultEnum;
37
38 /**
39  * Test the Notification Publisher using Mocks
40  *
41  */
42 public class TestNotificationPublisher {
43
44     @Mock
45     private IDistributionClient client;
46
47     @Mock
48     private INotificationData data;
49
50     @Mock
51     private IArtifactInfo artifact;
52
53     @Mock
54     private IConfiguration config;
55
56     @Mock
57     private IDistributionClientResult clientResult;
58
59     static {
60         System.setProperty("CONFIG_HOME", "src/test/resources");
61     }
62
63     @Before
64     public void setupMocks() {
65         MockitoAnnotations.initMocks(this);
66         when(client.getConfiguration()).thenReturn(config);
67         when(client.sendDownloadStatus(any())).thenReturn(clientResult);
68         when(client.sendComponentDoneStatus(any())).thenReturn(clientResult);
69         when(client.sendComponentDoneStatus(any(), anyString())).thenReturn(clientResult);
70         when(client.sendDeploymentStatus(any())).thenReturn(clientResult);
71         when(clientResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS);
72     }
73
74     @Test
75     public void testPublisher() {
76         NotificationPublisher publisher = new NotificationPublisher();
77         publisher.publishDownloadSuccess(client, data, artifact);
78         publisher.publishDownloadFailure(client, data, artifact, "");
79         publisher.publishComponentSuccess(client, data);
80         publisher.publishComponentFailure(client, data, "");
81         publisher.publishDeploySuccess(client, data, artifact);
82         publisher.publishDeployFailure(client, data, artifact);
83     }
84
85 }
86