2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
7 * Modifications Copyright (C) 2023 Nordix Foundation.
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.
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.api.main.startstop;
25 import static org.assertj.core.api.Assertions.assertThatCode;
27 import org.junit.jupiter.api.Test;
28 import org.onap.policy.api.main.PolicyApiApplication;
29 import org.onap.policy.api.main.config.PolicyPreloadConfig;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.boot.test.context.SpringBootTest;
32 import org.springframework.test.annotation.DirtiesContext;
33 import org.springframework.test.context.ActiveProfiles;
35 @SpringBootTest(classes = PolicyApiApplication.class)
36 @ActiveProfiles("test")
37 @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
38 class ApiDatabaseInitializerTest {
41 private PolicyPreloadConfig params;
44 private ApiDatabaseInitializer adi;
47 void testInitializeApiDatabase() {
48 assertThatCode(() -> adi.initializeApiDatabase(params.getPolicyTypes(),
49 params.getPolicies())).doesNotThrowAnyException();
51 // invoke it again - should still be OK
52 assertThatCode(() -> adi.initializeApiDatabase(params.getPolicyTypes(),
53 params.getPolicies())).doesNotThrowAnyException();