cee75ba47d15571853f996c4c82f17e52511aa4c
[appc.git] / appc-dg / appc-dg-shared / appc-dg-license-manager / src / test / java / org / onap / appc / dg / licmgr / impl / LicenseManagerPluginImplTest.java
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2019 Ericsson
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  *
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.appc.dg.licmgr.impl;
23
24 import org.junit.Assert;
25 import java.util.HashMap;
26 import java.util.Map;
27 import org.junit.Test;
28 import org.junit.runner.RunWith;
29 import org.onap.appc.exceptions.APPCException;
30 import org.onap.appc.licmgr.LicenseManager;
31 import org.onap.appc.licmgr.objects.LicenseModel;
32 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
33 import org.powermock.api.mockito.PowerMockito;
34 import org.powermock.core.classloader.annotations.PrepareForTest;
35 import org.powermock.modules.junit4.PowerMockRunner;
36 import org.mockito.Mockito;
37
38 @RunWith(PowerMockRunner.class)
39 @PrepareForTest(LicenseModel.class)
40 public class LicenseManagerPluginImplTest {
41
42     private LicenseManager licenseManagerMock = Mockito.mock(LicenseManager.class);
43     private LicenseModel licenseModelMock = PowerMockito.mock(LicenseModel.class);
44
45     @Test
46     public void testRetrieveLicenseModel() throws APPCException {
47         LicenseManagerPluginImpl lmImpl = new LicenseManagerPluginImpl();
48         lmImpl.setLicenseManager(licenseManagerMock);
49         Mockito.doReturn(licenseModelMock).when(licenseManagerMock).retrieveLicenseModel(Mockito.anyString(), Mockito.anyString());
50         Map<String, String> params = new HashMap<>();
51         SvcLogicContext ctx = new SvcLogicContext();
52         lmImpl.retrieveLicenseModel(params, ctx);
53         Assert.assertEquals("", ctx.getAttribute("license-key"));
54     }
55
56 }