2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Ericsson
6 * ================================================================================
7 * Modifications Copyright (C) 2019 AT&T Intellectual Property
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.appc.dg.licmgr.impl;
26 import org.junit.Assert;
27 import java.util.HashMap;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31 import org.onap.appc.exceptions.APPCException;
32 import org.onap.appc.licmgr.LicenseManager;
33 import org.onap.appc.licmgr.objects.LicenseModel;
34 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
35 import org.powermock.api.mockito.PowerMockito;
36 import org.powermock.core.classloader.annotations.PrepareForTest;
37 import org.powermock.modules.junit4.PowerMockRunner;
38 import org.mockito.Mockito;
40 @RunWith(PowerMockRunner.class)
41 @PrepareForTest(LicenseModel.class)
42 public class LicenseManagerPluginImplTest {
44 private LicenseManager licenseManagerMock = Mockito.mock(LicenseManager.class);
45 private LicenseModel licenseModelMock = PowerMockito.mock(LicenseModel.class);
48 public void testRetrieveLicenseModel() throws APPCException {
49 LicenseManagerPluginImpl lmImpl = new LicenseManagerPluginImpl();
50 lmImpl.setLicenseManager(licenseManagerMock);
51 Mockito.doReturn(licenseModelMock).when(licenseManagerMock)
52 .retrieveLicenseModel(Mockito.anyString(), Mockito.anyString());
53 Map<String, String> params = new HashMap<>();
54 SvcLogicContext ctx = new SvcLogicContext();
55 lmImpl.retrieveLicenseModel(params, ctx);
56 Assert.assertEquals("", ctx.getAttribute("license-key"));