2 * ============LICENSE_START=======================================================
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
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.
19 * ============LICENSE_END=========================================================
22 package org.onap.appc.dg.licmgr.impl;
24 import org.junit.Assert;
25 import java.util.HashMap;
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;
38 @RunWith(PowerMockRunner.class)
39 @PrepareForTest(LicenseModel.class)
40 public class LicenseManagerPluginImplTest {
42 private LicenseManager licenseManagerMock = Mockito.mock(LicenseManager.class);
43 private LicenseModel licenseModelMock = PowerMockito.mock(LicenseModel.class);
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"));