diff options
author | 2019-01-30 14:04:35 +0000 | |
---|---|---|
committer | 2019-01-30 15:48:22 +0000 | |
commit | 0c40bcde9facc109ceb8dabb91156df2b4fb4129 (patch) | |
tree | af3b32aa18092c7ea6bb60005a6d503448a92297 /src/test/java/org/onap/schema | |
parent | df7904cca9c67ed7ce99e1d1d1c3a2c961a61445 (diff) |
Remove Multiplicity feature
The multiplicty feature is not working properly around relantionships
and demands more investigation in order to identify the issues.
In the future we might add this back.
For reference multiplicity was added under AAI-1197
Basically reversing the commit: d10a218c76633374f083f7a2802c198e93a6abae
Issue-ID: AAI-2124
Change-Id: I5d27b950841da08b00fbb422fb13136d43f0e3bd
Signed-off-by: Sanchez, Gabriel (gs882h) <gabriel.sanchez@amdocs.com>
Diffstat (limited to 'src/test/java/org/onap/schema')
3 files changed, 6 insertions, 169 deletions
diff --git a/src/test/java/org/onap/schema/EdgeRulesLoaderTest.java b/src/test/java/org/onap/schema/EdgeRulesLoaderTest.java index 8f82c58..2ad9456 100644 --- a/src/test/java/org/onap/schema/EdgeRulesLoaderTest.java +++ b/src/test/java/org/onap/schema/EdgeRulesLoaderTest.java @@ -29,7 +29,7 @@ import java.util.Set; import org.junit.Test; import org.onap.crud.exception.CrudException; -import org.onap.crud.parser.EdgePayload; +import org.onap.crud.service.EdgePayload; import org.onap.crud.util.CrudServiceUtil; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; diff --git a/src/test/java/org/onap/schema/RelationshipSchemaValidatorTest.java b/src/test/java/org/onap/schema/RelationshipSchemaValidatorTest.java index 7cc2e7f..11d42bf 100644 --- a/src/test/java/org/onap/schema/RelationshipSchemaValidatorTest.java +++ b/src/test/java/org/onap/schema/RelationshipSchemaValidatorTest.java @@ -27,9 +27,7 @@ import org.junit.Before; import org.junit.Test; import org.onap.crud.entity.Edge; import org.onap.crud.exception.CrudException; -import org.onap.crud.parser.EdgePayload; -import org.onap.schema.validation.RelationshipSchemaValidator; - +import org.onap.crud.service.EdgePayload; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; import org.onap.crud.OXMModelLoaderSetup; @@ -78,7 +76,7 @@ public class RelationshipSchemaValidatorTest extends OXMModelLoaderSetup{ RelationshipSchemaValidator.validateIncomingUpdatePayload(edge, version, payload); } catch (CrudException e) { assertEquals(400, e.getHttpStatus().getStatusCode()); - assertThat(e.getMessage(), is("Invalid Source/Target Urls")); + assertThat(e.getMessage(), is("Invalid Source Urls")); } } @@ -120,7 +118,7 @@ public class RelationshipSchemaValidatorTest extends OXMModelLoaderSetup{ RelationshipSchemaValidator.validateIncomingUpdatePayload(edge, version, payload); } catch (CrudException e) { assertEquals(400, e.getHttpStatus().getStatusCode()); - assertThat(e.getMessage(), is("Invalid Source/Target Urls")); + assertThat(e.getMessage(), is("Invalid Target Urls")); } } @@ -191,7 +189,7 @@ public class RelationshipSchemaValidatorTest extends OXMModelLoaderSetup{ RelationshipSchemaValidator.validateIncomingPatchPayload(edge, version, payload); } catch (CrudException e) { assertEquals(400, e.getHttpStatus().getStatusCode()); - assertThat(e.getMessage(), is("Invalid Source/Target Urls")); + assertThat(e.getMessage(), is("Invalid Source Urls")); } } @@ -234,7 +232,7 @@ public class RelationshipSchemaValidatorTest extends OXMModelLoaderSetup{ RelationshipSchemaValidator.validateIncomingPatchPayload(edge, version, payload); } catch (CrudException e) { assertEquals(400, e.getHttpStatus().getStatusCode()); - assertThat(e.getMessage(), is("Invalid Source/Target Urls")); + assertThat(e.getMessage(), is("Invalid Target Urls")); } } diff --git a/src/test/java/org/onap/schema/validation/MultiplicityValidatorTest.java b/src/test/java/org/onap/schema/validation/MultiplicityValidatorTest.java deleted file mode 100644 index 64cab0d..0000000 --- a/src/test/java/org/onap/schema/validation/MultiplicityValidatorTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-package org.onap.schema.validation;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.crud.entity.Edge;
-import org.onap.crud.entity.Vertex;
-import org.onap.crud.exception.CrudException;
-import org.onap.crud.parser.EdgePayload;
-import org.onap.schema.EdgeRulesLoader;
-import org.onap.schema.validation.MultiplicityValidator.MultiplicityType;
-
-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\","
- + "\"target\": \"services/inventory/v12/pserver/1d326bc7-b985-492b-9604-0d5d1f06f908\","
- + "\"properties\": {" + "\"prevent-delete\": \"NONE\" } }";
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Before
- public void init() {
- System.setProperty("CONFIG_HOME", "src/test/resources");
- EdgeRulesLoader.resetSchemaVersionContext();
- }
-
- @Test
- public void testValidPayloadForMultiplicityRule() throws CrudException {
- Map<String, List<Edge>> vertexMap = getEdgesForVertex(MultiplicityType.MANY2ONE, true);
- MultiplicityValidator.validatePayloadMultiplicity(EdgePayload.fromJson(postEdgePayload),
- vertexMap.get("source"), vertexMap.get("target"),
- "tosca.relationships.HostedOn", "v11");
- }
-
- @Test
- public void testInvalidPayloadForMultiplicityRule() throws CrudException {
- thrown.expect(CrudException.class);
- thrown.expectMessage("MANY2ONE multiplicity rule broken for Edge:vserver:pserver:tosca.relationships.HostedOn");
-
- Map<String, List<Edge>> vertexMap = getEdgesForVertex(MultiplicityType.MANY2ONE, false);
- MultiplicityValidator.validatePayloadMultiplicity(EdgePayload.fromJson(postEdgePayload),
- vertexMap.get("source"), vertexMap.get("target"),
- "tosca.relationships.HostedOn", "v11");
- }
-
- @Test
- public void testIsVertexValidForMultiplicityType() throws CrudException {
-
- Map<String, List<Edge>> vertexMap = getEdgesForVertex(MultiplicityType.MANY2MANY, true);
- Assert.assertTrue(MultiplicityValidator.isVertexValidForMultiplicityType(vertexMap.get("source"),
- vertexMap.get("target"), MultiplicityType.MANY2MANY));
-
- vertexMap = getEdgesForVertex(MultiplicityType.MANY2ONE, true);
- Assert.assertTrue(MultiplicityValidator.isVertexValidForMultiplicityType(
- vertexMap.get("source"), vertexMap.get("target"), MultiplicityType.MANY2ONE));
-
- vertexMap = getEdgesForVertex(MultiplicityType.ONE2MANY, true);
- Assert.assertTrue(MultiplicityValidator.isVertexValidForMultiplicityType(
- vertexMap.get("source"), vertexMap.get("target"), MultiplicityType.ONE2MANY));
-
- vertexMap = getEdgesForVertex(MultiplicityType.ONE2ONE, true);
- Assert.assertTrue(MultiplicityValidator.isVertexValidForMultiplicityType(
- vertexMap.get("source"), vertexMap.get("target"), MultiplicityType.ONE2ONE));
-
- vertexMap = getEdgesForVertex(MultiplicityType.ONE2MANY, false);
- Assert.assertFalse(MultiplicityValidator.isVertexValidForMultiplicityType(
- vertexMap.get("source"), vertexMap.get("target"), MultiplicityType.ONE2MANY));
-
- vertexMap = getEdgesForVertex(MultiplicityType.ONE2ONE, false);
- Assert.assertFalse(MultiplicityValidator.isVertexValidForMultiplicityType(
- vertexMap.get("source"), vertexMap.get("target"), MultiplicityType.ONE2ONE));
- }
-
- private Map<String, List<Edge>> getEdgesForVertex(MultiplicityType multiplicityType, boolean pass) {
-
- Map<String, List<Edge>> vertexMap = new HashMap<String, List<Edge>>();
- List<Edge> edgesForSourceVertex = new ArrayList<>();
- List<Edge> edgesForTargetVertex = new ArrayList<>();
-
- switch (multiplicityType) {
- case MANY2MANY:
- if (pass) {
- Edge edge = new Edge.Builder("type").source(new Vertex.Builder("source").build())
- .target(new Vertex.Builder("target").build()).build();
- edgesForSourceVertex.add(edge);
- edgesForTargetVertex.add(edge);
- }
- break;
- case MANY2ONE:
- if (pass) {
- Edge edge = new Edge.Builder("type").source(new Vertex.Builder("source").build())
- .target(new Vertex.Builder("target").build()).build();
- edgesForTargetVertex.add(edge);
- } else {
- Edge edge = new Edge.Builder("type").source(new Vertex.Builder("source").build())
- .target(new Vertex.Builder("target").build()).build();
- edgesForSourceVertex.add(edge);
- edgesForTargetVertex.add(edge);
- }
- break;
- case ONE2MANY:
- if (pass) {
- Edge edge = new Edge.Builder("type").source(new Vertex.Builder("source").build())
- .target(new Vertex.Builder("target").build()).build();
- edgesForSourceVertex.add(edge);
- } else {
- Edge edge = new Edge.Builder("type").source(new Vertex.Builder("source").build())
- .target(new Vertex.Builder("target").build()).build();
- edgesForSourceVertex.add(edge);
- edgesForTargetVertex.add(edge);
- }
- break;
- case ONE2ONE:
- if (!pass) {
- Edge edge = new Edge.Builder("type").source(new Vertex.Builder("source").build())
- .target(new Vertex.Builder("target").build()).build();
- edgesForSourceVertex.add(edge);
- edgesForTargetVertex.add(edge);
- }
- break;
- }
- vertexMap.put("source", edgesForSourceVertex);
- vertexMap.put("target", edgesForTargetVertex);
-
- return vertexMap;
- }
-
-}
|