2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Nokia.
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.licmgr.impl;
25 import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
26 import static org.mockito.BDDMockito.given;
28 import java.util.Collections;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31 import org.mockito.Mock;
32 import org.mockito.runners.MockitoJUnitRunner;
33 import org.onap.appc.licmgr.LicenseDataAccessService;
34 import org.onap.appc.licmgr.exception.DataAccessException;
36 @RunWith(MockitoJUnitRunner.class)
37 public class LicenseManagerImplTest {
40 private LicenseDataAccessService licenseDataAccessService;
43 public void retrieveLicenseModel_shouldThrowException_whenRetrieveLicenseModelDataIsEmpty() {
46 String vnfType = "dummy1";
47 String vnfVersion = "dummy2";
48 String expectedMessage = String
49 .format("License model not found for vnfType='%s' and vnfVersion='%s'", vnfType, vnfVersion);
50 given(licenseDataAccessService.retrieveLicenseModelData(vnfType, vnfVersion)).willReturn(Collections.emptyMap());
53 LicenseManagerImpl licenseManager = new LicenseManagerImpl();
54 licenseManager.setDAService(licenseDataAccessService);
56 assertThatExceptionOfType(DataAccessException.class)
57 .isThrownBy(() -> licenseManager.retrieveLicenseModel(vnfType, vnfVersion))
58 .withMessage(expectedMessage);