aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-10-21 19:04:18 +0000
committerGerrit Code Review <gerrit@onap.org>2020-10-21 19:04:18 +0000
commit7396509f9c11cc4e9651210cf8a290679bb17fd5 (patch)
tree6b8774ff5aa799e7baa1ee6b4d3eda8cbfbe8b30
parent00cbdf511a264cb4028ef2a5786a53badad25dcb (diff)
parentac680dd59dc046d25bd7fa406e003c32b0f08608 (diff)
Merge "add hasRelationships method to wrapper"
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryResultWrapper.java10
-rw-r--r--graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/AAIResultWrapperTest.java11
2 files changed, 20 insertions, 1 deletions
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryResultWrapper.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryResultWrapper.java
index 9e6572388b..ae32107339 100644
--- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryResultWrapper.java
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/entities/GraphInventoryResultWrapper.java
@@ -28,6 +28,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryObjectName;
import org.onap.so.jsonpath.JsonPathUtil;
import org.slf4j.Logger;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -63,6 +64,15 @@ public abstract class GraphInventoryResultWrapper<R extends GraphInventoryRelati
}
}
+ public boolean hasRelationshipsTo(GraphInventoryObjectName name) {
+ Optional<R> rOpt = this.getRelationships();
+ if (rOpt.isPresent()) {
+ return rOpt.get().getRelatedLinks(name).size() > 0;
+ } else {
+ return false;
+ }
+ }
+
public Optional<R> getRelationships() {
final String path = "$.relationship-list";
if (isEmpty()) {
diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/AAIResultWrapperTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/AAIResultWrapperTest.java
index adc2e7284e..98431759de 100644
--- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/AAIResultWrapperTest.java
+++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/entities/AAIResultWrapperTest.java
@@ -21,8 +21,9 @@
package org.onap.aaiclient.client.aai.entities;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
-import java.io.Serializable;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
@@ -36,6 +37,7 @@ import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
import org.springframework.util.SerializationUtils;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
@@ -107,4 +109,11 @@ public class AAIResultWrapperTest {
AAIResultWrapper wrapper = new AAIResultWrapper(new GenericVnf());
assertEquals("{}", wrapper.getJson());
}
+
+ @Test
+ public void hasRelationshipToTest() {
+ assertTrue(aaiResultWrapper.hasRelationshipsTo(Types.VCE));
+ assertFalse(aaiResultWrapper.hasRelationshipsTo(Types.CLASS_OF_SERVICE));
+
+ }
}