Added oparent to sdc main
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / distribution / engine / DistributionEnginePollingTaskTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.be.components.distribution.engine;
22
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;
32
33 public class DistributionEnginePollingTaskTest extends BeConfDependentTest {
34
35         @Mock
36         private ComponentsUtils componentsUtils;
37
38         private DistributionEnginePollingTask createTestSubject() {
39                 componentsUtils = Mockito.mock(ComponentsUtils.class);
40                 DistributionEngineConfiguration distributionEngineConfiguration = configurationManager
41                                 .getDistributionEngineConfiguration();
42
43                 return new DistributionEnginePollingTask(distributionEngineConfiguration,
44                                 new DistributionCompleteReporterMock(), componentsUtils, new DistributionEngineClusterHealth(),
45                                 new OperationalEnvironmentEntry());
46         }
47
48         @Test
49         public void testStartTask() throws Exception {
50                 DistributionEnginePollingTask testSubject;
51                 String topicName = "";
52
53                 // default test
54                 testSubject = createTestSubject();
55                 testSubject.startTask(topicName);
56         }
57
58         @Test
59         public void testStopTask() throws Exception {
60                 DistributionEnginePollingTask testSubject;
61
62                 // default test
63                 testSubject = createTestSubject();
64                 testSubject.stopTask();
65         }
66
67         @Test
68         public void testDestroy() throws Exception {
69                 DistributionEnginePollingTask testSubject;
70
71                 // default test
72                 testSubject = createTestSubject();
73                 testSubject.destroy();
74         }
75
76         @Test
77         public void testRun() throws Exception {
78                 DistributionEnginePollingTask testSubject;
79
80                 // default test
81                 testSubject = createTestSubject();
82                 testSubject.run();
83         }
84         
85         @Test
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");
95                 
96                 
97                 
98                 // default test
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",
104                                 notification);
105         }
106
107         @Test
108         public void testShutdownExecutor() throws Exception {
109                 DistributionEnginePollingTask testSubject;
110
111                 // default test
112                 testSubject = createTestSubject();
113                 Deencapsulation.invoke(testSubject, "shutdownExecutor");
114         }
115
116         private class DistributionCompleteReporterMock implements DistributionCompleteReporter {
117
118                 @Override
119                 public void reportDistributionComplete(DistributionStatusNotification distributionStatusNotification) {
120                         // TODO Auto-generated method stub
121
122                 }
123
124         }
125 }