6fd9cb1927f2b0429560e78565049e2f6293c131
[appc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
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
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.licmgr.impl;
23
24
25 import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
26 import static org.mockito.BDDMockito.given;
27
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;
35
36 @RunWith(MockitoJUnitRunner.class)
37 public class LicenseManagerImplTest {
38
39     @Mock
40     private LicenseDataAccessService licenseDataAccessService;
41
42     @Test
43     public void retrieveLicenseModel_shouldThrowException_whenRetrieveLicenseModelDataIsEmpty() {
44
45         // GIVEN
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());
51
52         // WHEN THEN
53         LicenseManagerImpl licenseManager = new LicenseManagerImpl();
54         licenseManager.setDAService(licenseDataAccessService);
55
56         assertThatExceptionOfType(DataAccessException.class)
57             .isThrownBy(() -> licenseManager.retrieveLicenseModel(vnfType, vnfVersion))
58             .withMessage(expectedMessage);
59     }
60 }