2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.be.components.distribution.engine;
23 import mockit.Deencapsulation;
24 import org.junit.Test;
25 import org.mockito.Mock;
26 import org.mockito.Mockito;
27 import org.openecomp.sdc.be.components.BeConfDependentTest;
28 import org.openecomp.sdc.be.components.distribution.engine.report.DistributionCompleteReporter;
29 import org.openecomp.sdc.be.config.DistributionEngineConfiguration;
30 import org.openecomp.sdc.be.impl.ComponentsUtils;
31 import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry;
33 public class DistributionEnginePollingTaskTest extends BeConfDependentTest {
36 private ComponentsUtils componentsUtils;
38 private DistributionEnginePollingTask createTestSubject() {
39 componentsUtils = Mockito.mock(ComponentsUtils.class);
40 DistributionEngineConfiguration distributionEngineConfiguration = configurationManager
41 .getDistributionEngineConfiguration();
43 return new DistributionEnginePollingTask(distributionEngineConfiguration,
44 new DistributionCompleteReporterMock(), componentsUtils, new DistributionEngineClusterHealth(),
45 new OperationalEnvironmentEntry());
49 public void testStartTask() throws Exception {
50 DistributionEnginePollingTask testSubject;
51 String topicName = "";
54 testSubject = createTestSubject();
55 testSubject.startTask(topicName);
59 public void testStopTask() throws Exception {
60 DistributionEnginePollingTask testSubject;
63 testSubject = createTestSubject();
64 testSubject.stopTask();
68 public void testDestroy() throws Exception {
69 DistributionEnginePollingTask testSubject;
72 testSubject = createTestSubject();
73 testSubject.destroy();
77 public void testRun() throws Exception {
78 DistributionEnginePollingTask testSubject;
81 testSubject = createTestSubject();
86 public void testHandleDistributionNotificationMsg() throws Exception {
87 DistributionEnginePollingTask testSubject;
88 DistributionStatusNotification notification = new DistributionStatusNotification();
89 notification.setDistributionID("mock");
90 notification.setConsumerID("mock");
91 notification.setArtifactURL("mock");
92 notification.setTimestamp(435435);
93 notification.setStatus(DistributionStatusNotificationEnum.ALREADY_DEPLOYED);
94 notification.setErrorReason("mock");
99 testSubject = createTestSubject();
100 Mockito.doNothing().when(componentsUtils).auditDistributionStatusNotification( Mockito.anyString(),
101 Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(),
102 Mockito.anyString(), Mockito.anyString());
103 Deencapsulation.invoke(testSubject, "handleDistributionNotificationMsg",
108 public void testShutdownExecutor() throws Exception {
109 DistributionEnginePollingTask testSubject;
112 testSubject = createTestSubject();
113 Deencapsulation.invoke(testSubject, "shutdownExecutor");
116 private class DistributionCompleteReporterMock implements DistributionCompleteReporter {
119 public void reportDistributionComplete(DistributionStatusNotification distributionStatusNotification) {
120 // TODO Auto-generated method stub