2 * ============LICENSE_START=======================================================
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
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 package org.onap.aai.modelloader.notification;
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;
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;
40 * Test the Notification Publisher using Mocks
43 public class TestNotificationPublisher {
46 private IDistributionClient client;
49 private INotificationData data;
52 private IArtifactInfo artifact;
55 private IConfiguration config;
58 private IDistributionClientResult clientResult;
61 System.setProperty("CONFIG_HOME", "src/test/resources");
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);
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);