aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml13
-rw-r--r--src/main/docker/Dockerfile1
-rw-r--r--src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java24
-rw-r--r--src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicy.java215
-rw-r--r--src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicyConfig.java21
-rw-r--r--src/main/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessor.java27
-rw-r--r--src/main/java/org/onap/aai/datarouter/policy/SpikeAutosuggestIndexProcessor.java17
-rw-r--r--src/main/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicy.java5
-rw-r--r--src/main/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyConfig.java22
-rw-r--r--src/main/java/org/onap/aai/datarouter/policy/SpikeEventPolicyConfig.java22
-rw-r--r--src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyTest.java130
-rw-r--r--src/test/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessorTest.java25
-rw-r--r--src/test/java/org/onap/aai/datarouter/policy/SpikeAutosuggestProcessorTest.java16
-rw-r--r--src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyTest.java18
-rw-r--r--src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorTest.java25
-rw-r--r--src/test/resources/config/schemaIngest.properties16
-rw-r--r--src/test/resources/oxm-reader/multiple-oxm/v11/aai_oxm_v11.xml (renamed from src/test/resources/oxm-reader/multiple-oxm/aai_oxm_v11.xml)0
-rw-r--r--src/test/resources/oxm-reader/multiple-oxm/v12/aai_oxm_v12.xml (renamed from src/test/resources/oxm-reader/multiple-oxm/aai_oxm_v12.xml)0
-rw-r--r--src/test/resources/oxm-reader/multiple-oxm/v13/aai_oxm_a_v13.xml (renamed from src/test/resources/oxm-reader/multiple-oxm/aai_oxm_a_v13.xml)0
-rw-r--r--src/test/resources/oxm-reader/multiple-oxm/v13/aai_oxm_b_v13.xml (renamed from src/test/resources/oxm-reader/multiple-oxm/aai_oxm_b_v13.xml)0
-rw-r--r--src/test/resources/oxm-reader/oxm/v10/aai_oxm_v10.xml (renamed from src/test/resources/oxm-reader/oxm/aai_oxm_v10.xml)0
-rw-r--r--src/test/resources/oxm-reader/oxm/v11/aai_oxm_v11.xml (renamed from src/test/resources/oxm-reader/oxm/aai_oxm_v11.xml)0
-rw-r--r--src/test/resources/oxm-reader/oxm/v12/aai_oxm_v12.xml (renamed from src/test/resources/oxm-reader/oxm/aai_oxm_v12.xml)0
-rw-r--r--src/test/resources/oxm-reader/oxm/v13/aai_oxm_v13.xml (renamed from src/test/resources/oxm-reader/oxm/aai_oxm_v13.xml)0
-rw-r--r--src/test/resources/oxm-reader/oxm/v8/aai_oxm_v8.xml (renamed from src/test/resources/oxm-reader/oxm/aai_oxm_v8.xml)0
-rw-r--r--src/test/resources/oxm-reader/oxm/v9/aai_oxm_v9.xml (renamed from src/test/resources/oxm-reader/oxm/aai_oxm_v9.xml)0
-rw-r--r--src/test/resources/spring-beans/data-router-oxm.xml14
27 files changed, 391 insertions, 220 deletions
diff --git a/pom.xml b/pom.xml
index 189bec4..0a96ad3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,6 +68,7 @@ limitations under the License.
<sonar.projectVersion>${project.version}</sonar.projectVersion>
<logback.version>1.2.3</logback.version>
<version.com.google.guava>16.0.1</version.com.google.guava>
+ <shemaUnpackVersion>onap</shemaUnpackVersion>
</properties>
<dependencies>
@@ -192,6 +193,12 @@ limitations under the License.
</dependency>
<dependency>
+ <groupId>org.onap.aai.aai-common</groupId>
+ <artifactId>aai-schema-ingest</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
@@ -393,10 +400,10 @@ limitations under the License.
<artifactItem>
<groupId>org.onap.aai.aai-common</groupId>
<artifactId>aai-schema</artifactId>
- <version>1.2.2</version>
+ <version>1.3.0-SNAPSHOT</version>
<type>jar</type>
- <includes>oxm/</includes>
- <outputDirectory>${project.build.directory}/bundleconfig-local/etc</outputDirectory>
+ <includes>/${shemaUnpackVersion}/oxm/</includes>
+ <outputDirectory>${project.build.directory}/oxm</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile
index e417ead..00827e3 100644
--- a/src/main/docker/Dockerfile
+++ b/src/main/docker/Dockerfile
@@ -27,6 +27,7 @@ ENV CONFIG_HOME=${CONFIG_HOME}
COPY data-router.jar $MICRO_HOME/
COPY bundleconfig-local $MICRO_HOME/bundleconfig
COPY bundleconfig-local/etc/logback.xml $MICRO_HOME/bundleconfig/etc
+COPY oxm $MICRO_HOME/
EXPOSE 9502 9502
diff --git a/src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java b/src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java
index 50d344b..9f96a22 100644
--- a/src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java
+++ b/src/main/java/org/onap/aai/datarouter/policy/AbstractSpikeEntityEventProcessor.java
@@ -26,7 +26,6 @@ import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -59,6 +58,7 @@ import org.onap.aai.util.VersionedOxmEntities;
import org.onap.aai.restclient.client.Headers;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.restclient.rest.HttpUtil;
+import org.onap.aai.setup.SchemaVersions;
import org.slf4j.MDC;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -109,8 +109,7 @@ public abstract class AbstractSpikeEntityEventProcessor implements Processor {
protected Logger logger;
protected Logger metricsLogger;
protected ObjectMapper mapper;
-
-
+
public AbstractSpikeEntityEventProcessor(SpikeEventPolicyConfig config)
throws FileNotFoundException {
mapper = new ObjectMapper();
@@ -128,7 +127,7 @@ public abstract class AbstractSpikeEntityEventProcessor implements Processor {
this.externalOxmModelProcessors = new ArrayList<>();
this.externalOxmModelProcessors.add(EntityOxmReferenceHelper.getInstance());
OxmModelLoader.registerExternalOxmModelProcessors(externalOxmModelProcessors);
- OxmModelLoader.loadModels();
+ OxmModelLoader.loadModels(config.getSchemaVersions(), config.getSchemaLocationsBean());
oxmVersionContextMap = OxmModelLoader.getVersionContextMap();
parseLatestOxmVersion();
}
@@ -906,21 +905,4 @@ public abstract class AbstractSpikeEntityEventProcessor implements Processor {
}
- protected List<String> extractSuggestableAttr(VersionedOxmEntities oxmEntities, String entityType) {
- // Extract suggestable attributeshandleTopographicalData
- Map<String, OxmEntityDescriptor> rootDescriptor = oxmEntities.getSuggestableEntityDescriptors();
-
- if (rootDescriptor == null) {
- return Collections.emptyList();
- }
-
- OxmEntityDescriptor desc = rootDescriptor.get(entityType);
-
- if (desc == null) {
- return Collections.emptyList();
- }
-
- return desc.getSuggestableAttributes();
- }
-
}
diff --git a/src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicy.java b/src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicy.java
index b6b7fd8..6660a79 100644
--- a/src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicy.java
+++ b/src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicy.java
@@ -56,6 +56,7 @@ import org.onap.aai.util.CrossEntityReference;
import org.onap.aai.util.EntityOxmReferenceHelper;
import org.onap.aai.util.ExternalOxmModelProcessor;
import org.onap.aai.schema.OxmModelLoader;
+import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.Version;
import org.onap.aai.util.VersionedOxmEntities;
import org.onap.aai.cl.api.Logger;
@@ -96,16 +97,16 @@ public class EntityEventPolicy implements Processor {
/** Agent for communicating with the Search Service. */
private SearchServiceAgent searchAgent = null;
-
+
/** Search index name for storing AAI event entities. */
private String entitySearchIndex;
/** Search index name for storing topographical search data. */
private String topographicalSearchIndex;
-
+
/** Search index name for suggestive search data. */
private String aggregateGenericVnfIndex;
-
+
private String autosuggestIndex;
private String srcDomain;
@@ -130,7 +131,7 @@ public class EntityEventPolicy implements Processor {
topographicalSearchIndex = config.getSearchTopographySearchIndex();
aggregateGenericVnfIndex = config.getSearchAggregationVnfIndex();
autosuggestIndex = config.getSearchEntityAutoSuggestIndex();
-
+
// Instantiate the agent that we will use for interacting with the Search Service.
searchAgent = new SearchServiceAgent(config.getSearchCertName(),
config.getSearchKeystore(),
@@ -143,7 +144,7 @@ public class EntityEventPolicy implements Processor {
this.externalOxmModelProcessors = new ArrayList<>();
this.externalOxmModelProcessors.add(EntityOxmReferenceHelper.getInstance());
OxmModelLoader.registerExternalOxmModelProcessors(externalOxmModelProcessors);
- OxmModelLoader.loadModels();
+ OxmModelLoader.loadModels(config.getSchemaVersions(), config.getSchemaLocationsBean());
oxmVersionContextMap = OxmModelLoader.getVersionContextMap();
parseLatestOxmVersion();
}
@@ -171,11 +172,11 @@ public class EntityEventPolicy implements Processor {
}
public void startup() {
-
+
// Create the indexes in the search service if they do not already exist.
searchAgent.createSearchIndex(entitySearchIndex, ENTITY_SEARCH_SCHEMA);
searchAgent.createSearchIndex(topographicalSearchIndex, TOPOGRAPHICAL_SEARCH_SCHEMA);
-
+
logger.info(EntityEventPolicyMsgs.ENTITY_EVENT_POLICY_REGISTERED);
}
@@ -207,7 +208,7 @@ public class EntityEventPolicy implements Processor {
logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE, errorMsg, payload);
setResponse(exchange, ResponseType.FAILURE, additionalInfo);
}
-
+
@Override
public void process(Exchange exchange) throws Exception {
@@ -215,7 +216,7 @@ public class EntityEventPolicy implements Processor {
String uebPayload = exchange.getIn().getBody().toString();
- JsonNode uebAsJson =null;
+ JsonNode uebAsJson = null;
ObjectMapper mapper = new ObjectMapper();
try{
uebAsJson = mapper.readTree(uebPayload);
@@ -230,7 +231,7 @@ public class EntityEventPolicy implements Processor {
returnWithError(exchange, uebPayload, "Payload is missing " + EVENT_HEADER);
return;
}
-
+
JSONObject uebObjEntity = getUebContentAsJson(uebPayload, ENTITY_HEADER);
if (uebObjEntity == null) {
returnWithError(exchange, uebPayload, "Payload is missing " + ENTITY_HEADER);
@@ -392,14 +393,14 @@ public class EntityEventPolicy implements Processor {
* NOTES:
* 1. If the entity type is "customer", the below check will return true if any nested entityType
* in that model could contain a CER based on the OXM model version that has been loaded.
- * 2. For a DELETE operation on outer/parent entity (handled by the regular flow:
+ * 2. For a DELETE operation on outer/parent entity (handled by the regular flow:
* handleSearchServiceOperation()), ignore processing for cross-entity-reference under the
* assumption that AAI will push down all required cascade-deletes for nested entities as well
* 3. Handling the case where UEB events arrive out of order: CREATE customer is received before
* CREATE service-instance.
*/
- if (!action.equalsIgnoreCase(ACTION_DELETE) && oxmEntities != null
+ if (!action.equalsIgnoreCase(ACTION_DELETE) && oxmEntities != null
&& oxmEntities.entityModelContainsCrossEntityReference(topEntityType)) {
// We know the model "can" contain a CER reference definition, let's process a bit more
@@ -409,116 +410,122 @@ public class EntityEventPolicy implements Processor {
JSONObject entityJsonObject = getUebEntity(uebPayload);
- if (entityJsonObject != null) {
- JsonNode entityJsonNode = convertToJsonNode(entityJsonObject.toString());
-
- String parentEntityType = entityType;
-
- String targetEntityUrl = entityLink;
+ JsonNode entityJsonNode = convertToJsonNode(entityJsonObject.toString());
+
+ String parentEntityType = entityType;
+
+ String targetEntityUrl = entityLink;
- for (Map.Entry<String, CrossEntityReference> entry : crossEntityRefMap.entrySet()) {
+ for (Map.Entry<String, CrossEntityReference> entry : crossEntityRefMap.entrySet()) {
- /*
- * if we know service-subscription is in the tree, then we can pull our all instances and process
- * from there.
- */
-
- String key = entry.getKey();
- CrossEntityReference cerDescriptor = entry.getValue();
-
- ArrayList<JsonNode> foundNodes = new ArrayList<>();
+ /*
+ * if we know service-subscription is in the tree, then we can pull our all instances and
+ * process from there.
+ */
- RouterServiceUtil.extractObjectsByKey(entityJsonNode, key, foundNodes);
+ String key = entry.getKey();
+ CrossEntityReference cerDescriptor = entry.getValue();
- if (!foundNodes.isEmpty()) {
+ ArrayList<JsonNode> foundNodes = new ArrayList<>();
- for (JsonNode n : foundNodes) {
- if ("customer".equalsIgnoreCase(parentEntityType)) {
- /*
- * NOTES: 1. prepare to hand-create url for service-instance 2. this will break if the
- * URL structure for service-instance changes
- */
- if (n.has("service-type")) {
- targetEntityUrl += "/service-subscriptions/service-subscription/"
- + RouterServiceUtil.getNodeFieldAsText(n, "service-type")
- + "/service-instances/service-instance/";
- }
- }
+ RouterServiceUtil.extractObjectsByKey(entityJsonNode, key, foundNodes);
- List<String> extractedParentEntityAttributeValues = new ArrayList<>();
+ if (!foundNodes.isEmpty()) {
- RouterServiceUtil.extractFieldValuesFromObject(n, cerDescriptor.getAttributeNames(),
- extractedParentEntityAttributeValues);
+ for (JsonNode n : foundNodes) {
+ if ("customer".equalsIgnoreCase(parentEntityType)){
+ /*
+ * NOTES:
+ * 1. prepare to hand-create url for service-instance
+ * 2. this will break if the URL structure for service-instance changes
+ */
+ if (n.has("service-type")){
+ targetEntityUrl += "/service-subscriptions/service-subscription/"
+ + RouterServiceUtil.getNodeFieldAsText(n, "service-type")
+ + "/service-instances/service-instance/";
+ }
+
+ }
- List<JsonNode> nestedTargetEntityInstances = new ArrayList<>();
- RouterServiceUtil.extractObjectsByKey(n, cerDescriptor.getTargetEntityType(),
- nestedTargetEntityInstances);
+ List<String> extractedParentEntityAttributeValues = new ArrayList<>();
- for (JsonNode targetEntityInstance : nestedTargetEntityInstances) {
- /*
- * Now: 1. build the AAIEntityType (IndexDocument) based on the extract entity 2. Get
- * data from ES 3. Extract ETAG 4. Merge ES Doc + AAIEntityType + Extracted Parent
- * Cross-Entity-Reference Values 5. Put data into ES with ETAG + updated doc
- */
+ RouterServiceUtil.extractFieldValuesFromObject(n, cerDescriptor.getAttributeNames(),
+ extractedParentEntityAttributeValues);
- // Get the complete URL for target entity
- if (targetEntityInstance.has("link")) { // nested SI has url mentioned
- targetEntityUrl = RouterServiceUtil.getNodeFieldAsText(targetEntityInstance, "link");
- } else if ("customer".equalsIgnoreCase(parentEntityType) && targetEntityInstance.has("service-instance-id")) {
- targetEntityUrl += RouterServiceUtil.getNodeFieldAsText(targetEntityInstance, "service-instance-id");
- }
+ List<JsonNode> nestedTargetEntityInstances = new ArrayList<>();
+ RouterServiceUtil.extractObjectsByKey(n, cerDescriptor.getTargetEntityType(),
+ nestedTargetEntityInstances);
- OxmEntityDescriptor searchableDescriptor = oxmEntities.getSearchableEntityDescriptor(cerDescriptor.getTargetEntityType());
+ for (JsonNode targetEntityInstance : nestedTargetEntityInstances) {
+ /*
+ * Now:
+ * 1. build the AAIEntityType (IndexDocument) based on the extract entity
+ * 2. Get data from ES
+ * 3. Extract ETAG
+ * 4. Merge ES Doc + AAIEntityType + Extracted Parent Cross-Entity-Reference Values
+ * 5. Put data into ES with ETAG + updated doc
+ */
- if (searchableDescriptor != null) {
+ // Get the complete URL for target entity
+ if (targetEntityInstance.has("link")) { // nested SI has url mentioned
+ targetEntityUrl = RouterServiceUtil.getNodeFieldAsText(targetEntityInstance,
+ "link");
+ } else if ("customer".equalsIgnoreCase(parentEntityType) &&
+ targetEntityInstance.has("service-instance-id")){
+ targetEntityUrl += RouterServiceUtil.getNodeFieldAsText(targetEntityInstance,
+ "service-instance-id");
+ }
+
+ OxmEntityDescriptor searchableDescriptor =
+ oxmEntities.getSearchableEntityDescriptor(cerDescriptor.getTargetEntityType());
- if (!searchableDescriptor.getSearchableAttributes().isEmpty()) {
+ if (searchableDescriptor != null) {
- AaiEventEntity entityToSync = null;
+ if (!searchableDescriptor.getSearchableAttributes().isEmpty()) {
- try {
+ AaiEventEntity entityToSync = null;
- entityToSync = getPopulatedEntity(targetEntityInstance, searchableDescriptor);
+ try {
- /*
- * Ready to do some ElasticSearch ops
- */
+ entityToSync = getPopulatedEntity(targetEntityInstance, searchableDescriptor);
- for (String parentCrossEntityReferenceAttributeValue : extractedParentEntityAttributeValues) {
- entityToSync.addCrossEntityReferenceValue(parentCrossEntityReferenceAttributeValue);
- }
+ /*
+ * Ready to do some ElasticSearch ops
+ */
- entityToSync.setLink(targetEntityUrl);
- entityToSync.deriveFields();
+ for (String parentCrossEntityReferenceAttributeValue : extractedParentEntityAttributeValues) {
+ entityToSync
+ .addCrossEntityReferenceValue(parentCrossEntityReferenceAttributeValue);
+ }
- updateCerInEntity(entityToSync);
+ entityToSync.setLink(targetEntityUrl);
+ entityToSync.deriveFields();
- } catch (NoSuchAlgorithmException e) {
- logger.debug(e.getMessage());
- }
- }
- } else {
- logger.debug(EntityEventPolicyMsgs.CROSS_ENTITY_REFERENCE_SYNC,
- "failure to find searchable descriptor for type "
- + cerDescriptor.getTargetEntityType());
- }
- }
+ updateCerInEntity(entityToSync);
+ } catch (NoSuchAlgorithmException e) {
+ logger.debug(e.getMessage());
}
-
+ }
} else {
- logger.debug(EntityEventPolicyMsgs.CROSS_ENTITY_REFERENCE_SYNC,
- "failed to find 0 instances of cross-entity-reference with entity " + key);
+ logger.debug(EntityEventPolicyMsgs.CROSS_ENTITY_REFERENCE_SYNC,
+ "failure to find searchable descriptor for type "
+ + cerDescriptor.getTargetEntityType());
}
+ }
}
- } else {
- logger.info(EntityEventPolicyMsgs.FAILED_TO_PARSE_UEB_PAYLOAD, "Unable to get UEB object");
+
+ } else {
+ logger.debug(EntityEventPolicyMsgs.CROSS_ENTITY_REFERENCE_SYNC,
+ "failed to find 0 instances of cross-entity-reference with entity " + key);
+ }
+
}
} else {
- logger.info(EntityEventPolicyMsgs.CROSS_ENTITY_REFERENCE_SYNC, "skipped due to OXM model for "
- + topEntityType + " does not contain a cross-entity-reference entity");
+ logger.info(EntityEventPolicyMsgs.CROSS_ENTITY_REFERENCE_SYNC, "skipped due to OXM model for "
+ + topEntityType + " does not contain a cross-entity-reference entity");
}
/*
@@ -603,7 +610,7 @@ public class EntityEventPolicy implements Processor {
}
OxmEntityDescriptor desc = rootDescriptor.get(entityType);
-
+
if (desc == null) {
return Collections.emptyList();
}
@@ -878,11 +885,11 @@ public class EntityEventPolicy implements Processor {
if (HttpUtil.isHttpResponseClassSuccess(storedEntity.getResultCode())) {
/*
- * NOTES: aaiEventEntity (ie the nested entity) may contain a subset of properties of
- * the pre-existing object,
+ * NOTES: aaiEventEntity (ie the nested entity) may contain a subset of properties of
+ * the pre-existing object,
* so all we want to do is update the CER on the pre-existing object (if needed).
*/
-
+
List<String> etag = storedEntity.getHeaders().get(Headers.ETAG);
if (etag != null && !etag.isEmpty()) {
@@ -891,7 +898,7 @@ public class EntityEventPolicy implements Processor {
logger.error(EntityEventPolicyMsgs.NO_ETAG_AVAILABLE_FAILURE,
entitySearchIndex, entityId);
}
-
+
ArrayList<JsonNode> sourceObject = new ArrayList<>();
NodeUtils.extractObjectsByKey(
NodeUtils.convertJsonStrToJsonNode(storedEntity.getResult()),
@@ -899,7 +906,7 @@ public class EntityEventPolicy implements Processor {
if (!sourceObject.isEmpty()) {
JsonNode node = sourceObject.get(0);
- final String sourceCer = NodeUtils.extractFieldValueFromObject(node,
+ final String sourceCer = NodeUtils.extractFieldValueFromObject(node,
"crossEntityReferenceValues");
String newCer = aaiEventEntity.getCrossReferenceEntityValues();
boolean hasNewCer = true;
@@ -910,7 +917,7 @@ public class EntityEventPolicy implements Processor {
hasNewCer = false;
}
}
-
+
if (hasNewCer){
// Do the PUT with new CER
((ObjectNode)node).put("crossEntityReferenceValues", newCer);
@@ -937,13 +944,13 @@ public class EntityEventPolicy implements Processor {
/**
* Perform create, read, update or delete (CRUD) operation on search engine's suggestive search
* index
- *
+ *
* @param eventEntity Entity/data to use in operation
* @param action The operation to perform
* @param target Resource to perform the operation on
* @param allowDeleteEvent Allow delete operation to be performed on resource
*/
- protected void handleSearchServiceOperation(DocumentStoreDataEntity eventEntity,
+ protected void handleSearchServiceOperation(DocumentStoreDataEntity eventEntity,
String action,
String index) {
try {
@@ -977,7 +984,7 @@ public class EntityEventPolicy implements Processor {
} else if (action.equalsIgnoreCase(ACTION_CREATE)) {
// Write the entry to the search service.
searchAgent.postDocument(index, eventEntity.getAsJson(), headers);
-
+
} else if (action.equalsIgnoreCase(ACTION_DELETE)) {
// Run the GET to retrieve the ETAG from the search service
OperationResult storedEntity = searchAgent.getDocument(index, entityId);
@@ -991,7 +998,7 @@ public class EntityEventPolicy implements Processor {
logger.error(EntityEventPolicyMsgs.NO_ETAG_AVAILABLE_FAILURE, index,
entityId);
}
-
+
/*
* The Spring-Boot version of the search-data-service rejects the DELETE operation unless
* we specify a Content-Type.
@@ -1063,7 +1070,7 @@ public class EntityEventPolicy implements Processor {
// put this here until we find a better spot
/**
* Helper utility to concatenate substrings of a URI together to form a proper URI.
- *
+ *
* @param suburis the list of substrings to concatenate together
* @return the concatenated list of substrings
*/
diff --git a/src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicyConfig.java b/src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicyConfig.java
index 826a419..ec45b74 100644
--- a/src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicyConfig.java
+++ b/src/main/java/org/onap/aai/datarouter/policy/EntityEventPolicyConfig.java
@@ -20,6 +20,9 @@
*/
package org.onap.aai.datarouter.policy;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersions;
+
public class EntityEventPolicyConfig {
private String sourceDomain;
@@ -33,6 +36,8 @@ public class EntityEventPolicyConfig {
private String searchCertName;
private String searchKeystorePwd;
private String searchKeystore;
+ private SchemaVersions schemaVersions;
+ private SchemaLocationsBean schemaLocationsBean;
public String getSourceDomain() {
@@ -122,4 +127,20 @@ public class EntityEventPolicyConfig {
public void setSearchAggregationVnfIndex(String searchAggregationVnfIndex) {
this.searchAggregationVnfIndex = searchAggregationVnfIndex;
}
+
+ public SchemaVersions getSchemaVersions() {
+ return schemaVersions;
+ }
+
+ public void setSchemaVersions(SchemaVersions schemaVersions) {
+ this.schemaVersions = schemaVersions;
+ }
+
+ public SchemaLocationsBean getSchemaLocationsBean() {
+ return schemaLocationsBean;
+ }
+
+ public void setSchemaLocationsBean(SchemaLocationsBean schemaLocationsBean) {
+ this.schemaLocationsBean = schemaLocationsBean;
+ }
}
diff --git a/src/main/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessor.java b/src/main/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessor.java
index c723d2b..b1a5a87 100644
--- a/src/main/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessor.java
+++ b/src/main/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessor.java
@@ -21,16 +21,12 @@
package org.onap.aai.datarouter.policy;
import java.io.FileNotFoundException;
-import java.util.ArrayList;
import java.util.List;
import org.apache.camel.Exchange;
import org.onap.aai.datarouter.entity.SpikeAggregationEntity;
import org.onap.aai.datarouter.entity.SpikeEventMeta;
import org.onap.aai.datarouter.logging.EntityEventPolicyMsgs;
-import org.onap.aai.util.EntityOxmReferenceHelper;
-import org.onap.aai.util.Version;
-import org.onap.aai.util.VersionedOxmEntities;
import com.fasterxml.jackson.databind.JsonNode;
@@ -49,36 +45,25 @@ public class SpikeAggregateGenericVnfProcessor extends AbstractSpikeEntityEventP
// Create the indexes in the search service if they do not already exist.
searchAgent.createSearchIndex(searchIndexName, searchIndexSchema, createIndexUrl);
logger.info(EntityEventPolicyMsgs.ENTITY_EVENT_POLICY_REGISTERED);
-
}
-
+
@Override
public void process(Exchange exchange) throws Exception {
long startTime = System.currentTimeMillis();
SpikeEventMeta meta = processSpikeEvent(exchange);
-
+
if (meta == null) {
return;
}
String oxmEntityType = getOxmEntityType(meta.getSpikeEventVertex().getType());
-
- VersionedOxmEntities oxmEntities =
- EntityOxmReferenceHelper.getInstance().getVersionedOxmEntities(Version.valueOf(oxmVersion.toLowerCase()));
-
- List<String> suggestibleAttrInPayload = new ArrayList<>();
- List<String> suggestibleAttrInOxm = extractSuggestableAttr(oxmEntities, meta.getSpikeEventVertex().getType());
- if (suggestibleAttrInOxm != null) {
- for (String attr: suggestibleAttrInOxm){
- if (meta.getVertexProperties().has(attr)) {
- suggestibleAttrInPayload.add(attr);
- }
- }
- }
- if (suggestibleAttrInPayload.isEmpty()) {
+ List<String> searchableAttr = getSearchableAttibutes(meta.getOxmJaxbContext(), oxmEntityType,
+ meta.getSpikeEventVertex().getType(), meta.getEventEntity().toString(), exchange);
+
+ if (searchableAttr == null) {
return;
}
diff --git a/src/main/java/org/onap/aai/datarouter/policy/SpikeAutosuggestIndexProcessor.java b/src/main/java/org/onap/aai/datarouter/policy/SpikeAutosuggestIndexProcessor.java
index c101425..b2f9202 100644
--- a/src/main/java/org/onap/aai/datarouter/policy/SpikeAutosuggestIndexProcessor.java
+++ b/src/main/java/org/onap/aai/datarouter/policy/SpikeAutosuggestIndexProcessor.java
@@ -141,6 +141,23 @@ public class SpikeAutosuggestIndexProcessor extends AbstractSpikeEntityEventProc
return;
}
+ public List<String> extractSuggestableAttr(VersionedOxmEntities oxmEntities, String entityType) {
+ // Extract suggestable attributeshandleTopographicalData
+ Map<String, OxmEntityDescriptor> rootDescriptor = oxmEntities.getSuggestableEntityDescriptors();
+
+ if (rootDescriptor == null) {
+ return Collections.emptyList();
+ }
+
+ OxmEntityDescriptor desc = rootDescriptor.get(entityType);
+
+ if (desc == null) {
+ return Collections.emptyList();
+ }
+
+ return desc.getSuggestableAttributes();
+ }
+
public List<String> extractAliasForSuggestableEntity(VersionedOxmEntities oxmEntities,
String entityType) {
diff --git a/src/main/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicy.java b/src/main/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicy.java
index 9826743..649fe6b 100644
--- a/src/main/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicy.java
+++ b/src/main/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicy.java
@@ -53,6 +53,7 @@ import org.onap.aai.entity.OxmEntityDescriptor;
import org.onap.aai.util.EntityOxmReferenceHelper;
import org.onap.aai.util.ExternalOxmModelProcessor;
import org.onap.aai.schema.OxmModelLoader;
+import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.restclient.client.Headers;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.restclient.rest.HttpUtil;
@@ -112,7 +113,7 @@ public class SpikeEntityEventPolicy implements Processor {
private Logger logger;
private Logger metricsLogger;
-
+
public enum ResponseType {
SUCCESS, PARTIAL_SUCCESS, FAILURE;
};
@@ -137,7 +138,7 @@ public class SpikeEntityEventPolicy implements Processor {
this.externalOxmModelProcessors = new ArrayList<>();
this.externalOxmModelProcessors.add(EntityOxmReferenceHelper.getInstance());
OxmModelLoader.registerExternalOxmModelProcessors(externalOxmModelProcessors);
- OxmModelLoader.loadModels();
+ OxmModelLoader.loadModels(config.getSchemaVersions(), config.getSchemaLocationsBean());
oxmVersionContextMap = OxmModelLoader.getVersionContextMap();
parseLatestOxmVersion();
}
diff --git a/src/main/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyConfig.java b/src/main/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyConfig.java
index 0005119..cc90e89 100644
--- a/src/main/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyConfig.java
+++ b/src/main/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyConfig.java
@@ -20,6 +20,9 @@
*/
package org.onap.aai.datarouter.policy;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersions;
+
public class SpikeEntityEventPolicyConfig {
private String sourceDomain;
@@ -30,7 +33,8 @@ public class SpikeEntityEventPolicyConfig {
private String searchCertName;
private String searchKeystorePwd;
private String searchKeystore;
-
+ private SchemaVersions schemaVersions;
+ private SchemaLocationsBean schemaLocationsBean;
public String getSourceDomain() {
return sourceDomain;
@@ -94,4 +98,20 @@ public class SpikeEntityEventPolicyConfig {
public void setSearchKeystorePwd(String searchKeystorePwd) {
this.searchKeystorePwd = searchKeystorePwd;
}
+
+ public SchemaVersions getSchemaVersions() {
+ return schemaVersions;
+ }
+
+ public void setSchemaVersions(SchemaVersions schemaVersions) {
+ this.schemaVersions = schemaVersions;
+ }
+
+ public SchemaLocationsBean getSchemaLocationsBean() {
+ return schemaLocationsBean;
+ }
+
+ public void setSchemaLocationsBean(SchemaLocationsBean schemaLocationsBean) {
+ this.schemaLocationsBean = schemaLocationsBean;
+ }
}
diff --git a/src/main/java/org/onap/aai/datarouter/policy/SpikeEventPolicyConfig.java b/src/main/java/org/onap/aai/datarouter/policy/SpikeEventPolicyConfig.java
index 55db200..6c4fb95 100644
--- a/src/main/java/org/onap/aai/datarouter/policy/SpikeEventPolicyConfig.java
+++ b/src/main/java/org/onap/aai/datarouter/policy/SpikeEventPolicyConfig.java
@@ -20,6 +20,9 @@
*/
package org.onap.aai.datarouter.policy;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersions;
+
public class SpikeEventPolicyConfig {
private String sourceDomain;
@@ -29,7 +32,8 @@ public class SpikeEventPolicyConfig {
private String searchCertName;
private String searchKeystorePwd;
private String searchKeystore;
-
+ private SchemaVersions schemaVersions;
+ private SchemaLocationsBean schemaLocationsBean;
public String getSourceDomain() {
return sourceDomain;
@@ -87,4 +91,20 @@ public class SpikeEventPolicyConfig {
public void setSearchKeystorePwd(String searchKeystorePwd) {
this.searchKeystorePwd = searchKeystorePwd;
}
+
+ public SchemaVersions getSchemaVersions() {
+ return schemaVersions;
+ }
+
+ public void setSchemaVersions(SchemaVersions schemaVersions) {
+ this.schemaVersions = schemaVersions;
+ }
+
+ public SchemaLocationsBean getSchemaLocationsBean() {
+ return schemaLocationsBean;
+ }
+
+ public void setSchemaLocationsBean(SchemaLocationsBean schemaLocationsBean) {
+ this.schemaLocationsBean = schemaLocationsBean;
+ }
}
diff --git a/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyTest.java b/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyTest.java
index adf8ce2..b76e7ee 100644
--- a/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyTest.java
+++ b/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyTest.java
@@ -20,7 +20,8 @@
*/
package org.onap.aai.datarouter.policy;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
@@ -32,67 +33,80 @@ import org.apache.camel.Message;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
-import org.onap.aai.datarouter.policy.EntityEventPolicy;
-import org.onap.aai.datarouter.policy.EntityEventPolicyConfig;
+import org.junit.runner.RunWith;
import org.onap.aai.datarouter.util.NodeUtils;
-import org.onap.aai.datarouter.util.SearchServiceAgent;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersions;
import org.powermock.api.mockito.PowerMockito;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml")
public class EntityEventPolicyTest {
- private EntityEventPolicy policy;
- private String eventJson;
- private InMemorySearchDatastore searchDb;
-
- @SuppressWarnings("unchecked")
- @Before
- public void init() throws Exception {
- EntityEventPolicyConfig config = PowerMockito.mock(EntityEventPolicyConfig.class);
- PowerMockito.when(config.getSearchKeystorePwd()).thenReturn("password");
- PowerMockito.when(config.getSourceDomain()).thenReturn("JUNIT");
-
- searchDb = new InMemorySearchDatastore();
- policy = new EntityEventPolicyStubbed(config).withSearchDb(searchDb);
-
- FileInputStream event = new FileInputStream( new File("src/test/resources/aai_event.json"));
- eventJson = IOUtils.toString(event, "UTF-8");
-
- }
-
- @Test
- public void testProcess() throws Exception {
- policy.process(getExchangeEvent("event1","create"));
- policy.process(getExchangeEvent("event2","create"));
-
- assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event1")));
- assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event2")));
-
- policy.process(getExchangeEvent("event1","update"));
- policy.process(getExchangeEvent("event2","update"));
- assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event1")));
- assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event2")));
-
- policy.process(getExchangeEvent("event2","delete"));
- assertNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event2")));
- }
-
- private Exchange getExchangeEvent(String link,String action){
- Object obj = eventJson.replace("$LINK",link ).replace("$ACTION",action) ;
- Exchange exchange = PowerMockito.mock(Exchange.class);
- Message inMessage = PowerMockito.mock(Message.class);
- Message outMessage = PowerMockito.mock(Message.class);
- PowerMockito.when(exchange.getIn()).thenReturn(inMessage);
- PowerMockito.when(inMessage.getBody()).thenReturn(obj);
-
- PowerMockito.when(exchange.getOut()).thenReturn(outMessage);
- PowerMockito.doNothing().when(outMessage).setBody(anyObject());
- PowerMockito.doNothing().when(outMessage).setHeader(anyString(), anyObject());
-
- return exchange;
-
- }
-
-
+ private EntityEventPolicyConfig eventPolicyConfig;
+ private EntityEventPolicy policy;
+ private String eventJson;
+ private InMemorySearchDatastore searchDb;
+
+ @Autowired
+ private SchemaVersions schemaVersions;
+ @Autowired
+ private SchemaLocationsBean schemaLocationsBean;
+
+ @SuppressWarnings("unchecked")
+ @Before
+ public void init() throws Exception {
+ eventPolicyConfig = new EntityEventPolicyConfig();
+ eventPolicyConfig.setSearchKeystorePwd("password");
+ eventPolicyConfig.setSourceDomain("JUNIT");
+
+ eventPolicyConfig.setSchemaVersions(schemaVersions);
+ eventPolicyConfig.setSchemaLocationsBean(schemaLocationsBean);
+
+ searchDb = new InMemorySearchDatastore();
+ policy = new EntityEventPolicyStubbed(eventPolicyConfig).withSearchDb(searchDb);
+
+ FileInputStream event = new FileInputStream(new File("src/test/resources/aai_event.json"));
+ eventJson = IOUtils.toString(event, "UTF-8");
+
+ }
+
+ @Test
+ public void testProcess() throws Exception {
+ policy.process(getExchangeEvent("event1", "create"));
+ policy.process(getExchangeEvent("event2", "create"));
+
+ assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event1")));
+ assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event2")));
+
+ policy.process(getExchangeEvent("event1", "update"));
+ policy.process(getExchangeEvent("event2", "update"));
+ assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event1")));
+ assertNotNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event2")));
+
+ policy.process(getExchangeEvent("event2", "delete"));
+ assertNull(searchDb.get(NodeUtils.generateUniqueShaDigest("event2")));
+ }
+
+ private Exchange getExchangeEvent(String link, String action) {
+ Object obj = eventJson.replace("$LINK", link).replace("$ACTION", action);
+ Exchange exchange = PowerMockito.mock(Exchange.class);
+ Message inMessage = PowerMockito.mock(Message.class);
+ Message outMessage = PowerMockito.mock(Message.class);
+ PowerMockito.when(exchange.getIn()).thenReturn(inMessage);
+ PowerMockito.when(inMessage.getBody()).thenReturn(obj);
+
+ PowerMockito.when(exchange.getOut()).thenReturn(outMessage);
+ PowerMockito.doNothing().when(outMessage).setBody(anyObject());
+ PowerMockito.doNothing().when(outMessage).setHeader(anyString(), anyObject());
+
+ return exchange;
+
+ }
+
+
}
diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessorTest.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessorTest.java
index 03970bd..cf9f013 100644
--- a/src/test/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessorTest.java
+++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessorTest.java
@@ -33,21 +33,38 @@ import org.apache.camel.Message;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.onap.aai.datarouter.util.NodeUtils;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersions;
import org.powermock.api.mockito.PowerMockito;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml")
public class SpikeAggregateGenericVnfProcessorTest {
+ private SpikeEventPolicyConfig eventPolicyConfig;
private SpikeAggregateGenericVnfProcessor policy;
private InMemorySearchDatastore searchDb;
+ @Autowired
+ private SchemaVersions schemaVersions;
+ @Autowired
+ private SchemaLocationsBean schemaLocationsBean;
+
@Before
public void init() throws Exception {
- SpikeEventPolicyConfig config = PowerMockito.mock(SpikeEventPolicyConfig.class);
- PowerMockito.when(config.getSearchKeystorePwd()).thenReturn("password");
- PowerMockito.when(config.getSourceDomain()).thenReturn("JUNIT");
+ eventPolicyConfig = new SpikeEventPolicyConfig();
+ eventPolicyConfig.setSearchKeystorePwd("password");
+ eventPolicyConfig.setSourceDomain("JUNIT");
+
+ eventPolicyConfig.setSchemaVersions(schemaVersions);
+ eventPolicyConfig.setSchemaLocationsBean(schemaLocationsBean);
searchDb = new InMemorySearchDatastore();
- policy = new SpikeAggregateGenericVnfProcessorStubbed(config).withSearchDb(searchDb);
+ policy = new SpikeAggregateGenericVnfProcessorStubbed(eventPolicyConfig).withSearchDb(searchDb);
}
@Test
diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeAutosuggestProcessorTest.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeAutosuggestProcessorTest.java
index c49f17b..6791ac3 100644
--- a/src/test/java/org/onap/aai/datarouter/policy/SpikeAutosuggestProcessorTest.java
+++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeAutosuggestProcessorTest.java
@@ -33,14 +33,27 @@ import org.apache.camel.Message;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.onap.aai.datarouter.util.NodeUtils;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersions;
import org.powermock.api.mockito.PowerMockito;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml")
public class SpikeAutosuggestProcessorTest {
private SpikeEventPolicyConfig eventPolicyConfig;
private SpikeAutosuggestIndexProcessor policy;
private InMemorySearchDatastore searchDb;
+ @Autowired
+ private SchemaVersions schemaVersions;
+ @Autowired
+ private SchemaLocationsBean schemaLocationsBean;
+
@Before
public void init() throws Exception {
@@ -48,6 +61,9 @@ public class SpikeAutosuggestProcessorTest {
eventPolicyConfig.setSearchKeystorePwd("password");
eventPolicyConfig.setSourceDomain("JUNIT");
+ eventPolicyConfig.setSchemaVersions(schemaVersions);
+ eventPolicyConfig.setSchemaLocationsBean(schemaLocationsBean);
+
searchDb = new InMemorySearchDatastore();
policy = new SpikeAutosuggestProcessorStubbed(eventPolicyConfig).withSearchDb(searchDb);
diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyTest.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyTest.java
index 68edb74..b78ba0e 100644
--- a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyTest.java
+++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyTest.java
@@ -20,7 +20,8 @@
*/
package org.onap.aai.datarouter.policy;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
@@ -32,14 +33,26 @@ import org.apache.camel.Message;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.onap.aai.datarouter.util.NodeUtils;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersions;
import org.powermock.api.mockito.PowerMockito;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml")
public class SpikeEntityEventPolicyTest {
private SpikeEntityEventPolicyConfig eventPolicyConfig;
private SpikeEntityEventPolicy policy;
private InMemorySearchDatastore searchDb;
+ @Autowired
+ private SchemaVersions schemaVersions;
+ @Autowired
+ private SchemaLocationsBean schemaLocationsBean;
@Before
public void init() throws Exception {
@@ -47,6 +60,9 @@ public class SpikeEntityEventPolicyTest {
eventPolicyConfig = new SpikeEntityEventPolicyConfig();
eventPolicyConfig.setSearchKeystorePwd("password");
eventPolicyConfig.setSourceDomain("JUNIT");
+
+ eventPolicyConfig.setSchemaVersions(schemaVersions);
+ eventPolicyConfig.setSchemaLocationsBean(schemaLocationsBean);
searchDb = new InMemorySearchDatastore();
policy = new SpikeEntityEventPolicyStubbed(eventPolicyConfig).withSearchDb(searchDb);
diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorTest.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorTest.java
index 5b40c1a..56af3ea 100644
--- a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorTest.java
+++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorTest.java
@@ -33,22 +33,39 @@ import org.apache.camel.Message;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.onap.aai.datarouter.util.NodeUtils;
+import org.onap.aai.setup.SchemaLocationsBean;
+import org.onap.aai.setup.SchemaVersions;
import org.powermock.api.mockito.PowerMockito;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml")
public class SpikeEntitySearchProcessorTest {
+ private SpikeEventPolicyConfig eventPolicyConfig;
private SpikeEntitySearchProcessor policy;
private String eventJson;
private InMemorySearchDatastore searchDb;
+ @Autowired
+ private SchemaVersions schemaVersions;
+ @Autowired
+ private SchemaLocationsBean schemaLocationsBean;
+
@Before
public void init() throws Exception {
- SpikeEventPolicyConfig config = PowerMockito.mock(SpikeEventPolicyConfig.class);
- PowerMockito.when(config.getSearchKeystorePwd()).thenReturn("password");
- PowerMockito.when(config.getSourceDomain()).thenReturn("JUNIT");
+ eventPolicyConfig = new SpikeEventPolicyConfig();
+ eventPolicyConfig.setSearchKeystorePwd("password");
+ eventPolicyConfig.setSourceDomain("JUNIT");
+
+ eventPolicyConfig.setSchemaVersions(schemaVersions);
+ eventPolicyConfig.setSchemaLocationsBean(schemaLocationsBean);
searchDb = new InMemorySearchDatastore();
- policy = new SpikeEntitySearchProcessorStubbed(config).withSearchDb(searchDb);
+ policy = new SpikeEntitySearchProcessorStubbed(eventPolicyConfig).withSearchDb(searchDb);
}
diff --git a/src/test/resources/config/schemaIngest.properties b/src/test/resources/config/schemaIngest.properties
new file mode 100644
index 0000000..3c51c3d
--- /dev/null
+++ b/src/test/resources/config/schemaIngest.properties
@@ -0,0 +1,16 @@
+# Properties for the SchemaLocationsBean
+# Properties required by the aai-common - aai-schema-ingest lib as of 1.3.0
+schema.configuration.location=N/A
+schema.nodes.location=src/test/resources/oxm-reader/oxm
+schema.edges.location=
+# These versions need to exist if they are included in the list
+schema.version.list=v8,v9,v10,v11,v12,v13
+# Decalares the oxm version to load
+schema.version.api.default=v13
+
+# Don't use these properties in our application, need to be set to prevent an exception on startup (see SchemaVersions bean)
+schema.version.depth.start=v13
+schema.version.related.link.start=v13
+schema.version.app.root.start=v13
+schema.version.namespace.change.start=v13
+schema.version.edge.label.start=v13 \ No newline at end of file
diff --git a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_v11.xml b/src/test/resources/oxm-reader/multiple-oxm/v11/aai_oxm_v11.xml
index 90d023c..90d023c 100644
--- a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_v11.xml
+++ b/src/test/resources/oxm-reader/multiple-oxm/v11/aai_oxm_v11.xml
diff --git a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_v12.xml b/src/test/resources/oxm-reader/multiple-oxm/v12/aai_oxm_v12.xml
index d9fbcca..d9fbcca 100644
--- a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_v12.xml
+++ b/src/test/resources/oxm-reader/multiple-oxm/v12/aai_oxm_v12.xml
diff --git a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_a_v13.xml b/src/test/resources/oxm-reader/multiple-oxm/v13/aai_oxm_a_v13.xml
index 334d32d..334d32d 100644
--- a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_a_v13.xml
+++ b/src/test/resources/oxm-reader/multiple-oxm/v13/aai_oxm_a_v13.xml
diff --git a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_b_v13.xml b/src/test/resources/oxm-reader/multiple-oxm/v13/aai_oxm_b_v13.xml
index 368fcc7..368fcc7 100644
--- a/src/test/resources/oxm-reader/multiple-oxm/aai_oxm_b_v13.xml
+++ b/src/test/resources/oxm-reader/multiple-oxm/v13/aai_oxm_b_v13.xml
diff --git a/src/test/resources/oxm-reader/oxm/aai_oxm_v10.xml b/src/test/resources/oxm-reader/oxm/v10/aai_oxm_v10.xml
index 51eaa34..51eaa34 100644
--- a/src/test/resources/oxm-reader/oxm/aai_oxm_v10.xml
+++ b/src/test/resources/oxm-reader/oxm/v10/aai_oxm_v10.xml
diff --git a/src/test/resources/oxm-reader/oxm/aai_oxm_v11.xml b/src/test/resources/oxm-reader/oxm/v11/aai_oxm_v11.xml
index 90d023c..90d023c 100644
--- a/src/test/resources/oxm-reader/oxm/aai_oxm_v11.xml
+++ b/src/test/resources/oxm-reader/oxm/v11/aai_oxm_v11.xml
diff --git a/src/test/resources/oxm-reader/oxm/aai_oxm_v12.xml b/src/test/resources/oxm-reader/oxm/v12/aai_oxm_v12.xml
index d9fbcca..d9fbcca 100644
--- a/src/test/resources/oxm-reader/oxm/aai_oxm_v12.xml
+++ b/src/test/resources/oxm-reader/oxm/v12/aai_oxm_v12.xml
diff --git a/src/test/resources/oxm-reader/oxm/aai_oxm_v13.xml b/src/test/resources/oxm-reader/oxm/v13/aai_oxm_v13.xml
index 2dfc4f0..2dfc4f0 100644
--- a/src/test/resources/oxm-reader/oxm/aai_oxm_v13.xml
+++ b/src/test/resources/oxm-reader/oxm/v13/aai_oxm_v13.xml
diff --git a/src/test/resources/oxm-reader/oxm/aai_oxm_v8.xml b/src/test/resources/oxm-reader/oxm/v8/aai_oxm_v8.xml
index d666b73..d666b73 100644
--- a/src/test/resources/oxm-reader/oxm/aai_oxm_v8.xml
+++ b/src/test/resources/oxm-reader/oxm/v8/aai_oxm_v8.xml
diff --git a/src/test/resources/oxm-reader/oxm/aai_oxm_v9.xml b/src/test/resources/oxm-reader/oxm/v9/aai_oxm_v9.xml
index ecffb2f..ecffb2f 100644
--- a/src/test/resources/oxm-reader/oxm/aai_oxm_v9.xml
+++ b/src/test/resources/oxm-reader/oxm/v9/aai_oxm_v9.xml
diff --git a/src/test/resources/spring-beans/data-router-oxm.xml b/src/test/resources/spring-beans/data-router-oxm.xml
new file mode 100644
index 0000000..90e7e97
--- /dev/null
+++ b/src/test/resources/spring-beans/data-router-oxm.xml
@@ -0,0 +1,14 @@
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:task="http://www.springframework.org/schema/task"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
+ http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
+
+ <context:property-placeholder location="file:src/test/resources/config/schemaIngest.properties" ignore-unresolvable="true" />
+
+ <bean id="schemaVersions" class="org.onap.aai.setup.SchemaVersions"/>
+
+ <bean id="schemaLocationsBean" class="org.onap.aai.setup.SchemaLocationsBean"/>
+
+</beans>