Improve Test coverage of InfluxLogger
[nonrtric/plt/ranpm.git] / influxlogger / src / test / java / org / oran / pmlog / BeanFactoryTest.java
1 /*-
2  * ========================LICENSE_START=================================
3  * O-RAN-SC
4  * %%
5  * Copyright (C) 2023 Nordix Foundation
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  * ========================LICENSE_END===================================
19  */
20
21 package org.oran.pmlog;
22
23 import static org.junit.jupiter.api.Assertions.assertNotNull;
24
25 import org.junit.jupiter.api.Test;
26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.boot.test.context.SpringBootTest;
28 import org.springframework.test.context.TestPropertySource;
29
30 @SpringBootTest
31 @TestPropertySource(properties = { "server.http-port=8080" }) // Set the http-port property
32 class BeanFactoryTest {
33
34     @Autowired
35     private BeanFactory beanFactory;
36
37     @Test
38     void testApplicationConfigBean() {
39         // Ensure that the ApplicationConfig bean is created
40         assertNotNull(beanFactory.getApplicationConfig());
41     }
42
43     @Test
44     void testServletContainerBean() {
45         // Ensure that the ServletWebServerFactory bean is created
46         assertNotNull(beanFactory.servletContainer());
47     }
48
49     @Test
50     void testKafkaTopicListenerBean() {
51         // Ensure that the KafkaTopicListener bean is created with ApplicationConfig dependency
52         assertNotNull(beanFactory.getKafkaTopicListener(beanFactory.getApplicationConfig()));
53     }
54
55     @Test
56     void testInfluxStoreBean() {
57         // Ensure that the InfluxStore bean is created with ApplicationConfig and KafkaTopicListener dependencies
58         assertNotNull(beanFactory.getInfluxStore(beanFactory.getApplicationConfig(), beanFactory.getKafkaTopicListener(beanFactory.getApplicationConfig())));
59     }
60 }