summaryrefslogtreecommitdiffstats
path: root/aai-core/src/test
diff options
context:
space:
mode:
authorM.Hosnidokht <mohammad.hosnidokht@yoppworks.com>2020-12-03 11:11:16 -0500
committerM.Hosnidokht <mohammad.hosnidokht@yoppworks.com>2021-01-06 10:15:57 -0500
commiteca412c5285bb65bd82a8236e0fec8426a2c605e (patch)
tree9ac48d843e7d57d983dd0a0f1f87d043ac09ba0d /aai-core/src/test
parentc42f46f79066734b96f91815b49b633a30e0ede4 (diff)
Use data owner attribute instead of owning entity for OwnerCheck
Issue-ID: AAI-3226 Signed-off-by: Mohammad Hosnidokht <mohammad.hosnidokht@yoppworks.com> Change-Id: I8222546e7264e99ca3e53fe1212a45008c1064e6
Diffstat (limited to 'aai-core/src/test')
-rw-r--r--aai-core/src/test/java/org/onap/aai/introspection/sideeffect/OwnerCheckTest.java81
-rw-r--r--aai-core/src/test/resources/onap/oxm/v14/aai_oxm_v14.xml5
2 files changed, 68 insertions, 18 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/OwnerCheckTest.java b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/OwnerCheckTest.java
index 0e33f6c7..9f101965 100644
--- a/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/OwnerCheckTest.java
+++ b/aai-core/src/test/java/org/onap/aai/introspection/sideeffect/OwnerCheckTest.java
@@ -86,16 +86,10 @@ public class OwnerCheckTest extends AAISetup {
.addV("pnf")
.property("aai-node-type", "pnf")
.property("pnf-name", "my-pnf")
+ .property("data-owner", "Operator")
.property(AAIProperties.AAI_URI, "/network/pnfs/pnf/my-pnf")
.property("model-invariant-id", "key1")
.as("v1")
- .addV("owning-entity")
- .property("aai-node-type", "owning-entity")
- .property("owning-entity-name", "OE-Generic")
- .property("owning-entity-id", "367c897c-8cec-47ba-b7f5-4b6139f06691")
- .property(AAIProperties.AAI_URI,"/network/pnfs/pnf/my-pnf/business/owning-entities/owning-entity/367c897c-8cec-47ba-b7f5-4b6139f06691")
- .as("oe")
- .addE("org.onap.relationships.inventory.BelongsTo").to("v1").from("oe")
.property(EdgeProperty.CONTAINS.toString(), true)
.addV("model-ver")
.property("aai-node-type", "model-ver")
@@ -137,14 +131,13 @@ public class OwnerCheckTest extends AAISetup {
}
@Test
- public void shouldFailComparisonWithDiffOwningEntity() throws Exception {
+ public void shouldFailIfGroupsNotContainsDataOwner() throws Exception {
final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
final Introspector obj = loader.introspectorFromName("pnf");
obj.setValue("pnf-name", "my-pnf");
obj.setValue("model-invariant-id", "key1");
obj.setValue("model-version-id", "key2");
- //obj.setValue("owning-entity-id", "367c897c-8cec-47ba-b7f5-4b6139f06691");
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
Graph g = graph.newTransaction();
@@ -152,30 +145,29 @@ public class OwnerCheckTest extends AAISetup {
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
DBSerializer serializer =
- new DBSerializer(schemaVersions.getDefaultVersion(),
- spy, introspectorFactoryType,
- "AAI_TEST", new HashSet<>(Arrays.asList("OE-GenericI", "OE-GenericII")));
+ new DBSerializer(schemaVersions.getDefaultVersion(),
+ spy, introspectorFactoryType,
+ "AAI_TEST", new HashSet<>(Arrays.asList("OperatorI", "OperatorII")));
Vertex selfV = g.traversal().V().has("aai-node-type", "pnf").next();
OwnerCheck ownerCheck = new OwnerCheck(obj, selfV, spy, serializer);
thrown.expect(AAIException.class);
- thrown.expectMessage("Group(s) :[OE-GenericI, OE-GenericII] not authorized to perform function");
+ thrown.expectMessage("Group(s) :[OperatorII, OperatorI] not authorized to perform function");
ownerCheck.execute();
g.tx().rollback();
}
@Test
- public void shouldPassIfOwningEntityEqual() throws Exception {
+ public void shouldPassIfGroupsContainsDataOwner() throws Exception {
final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
final Introspector obj = loader.introspectorFromName("pnf");
obj.setValue("pnf-name", "my-pnf");
obj.setValue("model-invariant-id", "key1");
obj.setValue("model-version-id", "key2");
- //obj.setValue("owning-entity-id", "367c897c-8cec-47ba-b7f5-4b6139f06691");
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
Graph g = graph.newTransaction();
@@ -189,25 +181,78 @@ public class OwnerCheckTest extends AAISetup {
DBSerializer serializer =
new DBSerializer(schemaVersions.getDefaultVersion(),
spy, introspectorFactoryType,
- "AAI_TEST", new HashSet<>(Arrays.asList("OE-Generic", "OE-GenericII")));
+ "AAI_TEST", new HashSet<>(Arrays.asList("OperatorIII", "Operator")));
+
+ OwnerCheck ownerCheck = new OwnerCheck(obj, selfV, spy, serializer);
+
+ ownerCheck.execute();
+ g.tx().rollback();
+ }
+
+ @Test
+ public void shouldPassIfGroupsIsEmpty() throws Exception {
+
+ final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ final Introspector obj = loader.introspectorFromName("pnf");
+ obj.setValue("pnf-name", "my-pnf");
+ obj.setValue("model-invariant-id", "key1");
+ obj.setValue("model-version-id", "key2");
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ Graph g = graph.newTransaction();
+ GraphTraversalSource traversal = g.traversal();
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ DBSerializer serializer =
+ new DBSerializer(schemaVersions.getDefaultVersion(),
+ spy, introspectorFactoryType,
+ "AAI_TEST");
+
+ Vertex selfV = g.traversal().V().has("aai-node-type", "pnf").next();
OwnerCheck ownerCheck = new OwnerCheck(obj, selfV, spy, serializer);
ownerCheck.execute();
+ g.tx().rollback();
+ }
+
+ @Test
+ public void shouldPassIfDataOwnerIsNull() throws Exception {
+
+ final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
+ final Introspector obj = loader.introspectorFromName("pnf");
+ obj.setValue("pnf-name", "my-pnf");
+ obj.setValue("model-invariant-id", "key1");
+ obj.setValue("model-version-id", "key2");
+ obj.setValue("data-owner", null);
+ TransactionalGraphEngine spy = spy(dbEngine);
+ TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
+ Graph g = graph.newTransaction();
+ GraphTraversalSource traversal = g.traversal();
+ when(spy.asAdmin()).thenReturn(adminSpy);
+ when(adminSpy.getTraversalSource()).thenReturn(traversal);
+ DBSerializer serializer =
+ new DBSerializer(schemaVersions.getDefaultVersion(),
+ spy, introspectorFactoryType,
+ "AAI_TEST");
+
+ Vertex selfV = g.traversal().V().has("aai-node-type", "pnf").next();
+ OwnerCheck ownerCheck = new OwnerCheck(obj, selfV, spy, serializer);
+ ownerCheck.execute();
g.tx().rollback();
}
@Test
- public void shouldPassIfUserOwningEntityEmptyl() throws Exception {
+ public void shouldPassIfDataOwnerIsEmpty() throws Exception {
final Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
final Introspector obj = loader.introspectorFromName("pnf");
obj.setValue("pnf-name", "my-pnf");
obj.setValue("model-invariant-id", "key1");
obj.setValue("model-version-id", "key2");
- //obj.setValue("owning-entity-id", "367c897c-8cec-47ba-b7f5-4b6139f06691");
+ obj.setValue("data-owner", "");
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
Graph g = graph.newTransaction();
diff --git a/aai-core/src/test/resources/onap/oxm/v14/aai_oxm_v14.xml b/aai-core/src/test/resources/onap/oxm/v14/aai_oxm_v14.xml
index b08e4fb1..99596cde 100644
--- a/aai-core/src/test/resources/onap/oxm/v14/aai_oxm_v14.xml
+++ b/aai-core/src/test/resources/onap/oxm/v14/aai_oxm_v14.xml
@@ -5131,6 +5131,11 @@
<xml-property name="ownerCheck" value="N/A"/>
</xml-properties>
</xml-element>
+ <xml-element java-attribute="dataOwner" name="data-owner" type="java.lang.String">
+ <xml-properties>
+ <xml-property name="description" value="Resource owner"/>
+ </xml-properties>
+ </xml-element>
<xml-element java-attribute="pnfName2" name="pnf-name2" type="java.lang.String">
<xml-properties>
<xml-property name="description" value="name of Physical Network Function."/>