add junit coverage
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / service / level / impl / ServiceLevelUpgradeTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 Nokia
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.bpmn.infrastructure.service.level.impl;
22
23 import static org.assertj.core.api.Assertions.assertThat;
24 import org.camunda.bpm.engine.delegate.DelegateExecution;
25 import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
26 import org.junit.Test;
27
28 public class ServiceLevelUpgradeTest {
29
30     @Test
31     public void ServiceLevelUpgradeWithPnf() throws Exception {
32         // given
33         ServiceLevelUpgrade testedObject = new ServiceLevelUpgrade();
34         DelegateExecution execution = prepareExecution();
35         execution.setVariable(ServiceLevelConstants.RESOURCE_TYPE, "pnf");
36         // when
37         testedObject.execute(execution);
38         // then
39         assertThat(execution.getVariable(ServiceLevelConstants.SOFTWARE_WORKFLOW_TO_INVOKE))
40                 .isEqualTo("PNFSoftwareUpgrade");
41         assertThat(execution.getVariable(ServiceLevelConstants.CONTROLLER_STATUS)).isEqualTo("");
42     }
43
44     @Test
45     public void ServiceLevelUpgradeWithVnf() throws Exception {
46         // given
47         ServiceLevelUpgrade testedObject = new ServiceLevelUpgrade();
48         DelegateExecution execution = prepareExecution();
49         execution.setVariable(ServiceLevelConstants.RESOURCE_TYPE, "vnf");
50         // when
51         testedObject.execute(execution);
52         // then
53         assertThat(execution.getVariable(ServiceLevelConstants.SOFTWARE_WORKFLOW_TO_INVOKE)).isNull();
54         assertThat(execution.getVariable(ServiceLevelConstants.CONTROLLER_STATUS)).isNull();
55     }
56
57     private DelegateExecution prepareExecution() {
58         DelegateExecution execution = new DelegateExecutionFake();
59         execution.setVariable(ServiceLevelConstants.SERVICE_INSTANCE_ID, "serviceTest");
60         execution.setVariable(ServiceLevelConstants.BPMN_REQUEST, "bpmnRequestTest");
61         execution.setVariable(ServiceLevelConstants.PNF_NAME, "pnfNameTest");
62         return execution;
63     }
64
65 }