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.mockito.Matchers.any;
24 import static org.mockito.Matchers.anyString;
25 import static org.mockito.Mockito.when;
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;
39 * Test the Notification Publisher using Mocks
42 public class TestNotificationPublisher {
45 private IDistributionClient client;
48 private INotificationData data;
51 private IArtifactInfo artifact;
54 private IConfiguration config;
57 private IDistributionClientResult clientResult;
60 System.setProperty("CONFIG_HOME", "src/test/resources");
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);
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);