summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml4
-rw-r--r--src/main/java/org/onap/aai/schema/OxmModelLoader.java27
-rw-r--r--src/test/java/org/onap/aai/schema/OxmModelLoaderTest.java16
-rw-r--r--src/test/resources/schemaIngest.properties4
-rw-r--r--src/test/resources/spring-beans/data-router-oxm.xml9
5 files changed, 38 insertions, 22 deletions
diff --git a/pom.xml b/pom.xml
index e921965..8da4245 100644
--- a/pom.xml
+++ b/pom.xml
@@ -94,12 +94,12 @@ limitations under the License.
<dependency>
<groupId>org.onap.aai.aai-common</groupId>
<artifactId>aai-schema</artifactId>
- <version>1.3.0</version>
+ <version>1.4.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.onap.aai.aai-common</groupId>
<artifactId>aai-schema-ingest</artifactId>
- <version>1.3.0</version>
+ <version>1.4.1-SNAPSHOT</version>
<!--<exclusions>-->
<!--<exclusion>-->
<!--<groupId>com.google.guava</groupId>-->
diff --git a/src/main/java/org/onap/aai/schema/OxmModelLoader.java b/src/main/java/org/onap/aai/schema/OxmModelLoader.java
index bd64f3e..67e53bc 100644
--- a/src/main/java/org/onap/aai/schema/OxmModelLoader.java
+++ b/src/main/java/org/onap/aai/schema/OxmModelLoader.java
@@ -32,11 +32,10 @@ import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.logging.RouterCoreMsgs;
import org.onap.aai.util.ExternalOxmModelProcessor;
import org.onap.aai.nodes.NodeIngestor;
-import org.onap.aai.setup.ConfigTranslator;
import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
-import org.onap.aai.setup.AAIConfigTranslator;
+
public class OxmModelLoader {
@@ -46,19 +45,19 @@ public class OxmModelLoader {
private static final org.onap.aai.cl.api.Logger logger =
LoggerFactory.getInstance().getLogger(OxmModelLoader.class.getName());
- private OxmModelLoader() {
- throw new IllegalStateException("Utility class");
+ private static NodeIngestor nodeIngestor;
+
+ private OxmModelLoader(NodeIngestor setNodeIngestor) {
+ nodeIngestor = setNodeIngestor;
}
public static synchronized void loadModels(SchemaVersions schemaVersions, SchemaLocationsBean schemaLocationsBean) {
- ConfigTranslator configTranslator = new AAIConfigTranslator(schemaLocationsBean, schemaVersions);
- NodeIngestor nodeIngestor = new NodeIngestor(configTranslator);
for (SchemaVersion oxmVersion : schemaVersions.getVersions()) {
- DynamicJAXBContext jaxbContext = nodeIngestor.getContextForVersion(oxmVersion);
- if (jaxbContext != null) {
- loadModel(oxmVersion.toString(), jaxbContext);
- }
+ DynamicJAXBContext jaxbContext = nodeIngestor.getContextForVersion(oxmVersion);
+ if (jaxbContext != null) {
+ loadModel(oxmVersion.toString(), jaxbContext);
+ }
}
}
@@ -86,6 +85,14 @@ public class OxmModelLoader {
return versionContextMap;
}
+ public static NodeIngestor getNodeIngestor() {
+ return nodeIngestor;
+ }
+
+ public static void setNodeIngestor(NodeIngestor nodeIngestor) {
+ OxmModelLoader.nodeIngestor = nodeIngestor;
+ }
+
private static synchronized void loadModel(String oxmVersion, DynamicJAXBContext jaxbContext) {
versionContextMap.put(oxmVersion, jaxbContext);
if (oxmModelProcessorRegistry != null) {
diff --git a/src/test/java/org/onap/aai/schema/OxmModelLoaderTest.java b/src/test/java/org/onap/aai/schema/OxmModelLoaderTest.java
index f3e9091..6c221f7 100644
--- a/src/test/java/org/onap/aai/schema/OxmModelLoaderTest.java
+++ b/src/test/java/org/onap/aai/schema/OxmModelLoaderTest.java
@@ -32,6 +32,7 @@ import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.eclipse.persistence.mappings.DatabaseMapping;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.setup.SchemaLocationsBean;
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.EntityOxmReferenceHelper;
@@ -44,17 +45,20 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml")
public class OxmModelLoaderTest {
- @Autowired
- private SchemaVersions schemaVersions;
- @Autowired
- private SchemaLocationsBean schemaLocationsBean;
-
+ @Autowired
+ private SchemaVersions schemaVersions;
+ @Autowired
+ private SchemaLocationsBean schemaLocationsBean;
+ @Autowired
+ private NodeIngestor nodeIngestor;
+
@Test
public void testLoadingMultipleOxmFiles() {
-
+
ArrayList<ExternalOxmModelProcessor> externalOxmModelProcessors = new ArrayList<ExternalOxmModelProcessor>();
externalOxmModelProcessors.add(EntityOxmReferenceHelper.getInstance());
OxmModelLoader.registerExternalOxmModelProcessors(externalOxmModelProcessors);
+ OxmModelLoader.setNodeIngestor(nodeIngestor);
OxmModelLoader.loadModels(schemaVersions, schemaLocationsBean);
DynamicJAXBContext jaxbContext = OxmModelLoader.getContextForVersion("v13", schemaVersions, schemaLocationsBean);
diff --git a/src/test/resources/schemaIngest.properties b/src/test/resources/schemaIngest.properties
deleted file mode 100644
index d56d2ef..0000000
--- a/src/test/resources/schemaIngest.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-# Properties for the SchemaLocationsBean
-schemaConfig=NA
-nodeDir=src/test/resources/oxm-reader/oxm/
-edgeDir= \ No newline at end of file
diff --git a/src/test/resources/spring-beans/data-router-oxm.xml b/src/test/resources/spring-beans/data-router-oxm.xml
index 90e7e97..8dd38eb 100644
--- a/src/test/resources/spring-beans/data-router-oxm.xml
+++ b/src/test/resources/spring-beans/data-router-oxm.xml
@@ -11,4 +11,13 @@
<bean id="schemaLocationsBean" class="org.onap.aai.setup.SchemaLocationsBean"/>
+ <bean id="oxmConfigTranslator" class="org.onap.aai.setup.AAIConfigTranslator">
+ <constructor-arg ref="schemaLocationsBean" />
+ <constructor-arg ref="schemaVersions" />
+ </bean>
+
+ <bean id="nodeIngestor" class="org.onap.aai.nodes.NodeIngestor">
+ <constructor-arg ref="oxmConfigTranslator" />
+ </bean>
+
</beans>