Java 17 / Spring 6 / Spring Boot 3 Upgrade
[policy/api.git] / main / src / test / java / org / onap / policy / api / main / startstop / ApiDatabaseInitializerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
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
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
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=========================================================
21  */
22
23 package org.onap.policy.api.main.startstop;
24
25 import static org.assertj.core.api.Assertions.assertThatCode;
26
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;
34
35 @SpringBootTest(classes = PolicyApiApplication.class)
36 @ActiveProfiles("test")
37 @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
38 class ApiDatabaseInitializerTest {
39
40     @Autowired
41     private PolicyPreloadConfig params;
42
43     @Autowired
44     private ApiDatabaseInitializer adi;
45
46     @Test
47     void testInitializeApiDatabase() {
48         assertThatCode(() -> adi.initializeApiDatabase(params.getPolicyTypes(),
49                 params.getPolicies())).doesNotThrowAnyException();
50
51         // invoke it again - should still be OK
52         assertThatCode(() -> adi.initializeApiDatabase(params.getPolicyTypes(),
53                 params.getPolicies())).doesNotThrowAnyException();
54     }
55 }