summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/pom.xml5
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperPatchProvider.java8
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperProvider.java27
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIDSLQuery.java83
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java8
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java50
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIObjectType.java169
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java136
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIRestClient.java5
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java88
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java98
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java84
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/DSLNode.java75
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/DSLNodeKey.java69
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/DSLQuery.java47
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/DSLQueryBuilder.java111
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/QueryStep.java28
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/Relationships.java6
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/__.java59
-rw-r--r--common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java159
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/EmptyStringToNullSerializer.java (renamed from common/src/main/java/org/onap/so/client/aai/EmptyStringToNullSerializer.java)2
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryCommonObjectMapperPatchProvider.java35
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryCommonObjectMapperProvider.java52
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryPatchConverter.java (renamed from common/src/main/java/org/onap/so/client/aai/AAIPatchConverter.java)10
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryResourcesClient.java147
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventorySingleTransactionClient.java87
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryTransactionalClient.java94
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java117
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/exceptions/IncorrectNumberOfUriKeys.java20
-rw-r--r--common/src/main/resources/dmaap/default-consumer.properties1
-rw-r--r--common/src/test/java/org/onap/so/BeansTest.java1
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java14
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java2
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java5
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java3
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java3
-rw-r--r--common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java83
-rw-r--r--common/src/test/java/org/onap/so/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java20
-rw-r--r--common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java4
-rw-r--r--common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java55
-rw-r--r--common/src/test/java/org/onap/so/client/aai/objects/CustomAAIObjectType.java40
-rw-r--r--common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java109
-rw-r--r--common/src/test/java/org/onap/so/client/graphinventory/GraphInventoryPatchConverterTest.java (renamed from common/src/test/java/org/onap/so/client/aai/AAIPatchConverterTest.java)16
-rw-r--r--common/src/test/resources/logback-test.xml4
44 files changed, 1613 insertions, 626 deletions
diff --git a/common/pom.xml b/common/pom.xml
index 7d468fae3f..51c9ed3bcb 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -126,6 +126,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.reflections</groupId>
+ <artifactId>reflections</artifactId>
+ <version>0.9.11</version>
+ </dependency>
</dependencies>
<build>
<resources>
diff --git a/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperPatchProvider.java b/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperPatchProvider.java
index 33c9769400..9c8345d4b6 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperPatchProvider.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperPatchProvider.java
@@ -20,16 +20,12 @@
package org.onap.so.client.aai;
-import com.fasterxml.jackson.databind.module.SimpleModule;
+import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperPatchProvider;
-public class AAICommonObjectMapperPatchProvider extends AAICommonObjectMapperProvider {
+public class AAICommonObjectMapperPatchProvider extends GraphInventoryCommonObjectMapperPatchProvider {
public AAICommonObjectMapperPatchProvider() {
super();
- EmptyStringToNullSerializer sp = new EmptyStringToNullSerializer();
- SimpleModule emptyStringModule = new SimpleModule();
- emptyStringModule.addSerializer(String.class, sp);
- mapper.registerModule(emptyStringModule);
}
}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperProvider.java b/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperProvider.java
index 0e2071842f..15bc2ea8ef 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperProvider.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAICommonObjectMapperProvider.java
@@ -20,33 +20,12 @@
package org.onap.so.client.aai;
-import org.onap.so.client.policy.CommonObjectMapperProvider;
+import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.AnnotationIntrospector;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.MapperFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
-import com.fasterxml.jackson.databind.type.TypeFactory;
-import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
-
-public class AAICommonObjectMapperProvider extends CommonObjectMapperProvider {
+public class AAICommonObjectMapperProvider extends GraphInventoryCommonObjectMapperProvider {
public AAICommonObjectMapperProvider() {
- mapper = new ObjectMapper();
- mapper.setSerializationInclusion(Include.NON_NULL);
- mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
- mapper.enable(MapperFeature.USE_ANNOTATIONS);
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
- mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- AnnotationIntrospector aiJaxb = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
- AnnotationIntrospector aiJackson = new JacksonAnnotationIntrospector();
- // first Jaxb, second Jackson annotations
- mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(aiJaxb, aiJackson));
+ super();
}
}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIDSLQuery.java b/common/src/main/java/org/onap/so/client/aai/AAIDSLQuery.java
new file mode 100644
index 0000000000..52bae20ff3
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/AAIDSLQuery.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.aai;
+
+import java.util.Optional;
+
+import org.onap.so.client.RestClient;
+import org.onap.so.client.aai.entities.DSLQuery;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.graphinventory.Format;
+import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri;
+
+public class AAIDSLQuery extends AAIClient {
+
+ private Optional<String> depth = Optional.empty();
+ private boolean nodesOnly = false;
+ private Optional<AAISubgraphType> subgraph = Optional.empty();
+
+ public AAIDSLQuery() {
+ super();
+ }
+
+ public AAIDSLQuery(AAIVersion version) {
+ super();
+ this.version = version;
+ }
+
+ public String query(Format format, DSLQuery query) {
+ return this.createClient(AAIUriFactory.createResourceUri(AAIObjectType.DSL).queryParam("format", format.toString()))
+ .put(query, String.class);
+ }
+
+ public AAIDSLQuery depth (String depth) {
+ this.depth = Optional.of(depth);
+ return this;
+ }
+ public AAIDSLQuery nodesOnly() {
+ this.nodesOnly = true;
+ return this;
+ }
+ public AAIDSLQuery subgraph(AAISubgraphType type){
+
+ subgraph = Optional.of(type);
+
+ return this;
+ }
+
+ protected GraphInventoryUri setupQueryParams(GraphInventoryUri uri) {
+ GraphInventoryUri clone = uri.clone();
+ if (this.depth.isPresent()) {
+ clone.queryParam("depth", depth.get());
+ }
+ if (this.nodesOnly) {
+ clone.queryParam("nodesOnly", "");
+ }
+ if (this.subgraph.isPresent()) {
+ clone.queryParam("subgraph", this.subgraph.get().toString());
+ }
+ return clone;
+ }
+ @Override
+ protected RestClient createClient(GraphInventoryUri uri) {
+ return super.createClient(setupQueryParams(uri));
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java b/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java
index 242fd41b19..9d2c3a8b1b 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java
@@ -22,10 +22,10 @@ package org.onap.so.client.aai;
public class AAINamespaceConstants {
- protected static final String CLOUD_INFRASTRUCTURE = "/cloud-infrastructure";
- protected static final String NETWORK = "/network";
- protected static final String BUSINESS = "/business";
- protected static final String SERVICE_DESIGN_AND_CREATION = "/service-design-and-creation";
+ public static final String CLOUD_INFRASTRUCTURE = "/cloud-infrastructure";
+ public static final String NETWORK = "/network";
+ public static final String BUSINESS = "/business";
+ public static final String SERVICE_DESIGN_AND_CREATION = "/service-design-and-creation";
}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java
index 4f3816ad90..7eadea00ff 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java
@@ -20,37 +20,45 @@
package org.onap.so.client.aai;
-import org.onap.aai.domain.yang.NetworkTechnologies;
+import java.io.Serializable;
+
import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals;
import org.onap.so.constants.Defaults;
import com.google.common.base.CaseFormat;
-public enum AAIObjectPlurals implements GraphInventoryObjectPlurals {
+public class AAIObjectPlurals implements GraphInventoryObjectPlurals, Serializable {
- CUSTOMER(AAINamespaceConstants.BUSINESS, "/customers"),
- GENERIC_VNF(AAINamespaceConstants.NETWORK, "/generic-vnfs"),
- PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers"),
- P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces"),
- L3_NETWORK(AAINamespaceConstants.NETWORK, "/l3-networks"),
- NETWORK_POLICY(AAINamespaceConstants.NETWORK, "/network-policies"),
- VPN_BINDING(AAINamespaceConstants.NETWORK, "/vpn-bindings"),
- SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions"),
- SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances"),
- OWNING_ENTITY(AAINamespaceConstants.BUSINESS, "/owning-entities"),
- VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups"),
- AVAILIBILITY_ZONE(AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones"),
- VF_MODULE(AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules"),
- CONFIGURATION(AAINamespaceConstants.NETWORK, "/configurations"),
- DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants"),
- NETWORK_TECHNOLOGY(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/network-technologies"),
- LOGICAL_LINK(AAINamespaceConstants.NETWORK, "/logical-links");
+ private static final long serialVersionUID = 5312713297525740746L;
+
+ public static final AAIObjectPlurals CUSTOMER = new AAIObjectPlurals(AAINamespaceConstants.BUSINESS, "/customers", "customer");
+ public static final AAIObjectPlurals GENERIC_VNF = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/generic-vnfs", "generic-vnf");
+ public static final AAIObjectPlurals PORT_GROUP = new AAIObjectPlurals(AAIObjectType.VCE.uriTemplate(), "/port-groups", "port-group");
+ public static final AAIObjectPlurals PSERVER = new AAIObjectPlurals(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers", "pserver");
+ public static final AAIObjectPlurals P_INTERFACE = new AAIObjectPlurals(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces", "p-interface");
+ public static final AAIObjectPlurals L3_NETWORK = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/l3-networks", "l3-network");
+ public static final AAIObjectPlurals NETWORK_POLICY = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/network-policies", "network-policy");
+ public static final AAIObjectPlurals VPN_BINDING = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/vpn-bindings", "vpn-binding");
+ public static final AAIObjectPlurals SERVICE_SUBSCRIPTION = new AAIObjectPlurals(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions", "service-subscription");
+ public static final AAIObjectPlurals SERVICE_INSTANCE = new AAIObjectPlurals(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances", "service-instance");
+ public static final AAIObjectPlurals OWNING_ENTITY = new AAIObjectPlurals(AAINamespaceConstants.BUSINESS, "/owning-entities", "owning-entity");
+ public static final AAIObjectPlurals VOLUME_GROUP = new AAIObjectPlurals(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups", "volume-group");
+ public static final AAIObjectPlurals AVAILIBILITY_ZONE = new AAIObjectPlurals(AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones", "availability-zone");
+ public static final AAIObjectPlurals VF_MODULE = new AAIObjectPlurals(AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules", "vf-module");
+ public static final AAIObjectPlurals CONFIGURATION = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/configurations", "configuration");
+ public static final AAIObjectPlurals DEFAULT_TENANT = new AAIObjectPlurals(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants", "default-tenant");
+ public static final AAIObjectPlurals NETWORK_TECHNOLOGY = new AAIObjectPlurals(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/network-technologies", "network-technology");
+ public static final AAIObjectPlurals LOGICAL_LINK = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/logical-links", "logical-link");
+ public static final AAIObjectPlurals L_INTERFACE = new AAIObjectPlurals(AAIObjectType.VSERVER.uriTemplate(), "/l-interfaces", "l-interface");
+ public static final AAIObjectPlurals SUB_L_INTERFACE = new AAIObjectPlurals(AAIObjectType.L_INTERFACE.uriTemplate(), "/l-interfaces", "l-interface");
private final String uriTemplate;
private final String partialUri;
- private AAIObjectPlurals(String parentUri, String partialUri) {
+ private final String name;
+ protected AAIObjectPlurals(String parentUri, String partialUri, String name) {
this.uriTemplate = parentUri + partialUri;
this.partialUri = partialUri;
+ this.name = name;
}
@Override
@@ -74,6 +82,6 @@ public enum AAIObjectPlurals implements GraphInventoryObjectPlurals {
}
@Override
public String typeName(CaseFormat format) {
- return CaseFormat.UPPER_UNDERSCORE.to(format, this.name());
+ return CaseFormat.LOWER_HYPHEN.to(format, this.name);
}
}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
index c782ab4904..14d7f43911 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
@@ -20,22 +20,30 @@
package org.onap.so.client.aai;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Priority;
import org.onap.aai.annotations.Metadata;
-import org.onap.aai.domain.yang.AllottedResource;
import org.onap.aai.domain.yang.AggregateRoute;
+import org.onap.aai.domain.yang.AllottedResource;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.Collection;
import org.onap.aai.domain.yang.Complex;
import org.onap.aai.domain.yang.Configuration;
import org.onap.aai.domain.yang.Connector;
import org.onap.aai.domain.yang.Customer;
+import org.onap.aai.domain.yang.Device;
import org.onap.aai.domain.yang.ExtAaiNetwork;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.InstanceGroup;
import org.onap.aai.domain.yang.L3Network;
+import org.onap.aai.domain.yang.LInterface;
import org.onap.aai.domain.yang.LineOfBusiness;
import org.onap.aai.domain.yang.ModelVer;
import org.onap.aai.domain.yang.NetworkPolicy;
@@ -45,13 +53,14 @@ import org.onap.aai.domain.yang.OwningEntity;
import org.onap.aai.domain.yang.PInterface;
import org.onap.aai.domain.yang.PhysicalLink;
import org.onap.aai.domain.yang.Platform;
+import org.onap.aai.domain.yang.Pnf;
+import org.onap.aai.domain.yang.PortGroup;
import org.onap.aai.domain.yang.Project;
import org.onap.aai.domain.yang.Pserver;
import org.onap.aai.domain.yang.RouteTableReference;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.ServiceSubscription;
import org.onap.aai.domain.yang.SpPartner;
-import org.onap.aai.domain.yang.Device;
import org.onap.aai.domain.yang.Subnet;
import org.onap.aai.domain.yang.Tenant;
import org.onap.aai.domain.yang.TunnelXconnect;
@@ -64,76 +73,117 @@ import org.onap.aai.domain.yang.VpnBinding;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.client.graphinventory.GraphInventoryObjectType;
import org.onap.so.constants.Defaults;
+import org.reflections.Reflections;
+import org.reflections.scanners.SubTypesScanner;
+import org.reflections.util.ClasspathHelper;
+import org.reflections.util.ConfigurationBuilder;
import com.google.common.base.CaseFormat;
-public enum AAIObjectType implements GraphInventoryObjectType {
+public class AAIObjectType implements GraphInventoryObjectType, Serializable {
- DEFAULT_CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/{cloud-region-id}"),
- CUSTOMER(AAINamespaceConstants.BUSINESS, Customer.class),
- GENERIC_QUERY("/search", "/generic-query"),
- BULK_PROCESS("/bulkprocess", ""),
- SINGLE_TRANSACTION("/bulk/single-transaction", ""),
- GENERIC_VNF(AAINamespaceConstants.NETWORK, GenericVnf.class),
- VF_MODULE(AAIObjectType.GENERIC_VNF.uriTemplate(), VfModule.class),
- L3_NETWORK(AAINamespaceConstants.NETWORK, L3Network.class),
- NETWORK_POLICY(AAINamespaceConstants.NETWORK, NetworkPolicy.class),
- NODES_QUERY("/search", "/nodes-query"),
- CUSTOM_QUERY("/query", ""),
- ROUTE_TABLE_REFERENCE(AAINamespaceConstants.NETWORK, RouteTableReference.class),
- DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants/tenant/{tenant-id}"),
- VCE(AAINamespaceConstants.NETWORK, Vce.class),
- VPN_BINDING(AAINamespaceConstants.NETWORK, VpnBinding.class),
- CONFIGURATION(AAINamespaceConstants.NETWORK, Configuration.class),
- PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Pserver.class),
- SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), ServiceSubscription.class),
- SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), ServiceInstance.class),
- PROJECT(AAINamespaceConstants.BUSINESS, Project.class),
- LINE_OF_BUSINESS(AAINamespaceConstants.BUSINESS, LineOfBusiness.class),
- PLATFORM(AAINamespaceConstants.BUSINESS, Platform.class),
- OWNING_ENTITY(AAINamespaceConstants.BUSINESS, OwningEntity.class),
- ALLOTTED_RESOURCE(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), AllottedResource.class),
- PNF(AAINamespaceConstants.NETWORK, "/pnfs/pnf/{pnf-name}"),
- OPERATIONAL_ENVIRONMENT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, OperationalEnvironment.class),
- CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, CloudRegion.class),
- TENANT(AAIObjectType.CLOUD_REGION.uriTemplate(), Tenant.class),
- VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), VolumeGroup.class),
- VSERVER(AAIObjectType.TENANT.uriTemplate(), Vserver.class),
- MODEL_VER(AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/models/model/{model-invariant-id}", ModelVer.class),
- TUNNEL_XCONNECT(AAIObjectType.ALLOTTED_RESOURCE.uriTemplate(), TunnelXconnect.class),
- P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), PInterface.class),
- PHYSICAL_LINK(AAINamespaceConstants.NETWORK, PhysicalLink.class),
- INSTANCE_GROUP(AAINamespaceConstants.NETWORK, InstanceGroup.class),
- COLLECTION(AAINamespaceConstants.NETWORK, Collection.class),
- VNFC(AAINamespaceConstants.NETWORK, Vnfc.class),
- VLAN_TAG(AAINamespaceConstants.NETWORK, VlanTag.class),
- COMPLEX(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Complex.class),
- CONNECTOR(AAINamespaceConstants.BUSINESS, Connector.class),
- NETWORK_TECHNOLOGY(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, NetworkTechnology.class),
- SUBNET(AAIObjectType.L3_NETWORK.uriTemplate(), Subnet.class),
- SP_PARTNER(AAINamespaceConstants.BUSINESS, SpPartner.class),
- DEVICE(AAINamespaceConstants.NETWORK, Device.class),
- EXT_AAI_NETWORK(AAINamespaceConstants.NETWORK, ExtAaiNetwork.class),
- AGGREGATE_ROUTE(AAINamespaceConstants.NETWORK, AggregateRoute.class),
- UNKNOWN("", "");
+ private static final long serialVersionUID = -2877184776691514600L;
+ private static Map<String, AAIObjectType> map = new HashMap<>();
+
+ public static final AAIObjectType DEFAULT_CLOUD_REGION = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/{cloud-region-id}", "default-cloud-region");
+ public static final AAIObjectType CUSTOMER = new AAIObjectType(AAINamespaceConstants.BUSINESS, Customer.class);
+ public static final AAIObjectType GENERIC_QUERY = new AAIObjectType("/search", "/generic-query", "generic-query");
+ public static final AAIObjectType BULK_PROCESS = new AAIObjectType("/bulkprocess", "", "bulkprocess");
+ public static final AAIObjectType SINGLE_TRANSACTION = new AAIObjectType("/bulk/single-transaction", "", "single-transaction");
+ public static final AAIObjectType GENERIC_VNF = new AAIObjectType(AAINamespaceConstants.NETWORK, GenericVnf.class);
+ public static final AAIObjectType VF_MODULE = new AAIObjectType(AAIObjectType.GENERIC_VNF.uriTemplate(), VfModule.class);
+ public static final AAIObjectType L3_NETWORK = new AAIObjectType(AAINamespaceConstants.NETWORK, L3Network.class);
+ public static final AAIObjectType NETWORK_POLICY = new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkPolicy.class);
+ public static final AAIObjectType NODES_QUERY = new AAIObjectType("/search", "/nodes-query", "nodes-query");
+ public static final AAIObjectType CUSTOM_QUERY = new AAIObjectType("/query", "", "query");
+ public static final AAIObjectType ROUTE_TABLE_REFERENCE = new AAIObjectType(AAINamespaceConstants.NETWORK, RouteTableReference.class);
+ public static final AAIObjectType DEFAULT_TENANT = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants/tenant/{tenant-id}", "default-tenant");
+ public static final AAIObjectType VCE = new AAIObjectType(AAINamespaceConstants.NETWORK, Vce.class);
+ public static final AAIObjectType PORT_GROUP = new AAIObjectType(AAIObjectType.VCE.uriTemplate(), PortGroup.class);
+ public static final AAIObjectType VPN_BINDING = new AAIObjectType(AAINamespaceConstants.NETWORK, VpnBinding.class);
+ public static final AAIObjectType CONFIGURATION = new AAIObjectType(AAINamespaceConstants.NETWORK, Configuration.class);
+ public static final AAIObjectType PSERVER = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Pserver.class);
+ public static final AAIObjectType SERVICE_SUBSCRIPTION = new AAIObjectType(AAIObjectType.CUSTOMER.uriTemplate(), ServiceSubscription.class);
+ public static final AAIObjectType SERVICE_INSTANCE = new AAIObjectType(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), ServiceInstance.class);
+ public static final AAIObjectType PROJECT = new AAIObjectType(AAINamespaceConstants.BUSINESS, Project.class);
+ public static final AAIObjectType LINE_OF_BUSINESS = new AAIObjectType(AAINamespaceConstants.BUSINESS, LineOfBusiness.class);
+ public static final AAIObjectType PLATFORM = new AAIObjectType(AAINamespaceConstants.BUSINESS, Platform.class);
+ public static final AAIObjectType OWNING_ENTITY = new AAIObjectType(AAINamespaceConstants.BUSINESS, OwningEntity.class);
+ public static final AAIObjectType ALLOTTED_RESOURCE = new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), AllottedResource.class);
+ public static final AAIObjectType PNF = new AAIObjectType(AAINamespaceConstants.NETWORK, Pnf.class);
+ public static final AAIObjectType OPERATIONAL_ENVIRONMENT = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, OperationalEnvironment.class);
+ public static final AAIObjectType CLOUD_REGION = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, CloudRegion.class);
+ public static final AAIObjectType TENANT = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), Tenant.class);
+ public static final AAIObjectType VOLUME_GROUP = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), VolumeGroup.class);
+ public static final AAIObjectType VSERVER = new AAIObjectType(AAIObjectType.TENANT.uriTemplate(), Vserver.class);
+ public static final AAIObjectType MODEL_VER = new AAIObjectType(AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/models/model/{model-invariant-id}", ModelVer.class);
+ public static final AAIObjectType TUNNEL_XCONNECT = new AAIObjectType(AAIObjectType.ALLOTTED_RESOURCE.uriTemplate(), TunnelXconnect.class);
+ public static final AAIObjectType P_INTERFACE = new AAIObjectType(AAIObjectType.PSERVER.uriTemplate(), PInterface.class);
+ public static final AAIObjectType PHYSICAL_LINK = new AAIObjectType(AAINamespaceConstants.NETWORK, PhysicalLink.class);
+ public static final AAIObjectType INSTANCE_GROUP = new AAIObjectType(AAINamespaceConstants.NETWORK, InstanceGroup.class);
+ public static final AAIObjectType COLLECTION = new AAIObjectType(AAINamespaceConstants.NETWORK, Collection.class);
+ public static final AAIObjectType VNFC = new AAIObjectType(AAINamespaceConstants.NETWORK, Vnfc.class);
+ public static final AAIObjectType VLAN_TAG = new AAIObjectType(AAINamespaceConstants.NETWORK, VlanTag.class);
+ public static final AAIObjectType COMPLEX = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Complex.class);
+ public static final AAIObjectType CONNECTOR = new AAIObjectType(AAINamespaceConstants.BUSINESS, Connector.class);
+ public static final AAIObjectType NETWORK_TECHNOLOGY = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, NetworkTechnology.class);
+ public static final AAIObjectType SUBNET = new AAIObjectType(AAIObjectType.L3_NETWORK.uriTemplate(), Subnet.class);
+ public static final AAIObjectType SP_PARTNER = new AAIObjectType(AAINamespaceConstants.BUSINESS, SpPartner.class);
+ public static final AAIObjectType DEVICE = new AAIObjectType(AAINamespaceConstants.NETWORK, Device.class);
+ public static final AAIObjectType EXT_AAI_NETWORK = new AAIObjectType(AAINamespaceConstants.NETWORK, ExtAaiNetwork.class);
+ public static final AAIObjectType AGGREGATE_ROUTE = new AAIObjectType(AAINamespaceConstants.NETWORK, AggregateRoute.class);
+ public static final AAIObjectType L_INTERFACE = new AAIObjectType(AAIObjectType.VSERVER.uriTemplate(), LInterface.class);
+ public static final AAIObjectType UNKNOWN = new AAIObjectType("", "", "unknown");
+ public static final AAIObjectType DSL = new AAIObjectType("/dsl", "", "dsl");
private final String uriTemplate;
private final String parentUri;
private final String partialUri;
private final Class<?> aaiObjectClass;
- private static Map<String, AAIObjectType> map = new HashMap<>();
- private AAIObjectType(String parentUri, String partialUri) {
+ private final String name;
+
+ static {
+ /* Locate any AAIObjectTypes on the classpath and add them to our map */
+ java.util.Collection<URL> packages = ClasspathHelper.forPackage("");
+ Reflections r = new Reflections(new ConfigurationBuilder().setUrls(packages).setScanners(new SubTypesScanner()));
+
+ Set<Class<? extends AAIObjectType>> resources =
+ r.getSubTypesOf(AAIObjectType.class);
+ try {
+ for (Class<? extends AAIObjectType> customTypeClass : resources) {
+ AAIObjectType customType;
+ customType = customTypeClass.newInstance();
+ }
+ } catch (InstantiationException | IllegalAccessException e) {
+ }
+ }
+ protected AAIObjectType() {
+ this.parentUri = null;
+ this.partialUri = null;
+ this.uriTemplate = null;
+ this.aaiObjectClass = null;
+ this.name = null;
+ }
+ protected AAIObjectType(String parentUri, String partialUri, String name) {
this.parentUri = parentUri;
this.partialUri = partialUri;
this.uriTemplate = parentUri + partialUri;
this.aaiObjectClass = null;
+ this.name = name;
+ if (!AAIObjectType.map.containsKey(name)) {
+ AAIObjectType.map.put(name, this);
+ }
}
- private AAIObjectType(String parentUri, Class<?> aaiObjectClass) {
+ protected AAIObjectType(String parentUri, Class<?> aaiObjectClass) {
this.parentUri = parentUri;
this.partialUri = removeParentUri(aaiObjectClass, parentUri);
this.uriTemplate = parentUri + partialUri;
this.aaiObjectClass = aaiObjectClass;
+ this.name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, aaiObjectClass.getSimpleName());
+ if (!AAIObjectType.map.containsKey(name)) {
+ AAIObjectType.map.put(name, this);
+ }
}
@Override
@@ -142,12 +192,6 @@ public enum AAIObjectType implements GraphInventoryObjectType {
}
public static AAIObjectType fromTypeName(String name) {
- if (map.isEmpty()) {
- for (AAIObjectType type : AAIObjectType.values()) {
- map.put(type.typeName(), type);
- }
- }
-
if (map.containsKey(name)) {
return map.get(name);
} else {
@@ -160,12 +204,7 @@ public enum AAIObjectType implements GraphInventoryObjectType {
}
@Override
public String typeName(CaseFormat format) {
- String enumName = this.name();
- if (this.equals(AAIObjectType.DEFAULT_CLOUD_REGION) || this.equals(AAIObjectType.DEFAULT_TENANT)) {
- enumName = enumName.replace("DEFAULT_", "");
- }
-
- return CaseFormat.UPPER_UNDERSCORE.to(format, enumName);
+ return CaseFormat.LOWER_HYPHEN.to(format, this.name.replace("default-", ""));
}
@Override
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
index 87951d516b..288ac9bc7f 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIResourcesClient.java
@@ -36,9 +36,10 @@ import org.onap.so.client.aai.entities.AAIEdgeLabel;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUri;
+import org.onap.so.client.graphinventory.GraphInventoryResourcesClient;
import org.onap.so.client.graphinventory.entities.uri.Depth;
-public class AAIResourcesClient extends AAIClient {
+public class AAIResourcesClient extends AAIClient implements GraphInventoryResourcesClient<AAIResourcesClient, AAIResourceUri, AAIEdgeLabel, AAIResultWrapper, AAITransactionalClient, AAISingleTransactionClient> {
public AAIResourcesClient() {
super();
@@ -49,37 +50,30 @@ public class AAIResourcesClient extends AAIClient {
this.version = version;
}
- /**
- * creates a new object in A&AI
- *
- * @param obj - can be any object which will marshal into a valid A&AI payload
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#create(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.lang.Object)
*/
+ @Override
public void create(AAIResourceUri uri, Object obj) {
RestClient aaiRC = this.createClient(uri);
aaiRC.put(obj);
return;
}
- /**
- * creates a new object in A&AI with no payload body
- *
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#createEmpty(org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public void createEmpty(AAIResourceUri uri) {
RestClient aaiRC = this.createClient(uri);
aaiRC.put("");
return;
}
- /**
- * returns false if the object does not exist in A&AI
- *
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#exists(org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public boolean exists(AAIResourceUri uri) {
AAIUri forceMinimal = this.addParams(Optional.of(Depth.ZERO), true, uri);
try {
@@ -91,12 +85,10 @@ public class AAIResourcesClient extends AAIClient {
}
}
- /**
- * Adds a relationship between two objects in A&AI
- * @param uriA
- * @param uriB
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#connect(org.onap.so.client.aai.entities.uri.AAIResourceUri, org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public void connect(AAIResourceUri uriA, AAIResourceUri uriB) {
AAIResourceUri uriAClone = uriA.clone();
RestClient aaiRC = this.createClient(uriAClone.relationshipAPI());
@@ -104,14 +96,10 @@ public class AAIResourcesClient extends AAIClient {
return;
}
- /**
- * Adds a relationship between two objects in A&AI
- * with a given edge label
- * @param uriA
- * @param uriB
- * @param edge label
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#connect(org.onap.so.client.aai.entities.uri.AAIResourceUri, org.onap.so.client.aai.entities.uri.AAIResourceUri, org.onap.so.client.aai.entities.AAIEdgeLabel)
*/
+ @Override
public void connect(AAIResourceUri uriA, AAIResourceUri uriB, AAIEdgeLabel label) {
AAIResourceUri uriAClone = uriA.clone();
RestClient aaiRC = this.createClient(uriAClone.relationshipAPI());
@@ -119,13 +107,10 @@ public class AAIResourcesClient extends AAIClient {
return;
}
- /**
- * Removes relationship from two objects in A&AI
- *
- * @param uriA
- * @param uriB
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#disconnect(org.onap.so.client.aai.entities.uri.AAIResourceUri, org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public void disconnect(AAIResourceUri uriA, AAIResourceUri uriB) {
AAIResourceUri uriAClone = uriA.clone();
RestClient aaiRC = this.createClient(uriAClone.relationshipAPI());
@@ -133,12 +118,10 @@ public class AAIResourcesClient extends AAIClient {
return;
}
- /**
- * Deletes object from A&AI. Automatically handles resource-version.
- *
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#delete(org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public void delete(AAIResourceUri uri) {
AAIResourceUri clone = uri.clone();
RestClient aaiRC = this.createClient(clone);
@@ -150,23 +133,20 @@ public class AAIResourcesClient extends AAIClient {
return;
}
- /**
- * @param obj - can be any object which will marshal into a valid A&AI payload
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#update(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.lang.Object)
*/
+ @Override
public void update(AAIResourceUri uri, Object obj) {
RestClient aaiRC = this.createClient(uri);
aaiRC.patch(obj);
return;
}
- /**
- * Retrieves an object from A&AI and unmarshalls it into the Class specified
- * @param clazz
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#get(java.lang.Class, org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public <T> Optional<T> get(Class<T> clazz, AAIResourceUri uri) {
try {
return this.createClient(uri).get(clazz);
@@ -179,11 +159,10 @@ public class AAIResourcesClient extends AAIClient {
}
}
- /**
- * Retrieves an object from A&AI and returns complete response
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#getFullResponse(org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public Response getFullResponse(AAIResourceUri uri) {
try {
return this.createClient(uri).get();
@@ -196,12 +175,10 @@ public class AAIResourcesClient extends AAIClient {
}
}
- /**
- * Retrieves an object from A&AI and automatically unmarshalls it into a Map or List
- * @param resultClass
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#get(javax.ws.rs.core.GenericType, org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public <T> Optional<T> get(GenericType<T> resultClass, AAIResourceUri uri) {
try {
return this.createClient(uri).get(resultClass);
@@ -214,12 +191,10 @@ public class AAIResourcesClient extends AAIClient {
}
}
- /**
- * Retrieves an object from A&AI wrapped in a helper class which offer additional features
- *
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#get(org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public AAIResultWrapper get(AAIResourceUri uri) {
String json;
try {
@@ -234,13 +209,10 @@ public class AAIResourcesClient extends AAIClient {
return new AAIResultWrapper(json);
}
- /**
- * Retrieves an object from A&AI wrapped in a helper class which offer additional features
- * If the object cannot be found in A&AI the method will throw the runtime exception
- * included as an argument
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#get(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.lang.Class)
*/
+ @Override
public AAIResultWrapper get(AAIResourceUri uri, Class<? extends RuntimeException> c) {
String json;
try {
@@ -285,13 +257,10 @@ public class AAIResourcesClient extends AAIClient {
return result;
}
- /**
- * Will automatically create the object if it does not exist
- *
- * @param obj - Optional object which serializes to a valid A&AI payload
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#createIfNotExists(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.util.Optional)
*/
+ @Override
public AAIResourcesClient createIfNotExists(AAIResourceUri uri, Optional<Object> obj) {
if(!this.exists(uri)){
if (obj.isPresent()) {
@@ -304,20 +273,18 @@ public class AAIResourcesClient extends AAIClient {
return this;
}
- /**
- * Starts a transaction which encloses multiple A&AI mutations
- *
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#beginTransaction()
*/
+ @Override
public AAITransactionalClient beginTransaction() {
return new AAITransactionalClient(this.getVersion());
}
- /**
- * Starts a transaction groups multiple A&AI mutations
- *
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#beginSingleTransaction()
*/
+ @Override
public AAISingleTransactionClient beginSingleTransaction() {
return new AAISingleTransactionClient(this.getVersion());
}
@@ -333,6 +300,9 @@ public class AAIResourcesClient extends AAIClient {
return clone;
}
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryResourcesClient#getRestProperties()
+ */
@Override
public <T extends RestProperties> T getRestProperties() {
return super.getRestProperties();
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java
index 4f235c35f1..a2651195ee 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java
@@ -28,6 +28,7 @@ import javax.ws.rs.core.Response;
import org.onap.so.client.ResponseExceptionMapper;
import org.onap.so.client.RestClientSSL;
+import org.onap.so.client.graphinventory.GraphInventoryPatchConverter;
import org.onap.so.client.policy.CommonObjectMapperProvider;
import org.onap.so.utils.TargetEntity;
@@ -36,7 +37,7 @@ public class AAIRestClient extends RestClientSSL {
private final AAIProperties aaiProperties;
private static final AAICommonObjectMapperProvider standardProvider = new AAICommonObjectMapperProvider();
- private final AAIPatchConverter patchConverter = new AAIPatchConverter();
+ private final GraphInventoryPatchConverter patchConverter = new GraphInventoryPatchConverter();
protected AAIRestClient(AAIProperties props, URI uri) {
super(props, Optional.of(uri));
@@ -81,7 +82,7 @@ public class AAIRestClient extends RestClientSSL {
return super.patch(convertToPatchFormat(obj), resultClass);
}
- protected AAIPatchConverter getPatchConverter() {
+ protected GraphInventoryPatchConverter getPatchConverter() {
return this.patchConverter;
}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java b/common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java
index 2ecdb7c480..ba65ac3f15 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java
@@ -43,19 +43,21 @@ import org.onap.so.client.aai.entities.singletransaction.SingleTransactionRespon
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.graphinventory.GraphInventoryPatchConverter;
+import org.onap.so.client.graphinventory.GraphInventorySingleTransactionClient;
import org.onap.so.client.graphinventory.exceptions.BulkProcessFailed;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Joiner;
-public class AAISingleTransactionClient extends AAIClient {
+public class AAISingleTransactionClient extends AAIClient implements GraphInventorySingleTransactionClient<AAISingleTransactionClient, AAIResourceUri, AAIEdgeLabel> {
private final SingleTransactionRequest request;
private final AAIVersion version;
private int actionCount = 0;
- private final AAIPatchConverter patchConverter = new AAIPatchConverter();
+ private final GraphInventoryPatchConverter patchConverter = new GraphInventoryPatchConverter();
protected AAISingleTransactionClient(AAIVersion version) {
super();
@@ -63,37 +65,30 @@ public class AAISingleTransactionClient extends AAIClient {
this.request = new SingleTransactionRequest();
}
- /**
- * creates a new object in A&AI
- *
- * @param obj - can be any object which will marshal into a valid A&AI payload
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionClient#create(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.lang.Object)
*/
+ @Override
public AAISingleTransactionClient create(AAIResourceUri uri, Object obj) {
request.getOperations().add(new OperationBodyRequest().withAction("put").withUri(uri.build().toString()).withBody(obj));
incrementActionAmount();
return this;
}
- /**
- * creates a new object in A&AI with no payload body
- *
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionClient#createEmpty(org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public AAISingleTransactionClient createEmpty(AAIResourceUri uri) {
request.getOperations().add(new OperationBodyRequest().withAction("put").withUri(uri.build().toString()).withBody(new HashMap<String, String>()));
incrementActionAmount();
return this;
}
- /**
- * Adds a relationship between two objects in A&AI
- * @param uriA
- * @param uriB
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionClient#connect(org.onap.so.client.aai.entities.uri.AAIResourceUri, org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public AAISingleTransactionClient connect(AAIResourceUri uriA, AAIResourceUri uriB) {
AAIResourceUri uriAClone = uriA.clone();
request.getOperations().add(new OperationBodyRequest().withAction("put").withUri(uriAClone.relationshipAPI().build().toString()).withBody(this.buildRelationship(uriB)));
@@ -101,13 +96,10 @@ public class AAISingleTransactionClient extends AAIClient {
return this;
}
- /**
- * relationship between multiple objects in A&AI - connects A to all objects specified in list
- *
- * @param uriA
- * @param uris
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionClient#connect(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.util.List)
*/
+ @Override
public AAISingleTransactionClient connect(AAIResourceUri uriA, List<AAIResourceUri> uris) {
for (AAIResourceUri uri : uris) {
this.connect(uriA, uri);
@@ -115,6 +107,10 @@ public class AAISingleTransactionClient extends AAIClient {
return this;
}
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionClient#connect(org.onap.so.client.aai.entities.uri.AAIResourceUri, org.onap.so.client.aai.entities.uri.AAIResourceUri, org.onap.so.client.aai.entities.AAIEdgeLabel)
+ */
+ @Override
public AAISingleTransactionClient connect(AAIResourceUri uriA, AAIResourceUri uriB, AAIEdgeLabel label) {
AAIResourceUri uriAClone = uriA.clone();
RestClient aaiRC = this.createClient(uriAClone.relationshipAPI());
@@ -122,6 +118,10 @@ public class AAISingleTransactionClient extends AAIClient {
return this;
}
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionClient#connect(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.util.List, org.onap.so.client.aai.entities.AAIEdgeLabel)
+ */
+ @Override
public AAISingleTransactionClient connect(AAIResourceUri uriA, List<AAIResourceUri> uris, AAIEdgeLabel label) {
for (AAIResourceUri uri : uris) {
this.connect(uriA, uri, label);
@@ -129,13 +129,10 @@ public class AAISingleTransactionClient extends AAIClient {
return this;
}
- /**
- * Removes relationship from two objects in A&AI
- *
- * @param uriA
- * @param uriB
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionClient#disconnect(org.onap.so.client.aai.entities.uri.AAIResourceUri, org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public AAISingleTransactionClient disconnect(AAIResourceUri uriA, AAIResourceUri uriB) {
AAIResourceUri uriAClone = uriA.clone();
request.getOperations().add(new OperationBodyRequest().withAction("delete").withUri(uriAClone.relationshipAPI().build().toString()).withBody(this.buildRelationship(uriB)));
@@ -143,24 +140,20 @@ public class AAISingleTransactionClient extends AAIClient {
return this;
}
- /**
- * Removes relationship from multiple objects - disconnects A from all objects specified in list
- * @param uriA
- * @param uris
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionClient#disconnect(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.util.List)
*/
+ @Override
public AAISingleTransactionClient disconnect(AAIResourceUri uriA, List<AAIResourceUri> uris) {
for (AAIResourceUri uri : uris) {
this.disconnect(uriA, uri);
}
return this;
}
- /**
- * Deletes object from A&AI. Automatically handles resource-version.
- *
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionClient#delete(org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public AAISingleTransactionClient delete(AAIResourceUri uri) {
AAIResourcesClient client = new AAIResourcesClient();
AAIResourceUri clone = uri.clone();
@@ -172,11 +165,10 @@ public class AAISingleTransactionClient extends AAIClient {
return this;
}
- /**
- * @param obj - can be any object which will marshal into a valid A&AI payload
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionClient#update(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.lang.Object)
*/
+ @Override
public AAISingleTransactionClient update(AAIResourceUri uri, Object obj) {
final String payload = getPatchConverter().convertPatchFormat(obj);
@@ -188,10 +180,10 @@ public class AAISingleTransactionClient extends AAIClient {
private void incrementActionAmount() {
actionCount++;
}
- /**
- * Executes all created transactions in A&AI
- * @throws BulkProcessFailed
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionClient#execute()
*/
+ @Override
public void execute() throws BulkProcessFailed {
RestClient client = this.createClient(AAIUriFactory.createResourceUri(AAIObjectType.SINGLE_TRANSACTION));
try {
@@ -261,7 +253,7 @@ public class AAISingleTransactionClient extends AAIClient {
return this.request;
}
- protected AAIPatchConverter getPatchConverter() {
+ protected GraphInventoryPatchConverter getPatchConverter() {
return this.patchConverter;
}
}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java b/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java
index 118a3edf1c..dd4cb2f591 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java
@@ -20,8 +20,6 @@
package org.onap.so.client.aai;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -42,8 +40,9 @@ import org.onap.so.client.aai.entities.bulkprocess.OperationBody;
import org.onap.so.client.aai.entities.bulkprocess.Transaction;
import org.onap.so.client.aai.entities.bulkprocess.Transactions;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.graphinventory.GraphInventoryPatchConverter;
+import org.onap.so.client.graphinventory.GraphInventoryTransactionalClient;
import org.onap.so.client.graphinventory.exceptions.BulkProcessFailed;
import org.onap.so.jsonpath.JsonPathUtil;
@@ -51,14 +50,14 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Joiner;
-public class AAITransactionalClient extends AAIClient {
+public class AAITransactionalClient extends AAIClient implements GraphInventoryTransactionalClient<AAITransactionalClient, AAIResourceUri, AAIEdgeLabel> {
private final Transactions transactions;
private Transaction currentTransaction;
private final AAIVersion version;
private int actionCount = 0;
- private final AAIPatchConverter patchConverter = new AAIPatchConverter();
+ private final GraphInventoryPatchConverter patchConverter = new GraphInventoryPatchConverter();
protected AAITransactionalClient(AAIVersion version) {
super();
@@ -73,47 +72,39 @@ public class AAITransactionalClient extends AAIClient {
currentTransaction = transaction;
}
- /**
- * adds an additional transaction and closes the previous transaction
- *
- * @return AAITransactionalClient
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionalClient#beginNewTransaction()
*/
+ @Override
public AAITransactionalClient beginNewTransaction() {
startTransaction();
return this;
}
- /**
- * creates a new object in A&AI
- *
- * @param obj - can be any object which will marshal into a valid A&AI payload
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionalClient#create(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.lang.Object)
*/
+ @Override
public AAITransactionalClient create(AAIResourceUri uri, Object obj) {
currentTransaction.getPut().add(new OperationBody().withUri(uri.build().toString()).withBody(obj));
incrementActionAmount();
return this;
}
- /**
- * creates a new object in A&AI with no payload body
- *
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionalClient#createEmpty(org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public AAITransactionalClient createEmpty(AAIResourceUri uri) {
currentTransaction.getPut().add(new OperationBody().withUri(uri.build().toString()).withBody(new HashMap<String, String>()));
incrementActionAmount();
return this;
}
- /**
- * Adds a relationship between two objects in A&AI
- * @param uriA
- * @param uriB
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionalClient#connect(org.onap.so.client.aai.entities.uri.AAIResourceUri, org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public AAITransactionalClient connect(AAIResourceUri uriA, AAIResourceUri uriB) {
AAIResourceUri uriAClone = uriA.clone();
currentTransaction.getPut().add(new OperationBody().withUri(uriAClone.relationshipAPI().build().toString()).withBody(this.buildRelationship(uriB)));
@@ -121,13 +112,10 @@ public class AAITransactionalClient extends AAIClient {
return this;
}
- /**
- * relationship between multiple objects in A&AI - connects A to all objects specified in list
- *
- * @param uriA
- * @param uris
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionalClient#connect(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.util.List)
*/
+ @Override
public AAITransactionalClient connect(AAIResourceUri uriA, List<AAIResourceUri> uris) {
for (AAIResourceUri uri : uris) {
this.connect(uriA, uri);
@@ -135,6 +123,10 @@ public class AAITransactionalClient extends AAIClient {
return this;
}
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionalClient#connect(org.onap.so.client.aai.entities.uri.AAIResourceUri, org.onap.so.client.aai.entities.uri.AAIResourceUri, org.onap.so.client.aai.entities.AAIEdgeLabel)
+ */
+ @Override
public AAITransactionalClient connect(AAIResourceUri uriA, AAIResourceUri uriB, AAIEdgeLabel label) {
AAIResourceUri uriAClone = uriA.clone();
RestClient aaiRC = this.createClient(uriAClone.relationshipAPI());
@@ -142,6 +134,10 @@ public class AAITransactionalClient extends AAIClient {
return this;
}
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionalClient#connect(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.util.List, org.onap.so.client.aai.entities.AAIEdgeLabel)
+ */
+ @Override
public AAITransactionalClient connect(AAIResourceUri uriA, List<AAIResourceUri> uris, AAIEdgeLabel label) {
for (AAIResourceUri uri : uris) {
this.connect(uriA, uri, label);
@@ -149,13 +145,10 @@ public class AAITransactionalClient extends AAIClient {
return this;
}
- /**
- * Removes relationship from two objects in A&AI
- *
- * @param uriA
- * @param uriB
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionalClient#disconnect(org.onap.so.client.aai.entities.uri.AAIResourceUri, org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public AAITransactionalClient disconnect(AAIResourceUri uriA, AAIResourceUri uriB) {
AAIResourceUri uriAClone = uriA.clone();
currentTransaction.getDelete().add(new OperationBody().withUri(uriAClone.relationshipAPI().build().toString()).withBody(this.buildRelationship(uriB)));
@@ -163,24 +156,20 @@ public class AAITransactionalClient extends AAIClient {
return this;
}
- /**
- * Removes relationship from multiple objects - disconnects A from all objects specified in list
- * @param uriA
- * @param uris
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionalClient#disconnect(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.util.List)
*/
+ @Override
public AAITransactionalClient disconnect(AAIResourceUri uriA, List<AAIResourceUri> uris) {
for (AAIResourceUri uri : uris) {
this.disconnect(uriA, uri);
}
return this;
}
- /**
- * Deletes object from A&AI. Automatically handles resource-version.
- *
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionalClient#delete(org.onap.so.client.aai.entities.uri.AAIResourceUri)
*/
+ @Override
public AAITransactionalClient delete(AAIResourceUri uri) {
AAIResourcesClient client = new AAIResourcesClient();
AAIResourceUri clone = uri.clone();
@@ -192,11 +181,10 @@ public class AAITransactionalClient extends AAIClient {
return this;
}
- /**
- * @param obj - can be any object which will marshal into a valid A&AI payload
- * @param uri
- * @return
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionalClient#update(org.onap.so.client.aai.entities.uri.AAIResourceUri, java.lang.Object)
*/
+ @Override
public AAITransactionalClient update(AAIResourceUri uri, Object obj) {
final String payload = getPatchConverter().convertPatchFormat(obj);
currentTransaction.getPatch().add(new OperationBody().withUri(uri.build().toString()).withBody(payload));
@@ -207,10 +195,10 @@ public class AAITransactionalClient extends AAIClient {
private void incrementActionAmount() {
actionCount++;
}
- /**
- * Executes all created transactions in A&AI
- * @throws BulkProcessFailed
+ /* (non-Javadoc)
+ * @see org.onap.so.client.aai.GraphInventoryTransactionalClient#execute()
*/
+ @Override
public void execute() throws BulkProcessFailed {
RestClient client = this.createClient(AAIUriFactory.createResourceUri(AAIObjectType.BULK_PROCESS));
try {
@@ -293,7 +281,7 @@ public class AAITransactionalClient extends AAIClient {
return this.transactions;
}
- protected AAIPatchConverter getPatchConverter() {
+ protected GraphInventoryPatchConverter getPatchConverter() {
return this.patchConverter;
}
}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java b/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java
index 77ea9bcdfe..9b3f98baa4 100644
--- a/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java
+++ b/common/src/main/java/org/onap/so/client/aai/entities/AAIResultWrapper.java
@@ -20,96 +20,22 @@
package org.onap.so.client.aai.entities;
-import java.io.IOException;
import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-
-import org.onap.so.client.aai.AAICommonObjectMapperProvider;
-import org.onap.so.jsonpath.JsonPathUtil;
+import org.onap.so.client.graphinventory.entities.GraphInventoryResultWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class AAIResultWrapper implements Serializable {
+public class AAIResultWrapper extends GraphInventoryResultWrapper implements Serializable {
private static final long serialVersionUID = 5895841925807816737L;
- private final String jsonBody;
- private final ObjectMapper mapper;
- private final transient Logger logger = LoggerFactory.getLogger(AAIResultWrapper.class);
+ private final static transient Logger logger = LoggerFactory.getLogger(AAIResultWrapper.class);
public AAIResultWrapper(String json) {
- this.jsonBody = json;
- this.mapper = new AAICommonObjectMapperProvider().getMapper();
+ super(json, logger);
}
public AAIResultWrapper(Object aaiObject) {
- this.mapper = new AAICommonObjectMapperProvider().getMapper();
- this.jsonBody = mapObjectToString(aaiObject);
- }
-
- protected String mapObjectToString(Object aaiObject) {
- try {
- return mapper.writeValueAsString(aaiObject);
- } catch (JsonProcessingException e) {
- logger.warn("could not parse object into json - defaulting to {}");
- return "{}";
- }
+ super(aaiObject, logger);
}
- public Optional<Relationships> getRelationships() {
- final String path = "$.relationship-list";
- if (isEmpty()) {
- return Optional.empty();
- }
- Optional<String> result = JsonPathUtil.getInstance().locateResult(jsonBody, path);
- if (result.isPresent()) {
- return Optional.of(new Relationships(result.get()));
- } else {
- return Optional.empty();
- }
- }
-
- public String getJson() {
- if(jsonBody == null) {
- return "{}";
- } else {
- return jsonBody;
- }
- }
-
- public Map<String, Object> asMap() {
- if (isEmpty()) {
- return new HashMap<>();
- }
- try {
- return mapper.readValue(this.jsonBody, new TypeReference<Map<String, Object>>(){});
- } catch (IOException e) {
- return new HashMap<>();
- }
- }
-
- public <T> Optional<T> asBean(Class<T> clazz) {
- if (isEmpty()) {
- return Optional.empty();
- }
- try {
- return Optional.of(mapper.readValue(this.jsonBody, clazz));
- } catch (IOException e) {
- return Optional.empty();
- }
- }
-
- public boolean isEmpty() {
- return jsonBody == null;
- }
- @Override
- public String toString() {
- return this.getJson();
- }
-
}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/DSLNode.java b/common/src/main/java/org/onap/so/client/aai/entities/DSLNode.java
new file mode 100644
index 0000000000..f94c28c5b7
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/DSLNode.java
@@ -0,0 +1,75 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.aai.entities;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.onap.so.client.graphinventory.GraphInventoryObjectName;
+
+public class DSLNode implements QueryStep {
+
+ private final String nodeName;
+ private final List<DSLNodeKey> nodeKeys;
+ private final StringBuilder query = new StringBuilder();
+ private boolean output = false;
+
+ public DSLNode() {
+ this.nodeName = "";
+ this.nodeKeys = new ArrayList<>();
+
+ }
+ public DSLNode(GraphInventoryObjectName name) {
+ this.nodeName = name.typeName();
+ this.nodeKeys = new ArrayList<>();
+ query.append(nodeName);
+ }
+ public DSLNode(GraphInventoryObjectName name, DSLNodeKey... key) {
+ this.nodeName = name.typeName();
+ this.nodeKeys = Arrays.asList(key);
+ query.append(nodeName);
+ }
+
+ public DSLNode output() {
+ this.output = true;
+
+ return this;
+ }
+
+ public DSLNode and(DSLNodeKey... key) {
+ this.nodeKeys.addAll(Arrays.asList(key));
+
+ return this;
+ }
+
+ @Override
+ public String build() {
+ if (output) {
+ query.append("*");
+ }
+ for (DSLNodeKey key : nodeKeys) {
+ query.append(key.build());
+ }
+
+ return query.toString();
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/DSLNodeKey.java b/common/src/main/java/org/onap/so/client/aai/entities/DSLNodeKey.java
new file mode 100644
index 0000000000..a9795d1cc3
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/DSLNodeKey.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.aai.entities;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import com.google.common.base.Joiner;
+
+
+public class DSLNodeKey implements QueryStep {
+
+ private boolean not = false;
+ private final StringBuilder query = new StringBuilder();
+ private final String keyName;
+ private final List<String> values;
+ public DSLNodeKey(String keyName, String... value) {
+
+ this.keyName = keyName;
+ this.values = Arrays.asList(value);
+ }
+
+ public DSLNodeKey not() {
+
+ this.not = true;
+ return this;
+ }
+
+ @Override
+ public String build() {
+
+ if (not) {
+ query.append(" !");
+ }
+ query.append("('").append(keyName).append("', ");
+ List<String> temp = new ArrayList<>();
+ for (String item : values) {
+ if (item.equals("null")) {
+ temp.add(String.format("' %s '", item));
+ } else if (item.equals("")){
+ temp.add("' '");
+ } else {
+ temp.add(String.format("'%s'", item));
+ }
+ }
+ query.append(Joiner.on(", ").join(temp)).append(")");
+
+ return query.toString();
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/DSLQuery.java b/common/src/main/java/org/onap/so/client/aai/entities/DSLQuery.java
new file mode 100644
index 0000000000..0f4095177a
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/DSLQuery.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.aai.entities;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class DSLQuery {
+
+ private String dsl;
+
+ public DSLQuery() {
+
+ }
+
+ public DSLQuery(String dsl) {
+ this.dsl = dsl;
+ }
+
+ public String getDsl() {
+ return dsl;
+ }
+
+ public void setDsl(String dsl) {
+ this.dsl = dsl;
+ }
+
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/DSLQueryBuilder.java b/common/src/main/java/org/onap/so/client/aai/entities/DSLQueryBuilder.java
new file mode 100644
index 0000000000..9f1dbeda8f
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/DSLQueryBuilder.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.aai.entities;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import com.google.common.base.Joiner;
+
+
+public class DSLQueryBuilder<S, E> implements QueryStep {
+
+ private List<QueryStep> steps = new ArrayList<>();
+
+
+ public DSLQueryBuilder() {
+
+ }
+ public DSLQueryBuilder(DSLNode node) {
+ steps.add(node);
+ }
+
+ public DSLQueryBuilder<S, DSLNode> node(DSLNode node) {
+ steps.add(node);
+
+ return (DSLQueryBuilder<S, DSLNode>) this;
+ }
+ public DSLQueryBuilder<S, E> output() {
+ if (steps.get(steps.size() -1) instanceof DSLNode) {
+ ((DSLNode)steps.get(steps.size() -1)).output();
+ }
+ return this;
+ }
+
+ public <E2> DSLQueryBuilder<S, E2> union(final DSLQueryBuilder<?, E2>... union) {
+
+ List<DSLQueryBuilder<?, ?>> unions = Arrays.asList(union);
+ steps.add(() -> {
+ StringBuilder query = new StringBuilder();
+
+ query.append("> [ ").append(
+ Joiner.on(", ").join(
+ unions.stream().map(item -> item.build()).collect(Collectors.toList())))
+ .append(" ]");
+ return query.toString();
+ });
+
+ return (DSLQueryBuilder<S, E2>) this;
+ }
+
+ public DSLQueryBuilder<S, E> where(DSLQueryBuilder<?, ?> where) {
+
+ steps.add(() -> {
+ StringBuilder query = new StringBuilder();
+ query.append(where.build()).append(")");
+ String result = query.toString();
+ if (!result.startsWith(">")) {
+ result = "> " + result;
+ }
+ return "(" + result;
+ });
+ return this;
+ }
+
+ public DSLQueryBuilder<S, E> to(DSLQueryBuilder<?, ?> to) {
+ steps.add(() -> {
+ StringBuilder query = new StringBuilder();
+
+ query.append("> ").append(to.build());
+ return query.toString();
+ });
+ return this;
+ }
+
+ public String limit(int limit) {
+ return compile() + " LIMIT " + limit;
+ }
+
+ @Override
+ public String build() {
+ return compile();
+ }
+
+ private String compile() {
+ return Joiner.on(" ").join(steps.stream().map(item -> item.build()).collect(Collectors.toList()));
+ }
+
+ protected QueryStep getFirst() {
+ return steps.get(0);
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/QueryStep.java b/common/src/main/java/org/onap/so/client/aai/entities/QueryStep.java
new file mode 100644
index 0000000000..b056fd0e40
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/QueryStep.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.aai.entities;
+
+@FunctionalInterface
+public interface QueryStep {
+
+
+ public String build();
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java b/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
index bab145b3fd..e907bc97d7 100644
--- a/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
+++ b/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
@@ -91,11 +91,7 @@ public class Relationships {
final String relatedTo = (String)relationship.get("related-to");
if (p.test(relatedTo)) {
AAIObjectType type;
- try {
- type = AAIObjectType.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, relatedTo));
- } catch (IllegalArgumentException e) {
- type = AAIObjectType.UNKNOWN;
- }
+ type = AAIObjectType.fromTypeName(relatedTo);
final String relatedLink = (String)relationship.get("related-link");
result.add(AAIUriFactory.createResourceFromExistingURI(type, UriBuilder.fromPath(relatedLink).build()));
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/__.java b/common/src/main/java/org/onap/so/client/aai/entities/__.java
new file mode 100644
index 0000000000..16d6f9b27e
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/aai/entities/__.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.aai.entities;
+
+import org.onap.so.client.graphinventory.GraphInventoryObjectName;
+
+public class __ {
+
+ protected __() {
+
+ }
+
+ public static <A> DSLQueryBuilder<A, A> identity() {
+ return new DSLQueryBuilder<>();
+ }
+ public static <A> DSLQueryBuilder<A, A> start(DSLNode node) {
+ return new DSLQueryBuilder<>(node);
+ }
+ public static DSLQueryBuilder<DSLNode, DSLNode> node(GraphInventoryObjectName name) {
+
+ return __.<DSLNode>start(new DSLNode(name));
+ }
+
+ public static DSLQueryBuilder<DSLNode, DSLNode> node(GraphInventoryObjectName name, DSLNodeKey... key) {
+ return __.<DSLNode>start(new DSLNode(name, key));
+ }
+
+ public static DSLNodeKey key(String keyName, String... value) {
+ return new DSLNodeKey(keyName, value);
+ }
+
+ public static <A, B> DSLQueryBuilder<A, B> union(final DSLQueryBuilder<?, B>... traversal) {
+
+ return __.<A>identity().union(traversal);
+ }
+
+public static <A> DSLQueryBuilder<A, A> where(DSLQueryBuilder<A, A> traversal) {
+
+ return __.<A>identity().where(traversal);
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java b/common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java
deleted file mode 100644
index 02d8d56867..0000000000
--- a/common/src/main/java/org/onap/so/client/aai/objects/AAIOperationalEnvironment.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.so.client.aai.objects;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
-@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({
-"operational-environment-id",
-"operational-environment-name",
-"operational-environment-type",
-"operational-environment-status",
-"tenant-context",
-"workload-context",
-"resource-version"
-})
-public class AAIOperationalEnvironment {
-
-@JsonProperty("operational-environment-id")
-private String operationalEnvironmentId;
-@JsonProperty("operational-environment-name")
-private String operationalEnvironmentName;
-@JsonProperty("operational-environment-type")
-private String operationalEnvironmentType;
-@JsonProperty("operational-environment-status")
-private String operationalEnvironmentStatus;
-@JsonProperty("tenant-context")
-private String tenantContext;
-@JsonProperty("workload-context")
-private String workloadContext;
-@JsonProperty("resource-version")
-private String resourceVersion;
-
-@JsonProperty("operational-environment-id")
-public String getOperationalEnvironmentId() {
-return operationalEnvironmentId;
- }
-
-@JsonProperty("operational-environment-id")
-public void setOperationalEnvironmentId(String operationalEnvironmentId) {
-this.operationalEnvironmentId = operationalEnvironmentId;
- }
-
-public AAIOperationalEnvironment withOperationalEnvironmentId(String operationalEnvironmentId) {
-this.operationalEnvironmentId = operationalEnvironmentId;
-return this;
- }
-
-@JsonProperty("operational-environment-name")
-public String getOperationalEnvironmentName() {
-return operationalEnvironmentName;
- }
-
-@JsonProperty("operational-environment-name")
-public void setOperationalEnvironmentName(String operationalEnvironmentName) {
-this.operationalEnvironmentName = operationalEnvironmentName;
- }
-
-public AAIOperationalEnvironment withOperationalEnvironmentName(String operationalEnvironmentName) {
-this.operationalEnvironmentName = operationalEnvironmentName;
-return this;
- }
-
-@JsonProperty("operational-environment-type")
-public String getOperationalEnvironmentType() {
-return operationalEnvironmentType;
- }
-
-@JsonProperty("operational-environment-type")
-public void setOperationalEnvironmentType(String operationalEnvironmentType) {
-this.operationalEnvironmentType = operationalEnvironmentType;
- }
-
-public AAIOperationalEnvironment withOperationalEnvironmentType(String operationalEnvironmentType) {
-this.operationalEnvironmentType = operationalEnvironmentType;
-return this;
- }
-
-@JsonProperty("operational-environment-status")
-public String getOperationalEnvironmentStatus() {
-return operationalEnvironmentStatus;
- }
-
-@JsonProperty("operational-environment-status")
-public void setOperationalEnvironmentStatus(String operationalEnvironmentStatus) {
-this.operationalEnvironmentStatus = operationalEnvironmentStatus;
- }
-
-public AAIOperationalEnvironment withOperationalEnvironmentStatus(String operationalEnvironmentStatus) {
-this.operationalEnvironmentStatus = operationalEnvironmentStatus;
-return this;
- }
-
-@JsonProperty("tenant-context")
-public String getTenantContext() {
-return tenantContext;
- }
-
-@JsonProperty("tenant-context")
-public void setTenantContext(String tenantContext) {
-this.tenantContext = tenantContext;
- }
-
-public AAIOperationalEnvironment withTenantContext(String tenantContext) {
-this.tenantContext = tenantContext;
-return this;
- }
-
-@JsonProperty("workload-context")
-public String getWorkloadContext() {
-return workloadContext;
- }
-
-@JsonProperty("workload-context")
-public void setWorkloadContext(String workloadContext) {
-this.workloadContext = workloadContext;
- }
-
-public AAIOperationalEnvironment withWorkloadContext(String workloadContext) {
-this.workloadContext = workloadContext;
-return this;
- }
-
-@JsonProperty("resource-version")
-public String getResourceVersion() {
-return resourceVersion;
- }
-
-@JsonProperty("resource-version")
-public void setResourceVersion(String resourceVersion) {
-this.resourceVersion = resourceVersion;
- }
-
-public AAIOperationalEnvironment withResourceVersion(String resourceVersion) {
-this.resourceVersion = resourceVersion;
-return this;
- }
-
-}
diff --git a/common/src/main/java/org/onap/so/client/aai/EmptyStringToNullSerializer.java b/common/src/main/java/org/onap/so/client/graphinventory/EmptyStringToNullSerializer.java
index 1120ebe0b9..e21386f809 100644
--- a/common/src/main/java/org/onap/so/client/aai/EmptyStringToNullSerializer.java
+++ b/common/src/main/java/org/onap/so/client/graphinventory/EmptyStringToNullSerializer.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.client.aai;
+package org.onap.so.client.graphinventory;
import java.io.IOException;
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryCommonObjectMapperPatchProvider.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryCommonObjectMapperPatchProvider.java
new file mode 100644
index 0000000000..47c9e77b84
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryCommonObjectMapperPatchProvider.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.graphinventory;
+
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
+public class GraphInventoryCommonObjectMapperPatchProvider extends GraphInventoryCommonObjectMapperProvider {
+
+
+ public GraphInventoryCommonObjectMapperPatchProvider() {
+ super();
+ EmptyStringToNullSerializer sp = new EmptyStringToNullSerializer();
+ SimpleModule emptyStringModule = new SimpleModule();
+ emptyStringModule.addSerializer(String.class, sp);
+ mapper.registerModule(emptyStringModule);
+ }
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryCommonObjectMapperProvider.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryCommonObjectMapperProvider.java
new file mode 100644
index 0000000000..f9857424a2
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryCommonObjectMapperProvider.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.graphinventory;
+
+import org.onap.so.client.policy.CommonObjectMapperProvider;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.AnnotationIntrospector;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
+
+public class GraphInventoryCommonObjectMapperProvider extends CommonObjectMapperProvider {
+
+ public GraphInventoryCommonObjectMapperProvider() {
+ mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+ mapper.enable(MapperFeature.USE_ANNOTATIONS);
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
+ mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ AnnotationIntrospector aiJaxb = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
+ AnnotationIntrospector aiJackson = new JacksonAnnotationIntrospector();
+ // first Jaxb, second Jackson annotations
+ mapper.setAnnotationIntrospector(AnnotationIntrospector.pair(aiJaxb, aiJackson));
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIPatchConverter.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryPatchConverter.java
index 6ccb592409..00e597b189 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIPatchConverter.java
+++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryPatchConverter.java
@@ -18,29 +18,31 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.client.aai;
+package org.onap.so.client.graphinventory;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
+import org.onap.so.client.aai.AAICommonObjectMapperPatchProvider;
+import org.onap.so.client.aai.AAICommonObjectMapperProvider;
import org.onap.so.client.graphinventory.exceptions.GraphInventoryPatchDepthExceededException;
import org.onap.so.jsonpath.JsonPathUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
-public class AAIPatchConverter {
+public class GraphInventoryPatchConverter {
private static final AAICommonObjectMapperProvider standardProvider = new AAICommonObjectMapperProvider();
private static final AAICommonObjectMapperPatchProvider patchProvider = new AAICommonObjectMapperPatchProvider();
private static final Pattern LOCATE_COMPLEX_OBJECT = Pattern.compile("^((?!relationship-list).)+?\\['[^\\[\\]]+?'\\]$");
- protected String convertPatchFormat(Object obj) {
+ public String convertPatchFormat(Object obj) {
return validatePatchObject(marshallObjectToPatchFormat(obj));
}
- protected String validatePatchObject(String payload) {
+ public String validatePatchObject(String payload) {
if (hasComplexObject(payload)) {
throw new GraphInventoryPatchDepthExceededException(payload);
}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryResourcesClient.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryResourcesClient.java
new file mode 100644
index 0000000000..7fbe286b98
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryResourcesClient.java
@@ -0,0 +1,147 @@
+package org.onap.so.client.graphinventory;
+
+import java.util.Optional;
+
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.Response;
+
+import org.onap.so.client.RestProperties;
+import org.onap.so.client.graphinventory.entities.GraphInventoryEdgeLabel;
+import org.onap.so.client.graphinventory.entities.GraphInventoryResultWrapper;
+import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri;
+
+public interface GraphInventoryResourcesClient<Self, Uri extends GraphInventoryUri, EdgeLabel extends GraphInventoryEdgeLabel, Wrapper extends GraphInventoryResultWrapper, TransactionalClient, SingleTransactionClient> {
+
+ /**
+ * creates a new object in GraphInventory
+ *
+ * @param obj - can be any object which will marshal into a valid GraphInventory payload
+ * @param uri
+ * @return
+ */
+ void create(Uri uri, Object obj);
+
+ /**
+ * creates a new object in GraphInventory with no payload body
+ *
+ * @param uri
+ * @return
+ */
+ void createEmpty(Uri uri);
+
+ /**
+ * returns false if the object does not exist in GraphInventory
+ *
+ * @param uri
+ * @return
+ */
+ boolean exists(Uri uri);
+
+ /**
+ * Adds a relationship between two objects in GraphInventory
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ void connect(Uri uriA, Uri uriB);
+
+ /**
+ * Adds a relationship between two objects in GraphInventory
+ * with a given edge label
+ * @param uriA
+ * @param uriB
+ * @param edge label
+ * @return
+ */
+ void connect(Uri uriA, Uri uriB, EdgeLabel label);
+
+ /**
+ * Removes relationship from two objects in GraphInventory
+ *
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ void disconnect(Uri uriA, Uri uriB);
+
+ /**
+ * Deletes object from GraphInventory. Automatically handles resource-version.
+ *
+ * @param uri
+ * @return
+ */
+ void delete(Uri uri);
+
+ /**
+ * @param obj - can be any object which will marshal into a valid GraphInventory payload
+ * @param uri
+ * @return
+ */
+ void update(Uri uri, Object obj);
+
+ /**
+ * Retrieves an object from GraphInventory and unmarshalls it into the Class specified
+ * @param clazz
+ * @param uri
+ * @return
+ */
+ <T> Optional<T> get(Class<T> clazz, Uri uri);
+
+ /**
+ * Retrieves an object from GraphInventory and returns complete response
+ * @param uri
+ * @return
+ */
+ Response getFullResponse(Uri uri);
+
+ /**
+ * Retrieves an object from GraphInventory and automatically unmarshalls it into a Map or List
+ * @param resultClass
+ * @param uri
+ * @return
+ */
+ <T> Optional<T> get(GenericType<T> resultClass, Uri uri);
+
+ /**
+ * Retrieves an object from GraphInventory wrapped in a helper class which offer additional features
+ *
+ * @param uri
+ * @return
+ */
+ Wrapper get(Uri uri);
+
+ /**
+ * Retrieves an object from GraphInventory wrapped in a helper class which offer additional features
+ * If the object cannot be found in GraphInventory the method will throw the runtime exception
+ * included as an argument
+ * @param uri
+ * @return
+ */
+ Wrapper get(Uri uri, Class<? extends RuntimeException> c);
+
+ /**
+ * Will automatically create the object if it does not exist
+ *
+ * @param obj - Optional object which serializes to a valid GraphInventory payload
+ * @param uri
+ * @return
+ */
+ Self createIfNotExists(Uri uri, Optional<Object> obj);
+
+ /**
+ * Starts a transaction which encloses multiple GraphInventory mutations
+ *
+ * @return
+ */
+ TransactionalClient beginTransaction();
+
+ /**
+ * Starts a transaction groups multiple GraphInventory mutations
+ *
+ * @return
+ */
+ SingleTransactionClient beginSingleTransaction();
+
+ <T extends RestProperties> T getRestProperties();
+
+} \ No newline at end of file
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventorySingleTransactionClient.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventorySingleTransactionClient.java
new file mode 100644
index 0000000000..e1aa2252d9
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventorySingleTransactionClient.java
@@ -0,0 +1,87 @@
+package org.onap.so.client.graphinventory;
+
+import java.util.List;
+
+import org.onap.so.client.graphinventory.entities.GraphInventoryEdgeLabel;
+import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri;
+import org.onap.so.client.graphinventory.exceptions.BulkProcessFailed;
+
+public interface GraphInventorySingleTransactionClient<Self, Uri extends GraphInventoryUri, EdgeLabel extends GraphInventoryEdgeLabel> {
+
+ /**
+ * creates a new object in A&AI
+ *
+ * @param obj - can be any object which will marshal into a valid A&AI payload
+ * @param uri
+ * @return
+ */
+ Self create(Uri uri, Object obj);
+
+ /**
+ * creates a new object in A&AI with no payload body
+ *
+ * @param uri
+ * @return
+ */
+ Self createEmpty(Uri uri);
+
+ /**
+ * Adds a relationship between two objects in A&AI
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ Self connect(Uri uriA, Uri uriB);
+
+ /**
+ * relationship between multiple objects in A&AI - connects A to all objects specified in list
+ *
+ * @param uriA
+ * @param uris
+ * @return
+ */
+ Self connect(Uri uriA, List<Uri> uris);
+
+ Self connect(Uri uriA, Uri uriB, EdgeLabel label);
+
+ Self connect(Uri uriA, List<Uri> uris, EdgeLabel label);
+
+ /**
+ * Removes relationship from two objects in A&AI
+ *
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ Self disconnect(Uri uriA, Uri uriB);
+
+ /**
+ * Removes relationship from multiple objects - disconnects A from all objects specified in list
+ * @param uriA
+ * @param uris
+ * @return
+ */
+ Self disconnect(Uri uriA, List<Uri> uris);
+
+ /**
+ * Deletes object from A&AI. Automatically handles resource-version.
+ *
+ * @param uri
+ * @return
+ */
+ Self delete(Uri uri);
+
+ /**
+ * @param obj - can be any object which will marshal into a valid A&AI payload
+ * @param uri
+ * @return
+ */
+ Self update(Uri uri, Object obj);
+
+ /**
+ * Executes all created transactions in A&AI
+ * @throws BulkProcessFailed
+ */
+ void execute() throws BulkProcessFailed;
+
+} \ No newline at end of file
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryTransactionalClient.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryTransactionalClient.java
new file mode 100644
index 0000000000..a7362c85da
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryTransactionalClient.java
@@ -0,0 +1,94 @@
+package org.onap.so.client.graphinventory;
+
+import java.util.List;
+
+import org.onap.so.client.graphinventory.entities.GraphInventoryEdgeLabel;
+import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri;
+import org.onap.so.client.graphinventory.exceptions.BulkProcessFailed;
+
+public interface GraphInventoryTransactionalClient<Self, Uri extends GraphInventoryUri, EdgeLabel extends GraphInventoryEdgeLabel> {
+
+ /**
+ * adds an additional transaction and closes the previous transaction
+ *
+ * @return Self
+ */
+ Self beginNewTransaction();
+
+ /**
+ * creates a new object in A&AI
+ *
+ * @param obj - can be any object which will marshal into a valid A&AI payload
+ * @param uri
+ * @return
+ */
+ Self create(Uri uri, Object obj);
+
+ /**
+ * creates a new object in A&AI with no payload body
+ *
+ * @param uri
+ * @return
+ */
+ Self createEmpty(Uri uri);
+
+ /**
+ * Adds a relationship between two objects in A&AI
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ Self connect(Uri uriA, Uri uriB);
+
+ /**
+ * relationship between multiple objects in A&AI - connects A to all objects specified in list
+ *
+ * @param uriA
+ * @param uris
+ * @return
+ */
+ Self connect(Uri uriA, List<Uri> uris);
+
+ Self connect(Uri uriA, Uri uriB, EdgeLabel label);
+
+ Self connect(Uri uriA, List<Uri> uris, EdgeLabel label);
+
+ /**
+ * Removes relationship from two objects in A&AI
+ *
+ * @param uriA
+ * @param uriB
+ * @return
+ */
+ Self disconnect(Uri uriA, Uri uriB);
+
+ /**
+ * Removes relationship from multiple objects - disconnects A from all objects specified in list
+ * @param uriA
+ * @param uris
+ * @return
+ */
+ Self disconnect(Uri uriA, List<Uri> uris);
+
+ /**
+ * Deletes object from A&AI. Automatically handles resource-version.
+ *
+ * @param uri
+ * @return
+ */
+ Self delete(Uri uri);
+
+ /**
+ * @param obj - can be any object which will marshal into a valid A&AI payload
+ * @param uri
+ * @return
+ */
+ Self update(Uri uri, Object obj);
+
+ /**
+ * Executes all created transactions in A&AI
+ * @throws BulkProcessFailed
+ */
+ void execute() throws BulkProcessFailed;
+
+} \ No newline at end of file
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java
new file mode 100644
index 0000000000..cc1ce0063b
--- /dev/null
+++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/GraphInventoryResultWrapper.java
@@ -0,0 +1,117 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.graphinventory.entities;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import org.onap.so.client.aai.AAICommonObjectMapperProvider;
+import org.onap.so.client.aai.entities.Relationships;
+import org.onap.so.jsonpath.JsonPathUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class GraphInventoryResultWrapper implements Serializable {
+
+ private static final long serialVersionUID = 5895841925807816727L;
+ protected final String jsonBody;
+ protected final ObjectMapper mapper;
+ private final transient Logger logger;
+
+ protected GraphInventoryResultWrapper(String json, Logger logger) {
+ this.jsonBody = json;
+ this.mapper = new AAICommonObjectMapperProvider().getMapper();
+ this.logger = logger;
+ }
+
+ protected GraphInventoryResultWrapper(Object aaiObject, Logger logger) {
+ this.mapper = new AAICommonObjectMapperProvider().getMapper();
+ this.jsonBody = mapObjectToString(aaiObject);
+ this.logger = logger;
+ }
+
+ protected String mapObjectToString(Object aaiObject) {
+ try {
+ return mapper.writeValueAsString(aaiObject);
+ } catch (JsonProcessingException e) {
+ logger.warn("could not parse object into json - defaulting to {}");
+ return "{}";
+ }
+ }
+ public Optional<Relationships> getRelationships() {
+ final String path = "$.relationship-list";
+ if (isEmpty()) {
+ return Optional.empty();
+ }
+ Optional<String> result = JsonPathUtil.getInstance().locateResult(jsonBody, path);
+ if (result.isPresent()) {
+ return Optional.of(new Relationships(result.get()));
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ public String getJson() {
+ if(jsonBody == null) {
+ return "{}";
+ } else {
+ return jsonBody;
+ }
+ }
+
+ public Map<String, Object> asMap() {
+ if (isEmpty()) {
+ return new HashMap<>();
+ }
+ try {
+ return mapper.readValue(this.jsonBody, new TypeReference<Map<String, Object>>(){});
+ } catch (IOException e) {
+ return new HashMap<>();
+ }
+ }
+
+ public <T> Optional<T> asBean(Class<T> clazz) {
+ if (isEmpty()) {
+ return Optional.empty();
+ }
+ try {
+ return Optional.of(mapper.readValue(this.jsonBody, clazz));
+ } catch (IOException e) {
+ return Optional.empty();
+ }
+ }
+
+ public boolean isEmpty() {
+ return jsonBody == null;
+ }
+ @Override
+ public String toString() {
+ return this.getJson();
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/exceptions/IncorrectNumberOfUriKeys.java b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/IncorrectNumberOfUriKeys.java
index c94e561274..121708fc46 100644
--- a/common/src/main/java/org/onap/so/client/graphinventory/exceptions/IncorrectNumberOfUriKeys.java
+++ b/common/src/main/java/org/onap/so/client/graphinventory/exceptions/IncorrectNumberOfUriKeys.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.graphinventory.exceptions;
public class IncorrectNumberOfUriKeys extends RuntimeException {
diff --git a/common/src/main/resources/dmaap/default-consumer.properties b/common/src/main/resources/dmaap/default-consumer.properties
index f19b64242d..3f492e1d33 100644
--- a/common/src/main/resources/dmaap/default-consumer.properties
+++ b/common/src/main/resources/dmaap/default-consumer.properties
@@ -16,6 +16,7 @@ maxBatchSize=100
maxAgeMs=250
group=MSO
id=dev
+timeout=60000
AFT_DME2_EXCHANGE_REQUEST_HANDLERS=com.att.nsa.test.PreferredRouteRequestHandler
AFT_DME2_EXCHANGE_REPLY_HANDLERS=com.att.nsa.test.PreferredRouteReplyHandler
AFT_DME2_REQ_TRACE_ON=true
diff --git a/common/src/test/java/org/onap/so/BeansTest.java b/common/src/test/java/org/onap/so/BeansTest.java
index 2e825cf8c7..54cbced563 100644
--- a/common/src/test/java/org/onap/so/BeansTest.java
+++ b/common/src/test/java/org/onap/so/BeansTest.java
@@ -63,7 +63,6 @@ public class BeansTest {
@Test
public void pojoStructure() {
- test("org.onap.so.client.aai.objects");
test("org.onap.so.client.policy.entities");
test("org.onap.so.client.grm.beans");
test("org.onap.so.client.ruby.beans");
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java b/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java
index ea842719e8..d4eaf0873b 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java
@@ -28,6 +28,20 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory;
public class AAIObjectTypeTest {
+
+ @Test
+ public void fromTypeNameTest() throws IllegalArgumentException, IllegalAccessException, InstantiationException {
+ AAIObjectType type = AAIObjectType.fromTypeName("allotted-resource");
+ assertEquals("allotted-resource", type.typeName());
+
+ }
+
+ @Test
+ public void customTypeTest() throws IllegalArgumentException, IllegalAccessException, InstantiationException {
+ AAIObjectType type = AAIObjectType.fromTypeName("my-custom-name");
+ assertEquals("my-custom-name", type.typeName());
+
+ }
@Test
public void verifyDefaultCase() {
assertEquals("default removed for tenant", "tenant", AAIObjectType.DEFAULT_TENANT.typeName());
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java
index f4b6141b0a..43616ba0c2 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java
@@ -21,7 +21,7 @@
package org.onap.so.client.aai;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java
index 6abeea9d9b..95b30f934b 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java
@@ -22,7 +22,7 @@ package org.onap.so.client.aai;
import static org.hamcrest.CoreMatchers.containsString;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -41,6 +41,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.client.RestClientSSL;
+import org.onap.so.client.graphinventory.GraphInventoryPatchConverter;
import org.onap.so.client.graphinventory.exceptions.GraphInventoryPatchDepthExceededException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -68,7 +69,7 @@ public class AAIRestClientTest {
public void verifyPatchValidation() throws URISyntaxException {
AAIRestClient client = new AAIRestClient(props, new URI(""));
AAIRestClient spy = spy(client);
- AAIPatchConverter patchValidatorMock = mock(AAIPatchConverter.class);
+ GraphInventoryPatchConverter patchValidatorMock = mock(GraphInventoryPatchConverter.class);
doReturn(patchValidatorMock).when(spy).getPatchConverter();
String payload = "{}";
doReturn(Response.ok().build()).when(spy).method(eq("PATCH"), any());
diff --git a/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java
index 428fa276db..27637126c6 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java
@@ -45,6 +45,7 @@ import org.onap.so.client.aai.entities.singletransaction.SingleTransactionRespon
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.defaultproperties.DefaultAAIPropertiesImpl;
+import org.onap.so.client.graphinventory.GraphInventoryPatchConverter;
import org.skyscreamer.jsonassert.JSONAssert;
import com.fasterxml.jackson.core.JsonParseException;
@@ -117,7 +118,7 @@ public class AAISingleTransactionClientTest {
@Test
public void confirmPatchFormat() {
AAISingleTransactionClient singleTransaction = spy(new AAISingleTransactionClient(AAIVersion.LATEST));
- AAIPatchConverter mock = mock(AAIPatchConverter.class);
+ GraphInventoryPatchConverter mock = mock(GraphInventoryPatchConverter.class);
doReturn(mock).when(singleTransaction).getPatchConverter();
singleTransaction.update(uriA, "{}");
verify(mock, times(1)).convertPatchFormat(any());
diff --git a/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java
index 621375882b..342e3b1aa4 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java
@@ -43,6 +43,7 @@ import org.onap.aai.domain.yang.Relationship;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.defaultproperties.DefaultAAIPropertiesImpl;
+import org.onap.so.client.graphinventory.GraphInventoryPatchConverter;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
@@ -143,7 +144,7 @@ public class AAITransactionalClientTest {
@Test
public void confirmPatchFormat() {
AAITransactionalClient client = spy(new AAITransactionalClient(AAIVersion.LATEST));
- AAIPatchConverter mock = mock(AAIPatchConverter.class);
+ GraphInventoryPatchConverter mock = mock(GraphInventoryPatchConverter.class);
doReturn(mock).when(client).getPatchConverter();
client.update(uriA, "{}");
verify(mock, times(1)).convertPatchFormat(any());
diff --git a/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java b/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java
new file mode 100644
index 0000000000..e66f43fa5f
--- /dev/null
+++ b/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.aai;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.onap.so.client.aai.entities.DSLNode;
+import org.onap.so.client.aai.entities.DSLQueryBuilder;
+import org.onap.so.client.aai.entities.__;
+
+public class DSLQueryBuilderTest {
+
+
+ @Test
+ public void whereTest() {
+ DSLQueryBuilder<DSLNode, DSLNode> builder = new DSLQueryBuilder<>(new DSLNode(AAIObjectType.CLOUD_REGION,
+ __.key("cloud-owner", "att-nc"),
+ __.key("cloud-region-id", "test")));
+
+ builder.to(__.node(AAIObjectType.VLAN_TAG)).where(
+ __.node(AAIObjectType.OWNING_ENTITY,
+ __.key("owning-entity-name", "name")
+ )
+ ).to(__.node(AAIObjectType.VLAN_TAG, __.key("vlan-id-outer", "108")).output());
+
+ assertEquals("cloud-region('cloud-owner', 'att-nc')('cloud-region-id', 'test') > "
+ + "vlan-tag (> owning-entity('owning-entity-name', 'name')) > "
+ + "vlan-tag*('vlan-id-outer', '108')", builder.build());
+ }
+
+ @Test
+ public void unionTest() {
+ DSLQueryBuilder<DSLNode, DSLNode> builder = new DSLQueryBuilder<>(new DSLNode(AAIObjectType.GENERIC_VNF,
+ __.key("vnf-id", "vnfId")).output());
+
+ builder.union(__.node(AAIObjectType.PSERVER).output().to(__.node(AAIObjectType.COMPLEX).output()),
+ __.node(AAIObjectType.VSERVER).to(__.node(AAIObjectType.PSERVER).output().to(__.node(AAIObjectType.COMPLEX).output())));
+
+ assertEquals("generic-vnf*('vnf-id', 'vnfId') > " + "[ pserver* > complex*, "
+ + "vserver > pserver* > complex* ]", builder.build());
+ }
+
+ @Test
+ public void whereUnionTest() {
+ DSLQueryBuilder<DSLNode, DSLNode> builder = new DSLQueryBuilder<>(new DSLNode(AAIObjectType.GENERIC_VNF,
+ __.key("vnf-id", "vnfId")).output());
+
+ builder.where(
+ __.union(
+ __.node(AAIObjectType.PSERVER, __.key("hostname", "hostname1")),
+ __.node(AAIObjectType.VSERVER).to(__.node(AAIObjectType.PSERVER, __.key("hostname", "hostname1")))));
+
+ assertEquals("generic-vnf*('vnf-id', 'vnfId') (> [ pserver('hostname', 'hostname1'), "
+ + "vserver > pserver('hostname', 'hostname1') ])", builder.build());
+ }
+
+ @Test
+ public void notNullTest() {
+ DSLQueryBuilder<DSLNode, DSLNode> builder = new DSLQueryBuilder<>(new DSLNode(AAIObjectType.CLOUD_REGION,
+ __.key("cloud-owner", "", "null").not()).output());
+
+ assertEquals("cloud-region* !('cloud-owner', ' ', ' null ')", builder.build());
+ }
+}
diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java
index 729f0e50e9..e84326e95f 100644
--- a/common/src/test/java/org/onap/so/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.aai.entities.uri;
import static org.hamcrest.CoreMatchers.equalTo;
diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java
index 7e70f2d5f4..6059e7bd23 100644
--- a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java
@@ -48,7 +48,7 @@ import javax.ws.rs.core.UriBuilder;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.mockito.Matchers;
+import org.mockito.ArgumentMatchers;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.defaultproperties.DefaultAAIPropertiesImpl;
@@ -158,7 +158,7 @@ public class ServiceInstanceUriTest {
ServiceInstanceUri spy = spy(instance);
AAIResourcesClient mockResourcesClient = mock(AAIResourcesClient.class);
AAIResultWrapper wrapper = mock(AAIResultWrapper.class);
- when(mockResourcesClient.get(Matchers.<AAIResourceUri>any(AAIResourceUri.class), Matchers.<Class<NotFoundException>>any())).thenReturn(wrapper);
+ when(mockResourcesClient.get(ArgumentMatchers.<AAIResourceUri>any(AAIResourceUri.class), ArgumentMatchers.<Class<NotFoundException>>any())).thenReturn(wrapper);
when(wrapper.getJson()).thenReturn(content);
when(spy.getResourcesClient()).thenReturn(mockResourcesClient);
exception.expect(GraphInventoryUriComputationException.class);
diff --git a/common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java b/common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java
deleted file mode 100644
index e2a3cbd6bd..0000000000
--- a/common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
- * ONAP : SO
- * ================================================================================
- * Copyright (C) 2018 TechMahindra
- * ================================================================================
- * 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.so.client.aai.objects;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class AAIOperationalEnvironmentTest {
-
- AAIOperationalEnvironment aaiOE =new AAIOperationalEnvironment();
-
- @Test
- public void test() {
- aaiOE.setOperationalEnvironmentId("operationalEnvironmentId");
- aaiOE.setOperationalEnvironmentName("operationalEnvironmentName");
- aaiOE.setOperationalEnvironmentStatus("operationalEnvironmentStatus");
- aaiOE.setOperationalEnvironmentType("operationalEnvironmentType");
- aaiOE.setResourceVersion("resourceVersion");
- aaiOE.setTenantContext("tenantContext");
- aaiOE.setWorkloadContext("workloadContext");
- assertEquals(aaiOE.getOperationalEnvironmentId(),"operationalEnvironmentId");
- assertEquals(aaiOE.getOperationalEnvironmentName(),"operationalEnvironmentName");
- assertEquals(aaiOE.getOperationalEnvironmentStatus(),"operationalEnvironmentStatus");
- assertEquals(aaiOE.getOperationalEnvironmentType(),"operationalEnvironmentType");
- assertEquals(aaiOE.getResourceVersion(),"resourceVersion");
- assertEquals(aaiOE.getTenantContext(),"tenantContext");
- assertEquals(aaiOE.getWorkloadContext(),"workloadContext");
- aaiOE.withOperationalEnvironmentId("operationalEnvironmentId");
- aaiOE.withOperationalEnvironmentName("operationalEnvironmentName");
- aaiOE.withOperationalEnvironmentStatus("operationalEnvironmentStatus");
- aaiOE.withOperationalEnvironmentType("operationalEnvironmentType");
- aaiOE.withResourceVersion("resourceVersion");
- aaiOE.withTenantContext("tenantContext");
- aaiOE.withWorkloadContext("workloadContext");
- }
-
-}
diff --git a/common/src/test/java/org/onap/so/client/aai/objects/CustomAAIObjectType.java b/common/src/test/java/org/onap/so/client/aai/objects/CustomAAIObjectType.java
new file mode 100644
index 0000000000..3979902962
--- /dev/null
+++ b/common/src/test/java/org/onap/so/client/aai/objects/CustomAAIObjectType.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.so.client.aai.objects;
+
+import org.onap.so.client.aai.AAINamespaceConstants;
+import org.onap.so.client.aai.AAIObjectType;
+
+public class CustomAAIObjectType extends AAIObjectType {
+
+ private static final long serialVersionUID = 1919729212831978098L;
+
+ public static final AAIObjectType CUSTOM = new CustomAAIObjectType(AAINamespaceConstants.NETWORK, "my-url", "my-custom-name");
+
+ /* Default constructor automatically called by AAIObjectType */
+ public CustomAAIObjectType() {
+ super();
+ }
+ protected CustomAAIObjectType(String parent, String uri, String name) {
+ super(parent, uri, name);
+ }
+
+}
diff --git a/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java b/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java
new file mode 100644
index 0000000000..f4490faacc
--- /dev/null
+++ b/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java
@@ -0,0 +1,109 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Nokia.
+ * ================================================================================
+ * 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.so.client.adapter.rest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.entry;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.GeneralSecurityException;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.codec.binary.Base64;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.so.client.policy.JettisonStyleMapperProvider;
+import org.onap.so.utils.CryptoUtils;
+import org.onap.so.utils.TargetEntity;
+
+public class AdapterRestClientTest {
+
+ private static final String CRYPTO_KEY = "546573746F736973546573746F736973";
+ private static final String INVALID_CRYPTO_KEY = "1234";
+
+ private Map<String, String> headerMap;
+ private AdapterRestProperties adapterRestPropertiesMock;
+
+ @Before
+ public void setup() {
+ headerMap = new HashMap<>();
+ adapterRestPropertiesMock = mock(AdapterRestProperties.class);
+ }
+
+ @Test
+ public void initializeHeaderMap_success() throws URISyntaxException, GeneralSecurityException {
+ // given
+ String encyptedMessage = CryptoUtils.encrypt("testAdapter", CRYPTO_KEY);
+ when(adapterRestPropertiesMock.getAuth()).thenReturn(encyptedMessage);
+ when(adapterRestPropertiesMock.getKey()).thenReturn(CRYPTO_KEY);
+ AdapterRestClient testedObject = new AdapterRestClient(adapterRestPropertiesMock, new URI(""));
+ // when
+ testedObject.initializeHeaderMap(headerMap);
+ // then
+ assertThat(headerMap).containsOnly(entry("Authorization", getExpectedEncodedString(encyptedMessage)));
+ }
+
+ @Test
+ public void initializeHeaderMap_putNullToMapWhenAuthIsNull() throws URISyntaxException {
+ // given
+ AdapterRestClient testedObject = new AdapterRestClient(adapterRestPropertiesMock, new URI(""));
+ // when
+ testedObject.initializeHeaderMap(headerMap);
+ // then
+ assertThat(headerMap).containsOnly(entry("Authorization", null));
+ }
+
+ @Test
+ public void initializeHeaderMap_putNullToMapWhenExOccurs() throws URISyntaxException, GeneralSecurityException {
+ // given
+ String encyptedMessage = CryptoUtils.encrypt("testAdapter", CRYPTO_KEY);
+ when(adapterRestPropertiesMock.getAuth()).thenReturn(encyptedMessage);
+ when(adapterRestPropertiesMock.getKey()).thenReturn(INVALID_CRYPTO_KEY);
+ AdapterRestClient testedObject = new AdapterRestClient(adapterRestPropertiesMock, new URI(""),
+ "accept", "contentType");
+ // when
+ testedObject.initializeHeaderMap(headerMap);
+ // then
+ assertThat(headerMap).containsOnly(entry("Authorization", null));
+ }
+
+ @Test
+ public void getTargetEntity_success() throws URISyntaxException {
+ AdapterRestClient testedObject = new AdapterRestClient(adapterRestPropertiesMock, new URI(""));
+ assertThat(testedObject.getTargetEntity()).isEqualTo(TargetEntity.OPENSTACK_ADAPTER);
+ }
+
+ @Test
+ public void getCommonObjectMapperProvider_success() throws URISyntaxException {
+ AdapterRestClient testedObject = new AdapterRestClient(adapterRestPropertiesMock, new URI(""));
+ assertThat(testedObject.getCommonObjectMapperProvider()).isInstanceOf(JettisonStyleMapperProvider.class);
+ }
+
+ private String getExpectedEncodedString(String encryptedMessage) throws GeneralSecurityException {
+ String auth = CryptoUtils.decrypt(encryptedMessage, CRYPTO_KEY);
+ byte[] encoded = Base64.encodeBase64(auth.getBytes());
+ String encodedString = new String(encoded);
+ return "Basic " + encodedString;
+ }
+}
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIPatchConverterTest.java b/common/src/test/java/org/onap/so/client/graphinventory/GraphInventoryPatchConverterTest.java
index 0d4490f51d..d24b3ff147 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIPatchConverterTest.java
+++ b/common/src/test/java/org/onap/so/client/graphinventory/GraphInventoryPatchConverterTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.client.aai;
+package org.onap.so.client.graphinventory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -35,6 +35,8 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.so.client.aai.AAICommonObjectMapperProvider;
+import org.onap.so.client.graphinventory.GraphInventoryPatchConverter;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -42,13 +44,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(MockitoJUnitRunner.class)
-public class AAIPatchConverterTest {
+public class GraphInventoryPatchConverterTest {
private ObjectMapper mapper = new AAICommonObjectMapperProvider().getMapper();
@Test
public void convertObjectToPatchFormatTest() throws URISyntaxException, JsonParseException, JsonMappingException, IOException {
- AAIPatchConverter validator = new AAIPatchConverter();
+ GraphInventoryPatchConverter validator = new GraphInventoryPatchConverter();
GenericVnf vnf = new GenericVnf();
vnf.setIpv4Loopback0Address("");
String result = validator.marshallObjectToPatchFormat(vnf);
@@ -60,7 +62,7 @@ public class AAIPatchConverterTest {
@Test
public void convertStringToPatchFormatTest() throws URISyntaxException, JsonParseException, JsonMappingException, IOException {
- AAIPatchConverter validator = new AAIPatchConverter();
+ GraphInventoryPatchConverter validator = new GraphInventoryPatchConverter();
String payload = "{\"ipv4-loopback0-address\":\"\"}";
String result = validator.marshallObjectToPatchFormat(payload);
@@ -69,7 +71,7 @@ public class AAIPatchConverterTest {
@Test
public void convertStringToPatchFormatNull_Test() throws URISyntaxException, JsonParseException, JsonMappingException, IOException {
- AAIPatchConverter validator = new AAIPatchConverter();
+ GraphInventoryPatchConverter validator = new GraphInventoryPatchConverter();
String payload = "{\"ipv4-loopback0-address\": null}";
String result = validator.marshallObjectToPatchFormat(payload);
System.out.println(result);
@@ -78,7 +80,7 @@ public class AAIPatchConverterTest {
@Test
public void convertMapToPatchFormatTest() throws URISyntaxException, JsonParseException, JsonMappingException, IOException {
- AAIPatchConverter validator = new AAIPatchConverter();
+ GraphInventoryPatchConverter validator = new GraphInventoryPatchConverter();
HashMap<String, String> map = new HashMap<>();
map.put("ipv4-loopback0-address", "");
map.put("ipv4-loopback1-address", "192.168.1.1");
@@ -89,7 +91,7 @@ public class AAIPatchConverterTest {
@Test
public void hasComplexObjectTest() {
- AAIPatchConverter validator = new AAIPatchConverter();
+ GraphInventoryPatchConverter validator = new GraphInventoryPatchConverter();
String hasNesting = "{ \"hello\" : \"world\", \"nested\" : { \"key\" : \"value\" } }";
String noNesting = "{ \"hello\" : \"world\" }";
String arrayCase = "{ \"hello\" : \"world\", \"nestedSimple\" : [\"value1\" , \"value2\"], \"nestedComplex\" : [{\"key\" : \"value\"}]}";
diff --git a/common/src/test/resources/logback-test.xml b/common/src/test/resources/logback-test.xml
index 772eeabeb6..b52e6be022 100644
--- a/common/src/test/resources/logback-test.xml
+++ b/common/src/test/resources/logback-test.xml
@@ -65,6 +65,10 @@
<appender-ref ref="STDOUT" />
</logger>
+ <logger name="org.reflections" level="ERROR" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
<root level="WARN">
<appender-ref ref="STDOUT" />