Unit tests in dg-util
[appc.git] / appc-dg-util / appc-dg-util-bundle / src / test / java / org / onap / appc / dg / util / impl / UpgradeStubNodeImplTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Copyright (C) 2018 Nokia
10  * =============================================================================
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  *      http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  * ============LICENSE_END=========================================================
24  */
25
26 package org.onap.appc.dg.util.impl;
27
28 import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
29 import static org.mockito.Mockito.verifyZeroInteractions;
30
31 import java.util.HashMap;
32 import java.util.Map;
33 import org.junit.Before;
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.mockito.Mock;
37 import org.mockito.runners.MockitoJUnitRunner;
38 import org.onap.appc.dg.util.UpgradeStubNode;
39 import org.onap.appc.exceptions.APPCException;
40 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
41
42 @RunWith(MockitoJUnitRunner.class)
43 public class UpgradeStubNodeImplTest {
44
45     @Mock
46     private SvcLogicContext svcLogicContext;
47
48     private UpgradeStubNode upgradeStubNode;
49
50     @Before
51     public void setUp() {
52         upgradeStubNode = new UpgradeStubNodeImpl();
53     }
54
55     @Test
56     public void handleUpgradeStub_shouldCompleteSuccessfully_whenFailureIndicatorIsNull() throws APPCException {
57         Map<String, String> params = new HashMap<>();
58         upgradeStubNode.handleUpgradeStub(params, svcLogicContext);
59         verifyZeroInteractions(svcLogicContext);
60     }
61
62     @Test
63     public void handleUpgradeStub_shouldCompleteSuccessfully_whenFailureIndicatorIsFalse() throws APPCException {
64         // GIVEN
65         Map<String, String> params = new HashMap<>();
66         params.put("failureIndicator", "false");
67         // WHEN
68         upgradeStubNode.handleUpgradeStub(params, svcLogicContext);
69         // THEN
70         verifyZeroInteractions(svcLogicContext);
71     }
72
73     @Test
74     public void handleUpgradeStub_shouldThrowAPPCException_whenFailureIndicatorIsTrue() throws APPCException {
75         // GIVEN
76         Map<String, String> params = new HashMap<>();
77         params.put("failureIndicator", "true");
78         // WHEN // THEN
79         assertThatExceptionOfType(APPCException.class)
80             .isThrownBy(() -> upgradeStubNode.handleUpgradeStub(params, svcLogicContext));
81         verifyZeroInteractions(svcLogicContext);
82     }
83 }