Fix NullPointerException in cnf-adaper 25/141525/1 1.13.0
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Sat, 12 Jul 2025 09:14:56 +0000 (11:14 +0200)
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>
Sat, 12 Jul 2025 09:14:56 +0000 (11:14 +0200)
- add @ComponentScan annotation that was removed in
  one of the last changes.
  It is required to pick up beans from the so common lib

Issue-ID: SO-4205
Change-Id: I1620cd983924dc1d45a0029444967ea9671dcb96
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/MSOCnfApplication.java
so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/SpringContextHelperTest.java [new file with mode: 0644]

index 5984192..577ecf5 100644 (file)
@@ -28,8 +28,10 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerA
 import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
 import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
 import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
+import org.springframework.context.annotation.ComponentScan;
 
 @SpringBootApplication
+@ComponentScan(basePackages = {"org.onap.so.adapters.cnf", "org.onap.so.spring"})
 @EnableAutoConfiguration(exclude = {LiquibaseAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
         DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class,
         SecurityAutoConfiguration.class})
diff --git a/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/SpringContextHelperTest.java b/so-cnf-adapter-application/src/test/java/org/onap/so/adapters/cnf/SpringContextHelperTest.java
new file mode 100644 (file)
index 0000000..e05f491
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2025 Deutsche Telekom
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.so.adapters.cnf;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.spring.SpringContextHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@SpringBootTest
+@RunWith(SpringRunner.class)
+public class SpringContextHelperTest {
+
+  @Autowired
+  SpringContextHelper helper;
+
+  @Test
+  // The SpringContextHelper is part of the so common library
+  // and is in a package that would normally not be picked up
+  // by spring's context scanning.
+  // This test thus essentially assures that the spring boot app
+  // has a @ComponentScan that includes org.onap.so.spring
+  public void thatSpringContextHelperIsAvailable() {
+    assertNotNull(helper);
+  }
+}