diff options
author | 2018-12-17 11:34:46 +0000 | |
---|---|---|
committer | 2018-12-17 12:24:27 +0000 | |
commit | f6a319cdda918e33c1bf5cffbb356dd0b9feb069 (patch) | |
tree | 7f5b25ab3cfe075c281c00e8896d157902aa338e /src/test/java/org | |
parent | fb4c5707d0f116cfd7438fa06e5273ce552345a7 (diff) |
Update to use Schema Service
The code supports both Schema Service and local schema files.
The property schema.translator.list drives which one to use.
Change-Id: Idc9c5832d7286e7904ddf0b2637c83b0a3cfa15c
Issue-ID: AAI-2008
Signed-off-by: Ravi Geda <gravik@amdocs.com>
Diffstat (limited to 'src/test/java/org')
4 files changed, 160 insertions, 148 deletions
diff --git a/src/test/java/org/onap/crud/OXMModelLoaderSetup.java b/src/test/java/org/onap/crud/OXMModelLoaderSetup.java index 0b34048..005a393 100644 --- a/src/test/java/org/onap/crud/OXMModelLoaderSetup.java +++ b/src/test/java/org/onap/crud/OXMModelLoaderSetup.java @@ -22,8 +22,9 @@ package org.onap.crud; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; - +import java.util.Set; import org.junit.Before; import org.mockito.Mock; import org.mockito.Mockito; @@ -33,6 +34,7 @@ import org.onap.aai.setup.AAIConfigTranslator; import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersion; import org.onap.aai.setup.SchemaVersions; +import org.onap.aai.setup.Translator; import org.onap.schema.EdgePropsConfiguration; import org.onap.schema.EdgeRulesLoader; import org.onap.schema.OxmModelLoader; @@ -67,12 +69,16 @@ public class OXMModelLoaderSetup { Mockito.when(schemaLocationsBean.getNodesInclusionPattern()).thenReturn(Arrays.asList(".*oxm(.*).xml")); Mockito.when(schemaLocationsBean.getEdgesInclusionPattern()).thenReturn(Arrays.asList("DbEdgeRules_.*.json")); Mockito.when(schemaLocationsBean.getNodeDirectory()).thenReturn("src/test/resources/multi-oxm/"); - Mockito.when(schemaLocationsBean.getEdgeDirectory()).thenReturn("src/test/resources/rules"); + Mockito.when(schemaLocationsBean.getEdgeDirectory()).thenReturn("src/test/resources/rules/"); Mockito.when(edgePropsConfiguration.getEdgePropsDir()).thenReturn("src/test/resources/edgeProps/"); AAIConfigTranslator aaiConfigTranslator = new AAIConfigTranslator(schemaLocationsBean, schemaVersions); - NodeIngestor nodeIngestor = new NodeIngestor(aaiConfigTranslator); - EdgeIngestor edgeIngestor = new EdgeIngestor(aaiConfigTranslator, schemaVersions); + Set<Translator> translators = new HashSet<>(); + translators.add(aaiConfigTranslator); + NodeIngestor nodeIngestor = new NodeIngestor(translators); + nodeIngestor.initialize(); + EdgeIngestor edgeIngestor = new EdgeIngestor(translators); + edgeIngestor.initialize(); edgeRulesLoader = new EdgeRulesLoader(aaiConfigTranslator, edgeIngestor, edgePropsConfiguration); oxmModelLoader = new OxmModelLoader(aaiConfigTranslator, nodeIngestor); } diff --git a/src/test/java/org/onap/crud/event/response/GraphEventResponseHandlerTest.java b/src/test/java/org/onap/crud/event/response/GraphEventResponseHandlerTest.java index a5edd7c..b28ba3a 100644 --- a/src/test/java/org/onap/crud/event/response/GraphEventResponseHandlerTest.java +++ b/src/test/java/org/onap/crud/event/response/GraphEventResponseHandlerTest.java @@ -30,6 +30,7 @@ import org.onap.crud.event.GraphEvent.GraphEventOperation; import org.onap.crud.event.envelope.GraphEventEnvelope; import org.onap.crud.exception.CrudException; import org.onap.crud.util.TestUtil; +import org.onap.schema.EdgeRulesLoader; import org.onap.schema.OxmModelLoader; import com.google.gson.Gson; import com.google.gson.JsonParser; @@ -51,6 +52,7 @@ public class GraphEventResponseHandlerTest extends OXMModelLoaderSetup { System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); OxmModelLoader.loadModels(); + EdgeRulesLoader.loadModels(); } @Test diff --git a/src/test/java/org/onap/crud/service/ChampDaoMockTest.java b/src/test/java/org/onap/crud/service/ChampDaoMockTest.java index dadf81a..01e4646 100644 --- a/src/test/java/org/onap/crud/service/ChampDaoMockTest.java +++ b/src/test/java/org/onap/crud/service/ChampDaoMockTest.java @@ -22,6 +22,7 @@ package org.onap.crud.service; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -30,11 +31,9 @@ import java.util.Map; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; -import org.onap.aai.logging.LoggingContext; import org.onap.aai.restclient.client.OperationResult; import org.onap.aai.restclient.client.RestClient; import org.onap.crud.dao.champ.ChampDao; -import org.slf4j.MDC; public class ChampDaoMockTest { // @formatter:off @@ -44,7 +43,7 @@ public class ChampDaoMockTest { "\"properties\": {" + "\"fqdn\": \"myhost.onap.com\"," + "\"hostname\": \"myhost\" } }"; - + private final String champEdge = "{" + "\"key\": \"test-uuid\"," + "\"type\": \"edgeType\"," + @@ -55,154 +54,154 @@ public class ChampDaoMockTest { "\"target\": {" + "\"key\": \"1d326bc7-b985-492b-9604-0d5d1f06f908\", \"type\": \"pserver\"}" + " }"; - - private final String edgePayload = "{" + - "\"type\":\"tosca.relationships.HostedOn\"," + - "\"properties\":{" + - "\"prevent-delete\":\"NONE\"}," + - "\"source\":{" + - "\"key\":\"test-uuid\"," + - "\"type\":\"vserver\"," + - "\"properties\":{}}," + - "\"target\":{" + - "\"key\":\"test-uuid\"," + - "\"type\":\"pserver\"," + - "\"properties\":{" + - "\"hostname\":\"myhost\"," + + + private final String edgePayload = "{" + + "\"type\":\"tosca.relationships.HostedOn\"," + + "\"properties\":{" + + "\"prevent-delete\":\"NONE\"}," + + "\"source\":{" + + "\"key\":\"test-uuid\"," + + "\"type\":\"vserver\"," + + "\"properties\":{}}," + + "\"target\":{" + + "\"key\":\"test-uuid\"," + + "\"type\":\"pserver\"," + + "\"properties\":{" + + "\"hostname\":\"myhost\"," + "\"fqdn\":\"myhost.onap.com\"}}}"; - private final String edgePayloadForPut = "{" + - "\"key\":\"test-uuid\"," + - "\"type\":\"tosca.relationships.HostedOn\"," + - "\"properties\":{" + - "\"prevent-delete\":\"NONE\"}," + - "\"source\":{" + - "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," + - "\"type\":\"vserver\"," + - "\"properties\":{}}," + - "\"target\":{" + - "\"key\":\"1d326bc7-b985-492b-9604-0d5d1f06f908\"," + - "\"type\":\"pserver\"," + + private final String edgePayloadForPut = "{" + + "\"key\":\"test-uuid\"," + + "\"type\":\"tosca.relationships.HostedOn\"," + + "\"properties\":{" + + "\"prevent-delete\":\"NONE\"}," + + "\"source\":{" + + "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," + + "\"type\":\"vserver\"," + + "\"properties\":{}}," + + "\"target\":{" + + "\"key\":\"1d326bc7-b985-492b-9604-0d5d1f06f908\"," + + "\"type\":\"pserver\"," + "\"properties\":{}}}"; - - private final String edgePayloadForPatch = "{" + - "\"key\":\"test-uuid\"," + - "\"type\":\"tosca.relationships.HostedOn\"," + - "\"properties\":{" + - "\"prevent-delete\":\"NONE\"}," + - "\"source\":{" + - "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," + - "\"type\":\"vserver\"}," + - "\"target\":{" + - "\"key\":\"1d326bc7-b985-492b-9604-0d5d1f06f908\"," + + + private final String edgePayloadForPatch = "{" + + "\"key\":\"test-uuid\"," + + "\"type\":\"tosca.relationships.HostedOn\"," + + "\"properties\":{" + + "\"prevent-delete\":\"NONE\"}," + + "\"source\":{" + + "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," + + "\"type\":\"vserver\"}," + + "\"target\":{" + + "\"key\":\"1d326bc7-b985-492b-9604-0d5d1f06f908\"," + "\"type\":\"pserver\"}}"; - - private final String edgePayloadForPost = "{" + - "\"type\":\"tosca.relationships.HostedOn\"," + - "\"properties\":{" + - "\"SVC-INFRA\":\"OUT\"," + - "\"prevent-delete\":\"IN\"," + - "\"delete-other-v\":\"NONE\"," + - "\"contains-other-v\":\"NONE\"" + - "}," + - "\"source\":{" + - "\"key\":\"test-uuid\"," + - "\"type\":\"vserver\"," + - "\"properties\":{" + - "" + - "}" + - "}," + - "\"target\":{" + - "\"key\":\"test-uuid\"," + - "\"type\":\"pserver\"," + - "\"properties\":{" + - "\"hostname\":\"myhost\"," + - "\"fqdn\":\"myhost.onap.com\"" + - "}" + - "}" + + + private final String edgePayloadForPost = "{" + + "\"type\":\"tosca.relationships.HostedOn\"," + + "\"properties\":{" + + "\"SVC-INFRA\":\"OUT\"," + + "\"prevent-delete\":\"IN\"," + + "\"delete-other-v\":\"NONE\"," + + "\"contains-other-v\":\"NONE\"" + + "}," + + "\"source\":{" + + "\"key\":\"test-uuid\"," + + "\"type\":\"vserver\"," + + "\"properties\":{" + + "" + + "}" + + "}," + + "\"target\":{" + + "\"key\":\"test-uuid\"," + + "\"type\":\"pserver\"," + + "\"properties\":{" + + "\"hostname\":\"myhost\"," + + "\"fqdn\":\"myhost.onap.com\"" + + "}" + + "}" + "}"; - - private final String edgePayloadForPutNoProperties = "{" + - "\"key\":\"test-uuid\"," + - "\"type\":\"tosca.relationships.HostedOn\"," + - "\"properties\":{" + - "\"SVC-INFRA\":\"OUT\"," + - "\"prevent-delete\":\"IN\"," + - "\"delete-other-v\":\"NONE\"," + - "\"contains-other-v\":\"NONE\"" + - "}," + - "\"source\":{" + - "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," + - "\"type\":\"vserver\"," + - "\"properties\":{" + - "" + - "}" + - "}," + - "\"target\":{" + - "\"key\":\"1d326bc7-b985-492b-9604-0d5d1f06f908\"," + - "\"type\":\"pserver\"," + - "\"properties\":{" + - "" + - "}" + - "}" + + + private final String edgePayloadForPutNoProperties = "{" + + "\"key\":\"test-uuid\"," + + "\"type\":\"tosca.relationships.HostedOn\"," + + "\"properties\":{" + + "\"SVC-INFRA\":\"OUT\"," + + "\"prevent-delete\":\"IN\"," + + "\"delete-other-v\":\"NONE\"," + + "\"contains-other-v\":\"NONE\"" + + "}," + + "\"source\":{" + + "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," + + "\"type\":\"vserver\"," + + "\"properties\":{" + + "" + + "}" + + "}," + + "\"target\":{" + + "\"key\":\"1d326bc7-b985-492b-9604-0d5d1f06f908\"," + + "\"type\":\"pserver\"," + + "\"properties\":{" + + "" + + "}" + + "}" + "}"; - - private final String vertexPayload = "{" + - "\"type\":\"pserver\"," + - "\"properties\":{" + - "\"hostname\":\"myhost\"," + - "\"in-maint\":false," + - "\"fqdn\":\"myhost.onap.com\"," + - "\"last-mod-source-of-truth\":\"source-of-truth\"," + - "\"source-of-truth\":\"source-of-truth\"," + + + private final String vertexPayload = "{" + + "\"type\":\"pserver\"," + + "\"properties\":{" + + "\"hostname\":\"myhost\"," + + "\"in-maint\":false," + + "\"fqdn\":\"myhost.onap.com\"," + + "\"last-mod-source-of-truth\":\"source-of-truth\"," + + "\"source-of-truth\":\"source-of-truth\"," + "\"aai-node-type\":\"pserver\"}}"; - - private final String vertexPayloadForVserver = "{" + - "\"type\":\"vserver\"," + - "\"properties\":{" + - "\"in-maint\":false," + - "\"vserver-name\":\"test-vserver\"," + - "\"vserver-id\":\"VSER1\"," + - "\"last-mod-source-of-truth\":\"source-of-truth\"," + - "\"vserver-name2\":\"alt-test-vserver\"," + - "\"source-of-truth\":\"source-of-truth\"," + - "\"vserver-selflink\":\"http://1.2.3.4/moreInfo\"," + - "\"is-closed-loop-disabled\":false," + + + private final String vertexPayloadForVserver = "{" + + "\"type\":\"vserver\"," + + "\"properties\":{" + + "\"in-maint\":false," + + "\"vserver-name\":\"test-vserver\"," + + "\"vserver-id\":\"VSER1\"," + + "\"last-mod-source-of-truth\":\"source-of-truth\"," + + "\"vserver-name2\":\"alt-test-vserver\"," + + "\"source-of-truth\":\"source-of-truth\"," + + "\"vserver-selflink\":\"http://1.2.3.4/moreInfo\"," + + "\"is-closed-loop-disabled\":false," + "\"aai-node-type\":\"vserver\"}}"; - - private final String vertexPayloadForPserver = "{" + - "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," + - "\"type\":\"pserver\"," + - "\"properties\":{" + - "\"ptnii-equip-name\":\"e-name\"," + - "\"hostname\":\"steve-host2\"," + - "\"equip-type\":\"server\"," + - "\"equip-vendor\":\"HP\"," + - "\"equip-model\":\"DL380p-nd\"," + - "\"in-maint\":false," + - "\"fqdn\":\"myhost.onap.net\"," + - "\"purpose\":\"my-purpose\"," + - "\"ipv4-oam-address\":\"1.2.3.4\"," + - "\"last-mod-source-of-truth\":\"source-of-truth\"," + + + private final String vertexPayloadForPserver = "{" + + "\"key\":\"50bdab41-ad1c-4d00-952c-a0aa5d827811\"," + + "\"type\":\"pserver\"," + + "\"properties\":{" + + "\"ptnii-equip-name\":\"e-name\"," + + "\"hostname\":\"steve-host2\"," + + "\"equip-type\":\"server\"," + + "\"equip-vendor\":\"HP\"," + + "\"equip-model\":\"DL380p-nd\"," + + "\"in-maint\":false," + + "\"fqdn\":\"myhost.onap.net\"," + + "\"purpose\":\"my-purpose\"," + + "\"ipv4-oam-address\":\"1.2.3.4\"," + + "\"last-mod-source-of-truth\":\"source-of-truth\"," + "\"aai-node-type\":\"pserver\"}}"; - - private final String vertexPayloadForPut = "{" + - "\"key\":\"test-uuid\"," + - "\"type\":\"pserver\"," + - "\"properties\":{" + - "\"hostname\":\"myhost\"," + - "\"in-maint\":false," + - "\"fqdn\":\"myhost.onap.com\"," + - "\"last-mod-source-of-truth\":\"source-of-truth\"," + + + private final String vertexPayloadForPut = "{" + + "\"key\":\"test-uuid\"," + + "\"type\":\"pserver\"," + + "\"properties\":{" + + "\"hostname\":\"myhost\"," + + "\"in-maint\":false," + + "\"fqdn\":\"myhost.onap.com\"," + + "\"last-mod-source-of-truth\":\"source-of-truth\"," + "\"aai-node-type\":\"pserver\"}}"; - - private final String vertexPayloadForPatch = "{" + - "\"key\":\"test-uuid\"," + - "\"type\":\"pserver\"," + - "\"properties\":{" + - "\"hostname\":\"myhost\"," + - "\"fqdn\":\"myhost.onap.com\"," + - "\"last-mod-source-of-truth\":\"source-of-truth\"," + + + private final String vertexPayloadForPatch = "{" + + "\"key\":\"test-uuid\"," + + "\"type\":\"pserver\"," + + "\"properties\":{" + + "\"hostname\":\"myhost\"," + + "\"fqdn\":\"myhost.onap.com\"," + + "\"last-mod-source-of-truth\":\"source-of-truth\"," + "\"aai-node-type\":\"pserver\"}}"; // @formatter:on @@ -345,7 +344,7 @@ public class ChampDaoMockTest { Map<String, List<String>> headers = new HashMap<>(); headers.put(HEADER_FROM_APP, Arrays.asList(FROM_APP_NAME)); - headers.put(HEADER_TRANS_ID, Arrays.asList(MDC.get(LoggingContext.LoggingField.REQUEST_ID.toString()))); + headers.put(HEADER_TRANS_ID, Arrays.asList(HEADER_TRANS_ID_VALUE)); when(restClientMock.get(url, headers, MediaType.APPLICATION_JSON_TYPE)).thenReturn(operationResult); } @@ -383,7 +382,7 @@ public class ChampDaoMockTest { operationResult.setResultCode(200); String baseUrl = BASE_OBJECT_URL + "/" + RELATIONSHIP_SUB_URL + "/" + id; String url; - + if (txId != null) { url = baseUrl + txId; } diff --git a/src/test/java/org/onap/schema/validation/MultiplicityValidatorTest.java b/src/test/java/org/onap/schema/validation/MultiplicityValidatorTest.java index b4d5a31..64cab0d 100644 --- a/src/test/java/org/onap/schema/validation/MultiplicityValidatorTest.java +++ b/src/test/java/org/onap/schema/validation/MultiplicityValidatorTest.java @@ -36,7 +36,12 @@ import org.onap.crud.parser.EdgePayload; import org.onap.schema.EdgeRulesLoader;
import org.onap.schema.validation.MultiplicityValidator.MultiplicityType;
-public class MultiplicityValidatorTest {
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.crud.OXMModelLoaderSetup;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class MultiplicityValidatorTest extends OXMModelLoaderSetup{
private final String postEdgePayload = "{" + "\"type\": \"tosca.relationships.HostedOn\","
+ "\"source\": \"services/inventory/v12/vserver/50bdab41-ad1c-4d00-952c-a0aa5d827811\","
|