diff options
Diffstat (limited to 'prh-commons')
31 files changed, 1495 insertions, 281 deletions
diff --git a/prh-commons/pom.xml b/prh-commons/pom.xml index e0d7e5b8..7c53880a 100644 --- a/prh-commons/pom.xml +++ b/prh-commons/pom.xml @@ -1,4 +1,23 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ ============LICENSE_START======================================================= + ~ PNF-REGISTRATION-HANDLER + ~ ================================================================================ + ~ Copyright (C) 2018-2019 NOKIA 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========================================================= +--> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> @@ -7,27 +26,23 @@ <parent> <groupId>org.onap.dcaegen2.services</groupId> <artifactId>prh</artifactId> - <version>1.2.0-SNAPSHOT</version> + <version>1.3.1-SNAPSHOT</version> </parent> <groupId>org.onap.dcaegen2.services.prh</groupId> <artifactId>prh-commons</artifactId> <packaging>jar</packaging> - <dependencies> <dependency> <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId> <artifactId>common-dependency</artifactId> </dependency> <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jul-to-slf4j</artifactId> + <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId> + <artifactId>aai-client</artifactId> </dependency> + <dependency> <groupId>org.slf4j</groupId> <artifactId>log4j-over-slf4j</artifactId> @@ -43,13 +58,12 @@ <dependency> <groupId>org.immutables</groupId> <artifactId>value</artifactId> - <version>${immutables.version}</version> </dependency> <dependency> <groupId>org.immutables</groupId> <artifactId>gson</artifactId> - <version>${immutables.version}</version> </dependency> + <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> @@ -57,7 +71,12 @@ </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> + <artifactId>mockito-junit-jupiter</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> <scope>test</scope> </dependency> </dependencies> diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderImpl.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderImpl.java new file mode 100644 index 00000000..2be95ee3 --- /dev/null +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderImpl.java @@ -0,0 +1,65 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2018 NOKIA 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.dcaegen2.services.prh.model; + +import com.google.gson.GsonBuilder; +import com.google.gson.TypeAdapterFactory; +import org.onap.dcaegen2.services.prh.model.ImmutableConsumerDmaapModel.Builder; +import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder; + +import java.util.ServiceLoader; +import org.springframework.util.StringUtils; + + +public class AaiJsonBodyBuilderImpl implements JsonBodyBuilder<ConsumerDmaapModel> { + + /** + * Method for serialization object by GSON. + * + * @param consumerDmaapModel - object which will be serialized + * @return string from serialization + */ + public String createJsonBody(ConsumerDmaapModel consumerDmaapModel) { + GsonBuilder gsonBuilder = new GsonBuilder(); + ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory); + + Builder builder = ImmutableConsumerDmaapModel.builder() + .correlationId(consumerDmaapModel.getCorrelationId()) + .serialNumber(consumerDmaapModel.getSerialNumber()) + .equipVendor(consumerDmaapModel.getEquipVendor()) + .equipModel(consumerDmaapModel.getEquipModel()) + .equipType(consumerDmaapModel.getEquipType()) + .nfRole(consumerDmaapModel.getNfRole()) + .swVersion(consumerDmaapModel.getSwVersion()) + .additionalFields(consumerDmaapModel.getAdditionalFields()); + + String ipv4 = consumerDmaapModel.getIpv4(); + if (!StringUtils.isEmpty(ipv4)) { + builder.ipv4(ipv4); + } + String ipv6 = consumerDmaapModel.getIpv6(); + if (!StringUtils.isEmpty(ipv6)) { + builder.ipv6(ipv6); + } + + return gsonBuilder.create().toJson(builder.build()); + } +}
\ No newline at end of file diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiPnfResultModel.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiPnfResultModel.java new file mode 100644 index 00000000..424d7f83 --- /dev/null +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiPnfResultModel.java @@ -0,0 +1,206 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2018 NOKIA 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.dcaegen2.services.prh.model; + +import com.google.gson.annotations.SerializedName; +import org.immutables.gson.Gson; +import org.immutables.value.Value; +import org.springframework.lang.Nullable; + + +/** + * PNF represents a physical network function. typically equipment used in the D1 world. in 1607, this will be populated by SDN-C to represent a premises router that a uCPE connects to. But this can be used to represent any physical device that is not an AIC node or uCPE. ###### Related Nodes - TO complex( pnf LocatedIn complex, MANY2ONE) - TO instance-group( pnf MemberOf instance-group, MANY2MANY) - TO zone( pnf LocatedIn zone, MANY2ONE) - FROM configuration( configuration AppliesTo pnf, ONE2MANY) - FROM esr-thirdparty-sdnc( esr-thirdparty-sdnc AppliesTo pnf, ONE2MANY) - FROM generic-vnf( generic-vnf HostedOn pnf, MANY2MANY) - FROM lag-interface (CHILD of pnf, lag-interface BindsTo pnf, MANY2ONE)(1) - FROM logical-link( logical-link BridgedTo pnf, MANY2MANY) - FROM p-interface (CHILD of pnf, p-interface BindsTo pnf, MANY2ONE)(1) - FROM service-instance( service-instance ComposedOf pnf, ONE2MANY) -(1) IF this PNF node is deleted, this FROM node is DELETED also + */ +@Value.Immutable +@Gson.TypeAdapters(fieldNamingStrategy = true) +public interface AaiPnfResultModel { + + /** + * unique name of Physical Network Function. + **/ + @Nullable + @SerializedName("pnf-name") + String getPnfName(); + + /** + * name of Physical Network Function. + **/ + @Nullable + @SerializedName("pnf-name2") + String getPnfName2(); + + /** + * URL to endpoint where AAI can get more details. + **/ + @Nullable + @SerializedName("selflink") + String getSelflink(); + + /** + * source of name2 + **/ + @Nullable + @SerializedName("pnf-name2-source") + String getPnfName2Source(); + + /** + * id of pnf + **/ + @Nullable + @SerializedName("pnf-id") + String getPnfId(); + + /** + * Equipment type. Source of truth should define valid values. + **/ + @Nullable + @SerializedName("equip-type") + String getEquipType(); + + /** + * Equipment vendor. Source of truth should define valid values. + **/ + @Nullable + @SerializedName("equip-vendor") + String getEquipVendor(); + + /** + * Equipment model. Source of truth should define valid values. + **/ + @Nullable + @SerializedName("equip-model") + String getEquipModel(); + + /** + * identifier of managed by ATT or customer + **/ + @Nullable + @SerializedName("management-option") + String getManagementOption(); + + /** + * ipv4-oam-address with new naming convention for IP addresses + **/ + @Nullable + @SerializedName("ipaddress-v4-oam") + String getIpaddressV4Oam(); + + /** + * sw-version is the version of SW for the hosted application on the PNF. + **/ + @Nullable + @SerializedName("sw-version") + String getSwVersion(); + + /** + * Used to indicate whether or not this object is in maintenance mode (maintenance mode = true). This field (in conjunction with prov-status) is used to suppress alarms and vSCL on VNFs/VMs. + **/ + @Nullable + @SerializedName("in-maint") + Boolean isInMaint(); + + /** + * ID of the physical frame (relay rack) where pnf is installed. + **/ + @Nullable + @SerializedName("frame-id") + String getFrameId(); + + /** + * Serial number of the device + **/ + @Nullable + @SerializedName("serial-number") + String getSerialNumber(); + + /** + * IPV4 Loopback 0 address + **/ + @Nullable + @SerializedName("ipaddress-v4-loopback-0") + String getIpaddressV4Loopback0(); + + /** + * IPV6 Loopback 0 address + **/ + @Nullable + @SerializedName("ipaddress-v6-loopback-0") + String getIpaddressV6Loopback0(); + + /** + * IPV4 AIM address + **/ + @Nullable + @SerializedName("ipaddress-v4-aim") + String getIpaddressV4Aim(); + + /** + * IPV6 AIM address + **/ + @Nullable + @SerializedName("ipaddress-v6-aim") + String getIpaddressV6Aim(); + + /** + * IPV6 OAM address + **/ + @Nullable + @SerializedName("ipaddress-v6-oam") + String getIpaddressV6Oam(); + + /** + * CANOPI's inventory status. Only set with values exactly as defined by CANOPI. + **/ + @Nullable + @SerializedName("inv-status") + String getInvStatus(); + + /** + * Used for optimistic concurrency. Must be empty on createGson, valid on update and delete. + **/ + @Nullable + @SerializedName("resource-version") + String getResourceVersion(); + + /** + * Prov Status of this device (not under canopi control) Valid values [PREPROV/NVTPROV/PROV] + **/ + @Nullable + @SerializedName("prov-status") + String getProvStatus(); + + /** + * Nf Role is the role performed by this instance in the network. + **/ + @Nullable + @SerializedName("nf-role") + String getNfRole(); + + /** + * Get relationshipList + **/ + @SerializedName("relationship-list") + @Value.Default + default Relationship getRelationshipList() { + return ImmutableRelationship.builder().build(); + } +} + diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiServiceInstanceResultModel.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiServiceInstanceResultModel.java new file mode 100644 index 00000000..67d6ff90 --- /dev/null +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiServiceInstanceResultModel.java @@ -0,0 +1,209 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2018 NOKIA 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.dcaegen2.services.prh.model; + +import com.google.gson.annotations.SerializedName; +import org.immutables.gson.Gson; +import org.immutables.value.Value; +import org.springframework.lang.Nullable; + +@Value.Immutable +@Gson.TypeAdapters(fieldNamingStrategy = true) +public interface AaiServiceInstanceResultModel { + + /** + * Uniquely identifies this instance of a service + **/ + @Nullable + @SerializedName("service-instance-id") + String getServiceInstanceId(); + + /** + * This field will store a name assigned to the service-instance. + **/ + @Nullable + @SerializedName("service-instance-name") + String getServiceInstanceName(); + + /** + * String capturing type of service. + **/ + @Nullable + @SerializedName("service-type") + String getServiceType(); + + /** + * String capturing the service role. + **/ + @Nullable + @SerializedName("service-role") + String getServiceRole(); + + /** + * This field will store the environment context assigned to the service-instance. + **/ + @Nullable + @SerializedName("environment-context") + String getEnvironmentContext(); + + /** + * This field will store the workload context assigned to the service-instance. + **/ + @Nullable + @SerializedName("workload-context") + String getWorkloadContext(); + + /** + * createGson time of Network Service. + **/ + @Nullable + @SerializedName("created-at") + String getCreatedAt(); + + /** + * last update of Network Service. + **/ + @Nullable + @SerializedName("updated-at") + String getUpdatedAt(); + + /** + * short description for service-instance. + **/ + @Nullable + @SerializedName("description") + String getDescription(); + + /** + * the ASDC model id for this resource or service model. + **/ + @Nullable + @SerializedName("model-invariant-id") + String getModelInvariantId(); + + /** + * the ASDC model version for this resource or service model. + **/ + @Nullable + @SerializedName("model-version-id") + String getModelVersionId(); + + /** + * the ASDC model version for this resource or service model. + **/ + @Nullable + @SerializedName("persona-model-version") + String getPersonaModelVersion(); + + /** + * the ASDC data dictionary widget model. This maps directly to the A&AI widget. + **/ + @Nullable + @SerializedName("widget-model-id") + String getWidgetModelId(); + + /** + * the ASDC data dictionary version of the widget model.This maps directly to the A&AI version of the widget. + **/ + @Nullable + @SerializedName("widget-model-version") + String getWidgetModelVersion(); + + /** + * Indicates the total bandwidth to be used for this service. + **/ + @Nullable + @SerializedName("bandwidth-total") + String getBandwidthTotal(); + + /** + * indicates the upstream bandwidth this service will use on the WAN1 port of the physical device. + **/ + @Nullable + @SerializedName("bandwidth-up-wan1") + String getBandwidthUpWan1(); + + /** + * indicates the downstream bandwidth this service will use on the WAN1 port of the physical device. + **/ + @Nullable + @SerializedName("bandwidth-down-wan1") + String getBandwidthDownWan1(); + + /** + * indicates the upstream bandwidth this service will use on the WAN2 port of the physical device. + **/ + @Nullable + @SerializedName("bandwidth-up-wan2") + String getBandwidthUpWan2(); + + /** + * indicates the downstream bandwidth this service will use on the WAN2 port of the physical device. + **/ + @Nullable + @SerializedName("bandwidth-down-wan2") + String getBandwidthDownWan2(); + + /** + * URL customers will use to access the vHN Portal. + **/ + @Nullable + @SerializedName("vhn-portal-url") + String getVhnPortalUrl(); + + /** + * An identifier that customers assign to the location where this service is being used. + **/ + @Nullable + @SerializedName("service-instance-location-id") + String getServiceInstanceLocationId(); + + /** + * Used for optimistic concurrency. Must be empty on createGson, valid on update and delete. + **/ + @Nullable + @SerializedName("resource-version") + String getResourceVersion(); + + /** + * Path to the controller object. + **/ + @Nullable + @SerializedName("selflink") + String getSelflink(); + + /** + * Orchestration status of this service. + **/ + @Nullable + @SerializedName("orchestration-status") + String getOrchestrationStatus(); + + /** + * Get relationshipList + **/ + @SerializedName("relationship-list") + @Value.Default + default Relationship getRelationshipList() { + return ImmutableRelationship.builder().build(); + } + +}
\ No newline at end of file diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java index b2bac24c..b519c3a5 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java @@ -20,7 +20,9 @@ package org.onap.dcaegen2.services.prh.model; +import com.google.gson.JsonObject; import com.google.gson.annotations.SerializedName; +import org.springframework.lang.Nullable; import org.immutables.gson.Gson; import org.immutables.value.Value; import org.onap.dcaegen2.services.sdk.rest.services.model.AaiModel; @@ -37,9 +39,39 @@ public interface ConsumerDmaapModel extends AaiModel, DmaapModel { @SerializedName(value = "correlationId", alternate = "correlationId") String getCorrelationId(); + @Nullable @SerializedName(value = "ipaddress-v4-oam", alternate = "ipaddress-v4-oam") String getIpv4(); + @Nullable @SerializedName(value = "ipaddress-v6-oam", alternate = "ipaddress-v6-oam") String getIpv6(); + + @Nullable + @SerializedName(value = "serial-number", alternate = "serial-number") + String getSerialNumber(); + + @Nullable + @SerializedName(value = "equip-vendor", alternate = "equip-vendor") + String getEquipVendor(); + + @Nullable + @SerializedName(value = "equip-model", alternate = "equip-model") + String getEquipModel(); + + @Nullable + @SerializedName(value = "equip-type", alternate = "equip-type") + String getEquipType(); + + @Nullable + @SerializedName(value = "nf-role", alternate = "nf-role") + String getNfRole(); + + @Nullable + @SerializedName(value = "sw-version", alternate = "sw-version") + String getSwVersion(); + + @Nullable + @SerializedName(value = "additionalFields", alternate = "additionalFields") + JsonObject getAdditionalFields(); } diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/PnfReadyJsonBodyBuilder.java index b504a4bd..b39c4690 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/PnfReadyJsonBodyBuilder.java @@ -20,16 +20,13 @@ package org.onap.dcaegen2.services.prh.model; -import com.google.gson.GsonBuilder; -import com.google.gson.TypeAdapterFactory; -import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import org.onap.dcaegen2.services.prh.model.ImmutableConsumerDmaapModel.Builder; +import org.onap.dcaegen2.services.prh.model.utils.PrhModelAwareGsonBuilder; -import java.util.ServiceLoader; - -public class JsonBodyBuilderImpl implements JsonBodyBuilder<ConsumerDmaapModel> { - - public JsonBodyBuilderImpl() {} +public class PnfReadyJsonBodyBuilder { /** * Method for serialization object by GSON. @@ -37,10 +34,14 @@ public class JsonBodyBuilderImpl implements JsonBodyBuilder<ConsumerDmaapModel> * @param consumerDmaapModel - object which will be serialized * @return string from serialization */ - public String createJsonBody(ConsumerDmaapModel consumerDmaapModel) { - GsonBuilder gsonBuilder = new GsonBuilder(); - ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory); - return gsonBuilder.create().toJson(ImmutableConsumerDmaapModel.builder().ipv4(consumerDmaapModel.getIpv4()) - .ipv6(consumerDmaapModel.getIpv6()).correlationId(consumerDmaapModel.getCorrelationId()).build()); + public JsonElement createJsonBody(ConsumerDmaapModel consumerDmaapModel) { + Builder builder = ImmutableConsumerDmaapModel.builder() + .correlationId(consumerDmaapModel.getCorrelationId()); + + JsonObject additionalFields = consumerDmaapModel.getAdditionalFields(); + if(additionalFields != null && !additionalFields.equals(new JsonObject())) { + builder.additionalFields(additionalFields); + } + return PrhModelAwareGsonBuilder.createGson().toJsonTree(builder.build()); } }
\ No newline at end of file diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/Relationship.java index 86717d7e..d92b7c75 100644 --- a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/Relationship.java @@ -20,16 +20,16 @@ package org.onap.dcaegen2.services.prh.model; -import static org.junit.jupiter.api.Assertions.assertEquals; +import com.google.gson.annotations.SerializedName; +import org.immutables.gson.Gson; +import org.immutables.value.Value; -import org.junit.jupiter.api.Test; +import java.util.List; -class CommonFunctionsTest { +@Value.Immutable +@Gson.TypeAdapters(fieldNamingStrategy = true) +public interface Relationship { - @Test - void createJsonBody_shouldReturnJsonInString() { - String expectedResult = "{\"correlationId\":\"NOKnhfsadhff\",\"ipaddress-v4-oam\":\"256.22.33.155\"" - + ",\"ipaddress-v6-oam\":\"200J:0db8:85a3:0000:0000:8a2e:0370:7334\"}"; - assertEquals(expectedResult, new JsonBodyBuilderImpl().createJsonBody(new ConsumerDmaapModelForUnitTest())); - } -} + @SerializedName("relationship") + List<RelationshipDict> getRelationship(); +}
\ No newline at end of file diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipData.java index cbada731..4b1670c6 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipData.java @@ -20,32 +20,30 @@ package org.onap.dcaegen2.services.prh.model; -public class ConsumerDmaapModelForUnitTest implements ConsumerDmaapModel { +import com.google.gson.annotations.SerializedName; +import org.immutables.gson.Gson; +import org.immutables.value.Value; - private final String correlationId; - private final String ipv4; - private final String ipv6; +/** + * RelationshipData + */ +@Value.Immutable +@Gson.TypeAdapters(fieldNamingStrategy = true) +public interface RelationshipData { /** - * Class for testing serialization of ConsumerDmaapModel. - */ - public ConsumerDmaapModelForUnitTest() { - this.correlationId = "NOKnhfsadhff"; - this.ipv4 = "256.22.33.155"; - this.ipv6 = "200J:0db8:85a3:0000:0000:8a2e:0370:7334"; - - } - - public String getCorrelationId() { - return correlationId; - } + * A keyword provided by A&AI to indicate an attribute. + * + * @return relationshipKey + **/ + @SerializedName("relationship-key") + String getRelationshipKey(); - public String getIpv4() { - return ipv4; - } - - public String getIpv6() { - return ipv6; - } - -} + /** + * Value of the attribute. + * + * @return relationshipValue + **/ + @SerializedName("relationship-value") + String getRelationshipValue(); +}
\ No newline at end of file diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelTest.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipDict.java index 4c4c345f..007f371b 100644 --- a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelTest.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/RelationshipDict.java @@ -20,29 +20,49 @@ package org.onap.dcaegen2.services.prh.model; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -class ConsumerDmaapModelTest { - - @Test - void consumerDmaapModelBuilder_shouldBuildAnObject() { - - // When - // Given - String sourceName = "NOKnhfsadhff"; - String ipv4 = "11.22.33.155"; - String ipv6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334"; - ConsumerDmaapModel consumerDmaapModel = ImmutableConsumerDmaapModel.builder() - .correlationId(sourceName) - .ipv4(ipv4) - .ipv6(ipv6) - .build(); - - // Then - Assertions.assertNotNull(consumerDmaapModel); - Assertions.assertEquals(sourceName, consumerDmaapModel.getCorrelationId()); - Assertions.assertEquals(ipv4, consumerDmaapModel.getIpv4()); - Assertions.assertEquals(ipv6, consumerDmaapModel.getIpv6()); +import com.google.gson.annotations.SerializedName; +import org.immutables.gson.Gson; +import org.immutables.value.Value; +import org.springframework.lang.Nullable; + +import java.util.Collections; +import java.util.List; + +/** + * RelationshipDict + */ +@Value.Immutable +@Gson.TypeAdapters(fieldNamingStrategy = true) +public interface RelationshipDict { + + /** + * A keyword provided by A&AI to indicate type of node. + **/ + @Nullable + @SerializedName("related-to") + String getRelatedTo(); + + /** + * The edge label for this relationship. + **/ + @Nullable + @SerializedName("relationship-label") + String getRelationshipLabel(); + + /** + * URL to the object in A&AI. + **/ + @Nullable + @SerializedName("related-link") + String getRelatedLink(); + + /** + * relationship Data + **/ + @SerializedName("relationship-data") + @Value.Default + default List<RelationshipData> getRelationshipData() { + return Collections.emptyList(); } -} + +}
\ No newline at end of file diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/bbs/LogicalLink.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/bbs/LogicalLink.java new file mode 100644 index 00000000..3b3dce15 --- /dev/null +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/bbs/LogicalLink.java @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2019 NOKIA 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.dcaegen2.services.prh.model.bbs; + +import com.google.gson.annotations.SerializedName; +import org.immutables.gson.Gson; +import org.immutables.value.Value; +import org.onap.dcaegen2.services.prh.model.ImmutableRelationship; +import org.onap.dcaegen2.services.prh.model.Relationship; +import org.onap.dcaegen2.services.sdk.rest.services.model.ClientModel; +import org.springframework.lang.Nullable; + +@Value.Immutable +@Gson.TypeAdapters(fieldNamingStrategy = true) +public interface LogicalLink extends ClientModel { + + @SerializedName(value = "link-name") + String getLinkName(); + + @SerializedName(value = "link-type") + String getLinkType(); + + @Nullable + @SerializedName(value = "resource-version") + String getResourceVersion(); + + @SerializedName("relationship-list") + @Value.Default + default Relationship getRelationshipList() { + return ImmutableRelationship.builder().build(); + } +} diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/logging/MdcVariables.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/queries/NamedNode.java index c6fc4592..6329e7e0 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/logging/MdcVariables.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/queries/NamedNode.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * PNF-REGISTRATION-HANDLER * ================================================================================ - * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved. + * Copyright (C) 2019 NOKIA 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. @@ -18,27 +18,17 @@ * ============LICENSE_END========================================================= */ -package org.onap.dcaegen2.services.prh.model.logging; +package org.onap.dcaegen2.services.prh.model.queries; import java.util.Map; -import org.slf4j.MDC; +import org.immutables.value.Value; -public final class MdcVariables { - - public static final String X_ONAP_REQUEST_ID = "X-ONAP-RequestID"; - public static final String X_INVOCATION_ID = "X-InvocationID"; - public static final String REQUEST_ID = "RequestID"; - public static final String INVOCATION_ID = "InvocationID"; - public static final String INSTANCE_UUID = "InstanceUUID"; - public static final String RESPONSE_CODE = "ResponseCode"; - public static final String SERVICE_NAME = "ServiceName"; - - private MdcVariables() { - } - - public static void setMdcContextMap(Map<String, String> mdcContextMap) { - if (mdcContextMap != null) { - MDC.setContextMap(mdcContextMap); - } - } -} +/** + * @see NamedNodeAdapter + * @see NamedNodes + */ +@Value.Immutable +public interface NamedNode { + String name(); + Map<String, Object> properties(); +}
\ No newline at end of file diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/queries/NamedNodeAdapter.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/queries/NamedNodeAdapter.java new file mode 100644 index 00000000..be6c8d5b --- /dev/null +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/queries/NamedNodeAdapter.java @@ -0,0 +1,71 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2019 NOKIA 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.dcaegen2.services.prh.model.queries; + +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import org.onap.dcaegen2.services.prh.model.queries.ImmutableNamedNode.Builder; + +/** + * @see NamedNode + * @see <a href="https://docs.onap.org/en/dublin/submodules/aai/aai-common.git/docs/AAI%20REST%20API%20Documentation/customQueries.html">AAI + * Custom queries</a></a> + */ +public class NamedNodeAdapter extends TypeAdapter<NamedNode> { + + @Override + public void write(JsonWriter jsonWriter, NamedNode namedNode) { + throw new UnsupportedOperationException("This model is read only!"); + } + + @Override + public NamedNode read(JsonReader jsonReader) throws IOException { + jsonReader.beginObject(); + Builder nodeBuilder = ImmutableNamedNode.builder().name(jsonReader.nextName()); + readProperties(jsonReader, nodeBuilder); + jsonReader.endObject(); + + return nodeBuilder.build(); + } + + private void readProperties(JsonReader jsonReader, Builder nodeBuilder) throws IOException { + jsonReader.beginObject(); + while (jsonReader.hasNext()) { + String key = jsonReader.nextName(); + switch (jsonReader.peek()) { + case STRING: + nodeBuilder.putProperties(key, jsonReader.nextString()); + break; + case NUMBER: + nodeBuilder.putProperties(key, jsonReader.nextInt()); + break; + case BOOLEAN: + nodeBuilder.putProperties(key, jsonReader.nextBoolean()); + break; + default: + jsonReader.skipValue(); + } + } + jsonReader.endObject(); + } +}
\ No newline at end of file diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/queries/NamedNodes.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/queries/NamedNodes.java new file mode 100644 index 00000000..6a463ddf --- /dev/null +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/queries/NamedNodes.java @@ -0,0 +1,40 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2019 NOKIA 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.dcaegen2.services.prh.model.queries; + +import com.google.gson.annotations.SerializedName; +import java.util.List; +import org.immutables.gson.Gson; +import org.immutables.value.Value; + +/** + * @see NamedNode + * @see PnfQuery + * @see <a href="https://docs.onap.org/en/dublin/submodules/aai/aai-common.git/docs/AAI%20REST%20API%20Documentation/customQueries.html">AAI + * Custom queries</a></a> + */ +@Value.Immutable +@Gson.TypeAdapters(fieldNamingStrategy = true) +public interface NamedNodes { + + @SerializedName(value = "results") + List<NamedNode> results(); +}
\ No newline at end of file diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/queries/PnfQuery.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/queries/PnfQuery.java new file mode 100644 index 00000000..7a9025aa --- /dev/null +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/queries/PnfQuery.java @@ -0,0 +1,54 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2019 NOKIA 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.dcaegen2.services.prh.model.queries; + +import static java.util.Arrays.asList; +import static org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod.PUT; + +import com.google.gson.annotations.SerializedName; +import java.util.List; +import org.onap.dcaegen2.services.sdk.rest.services.aai.client.service.http.Request; +import org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod; + +/** + * @see NamedNodes + * @see <a href="https://docs.onap.org/en/dublin/submodules/aai/aai-common.git/docs/AAI%20REST%20API%20Documentation/customQueries.html">AAI + * Custom queries</a></a> + */ +public class PnfQuery implements Request { + + @SerializedName("start") + private final List<String> startNodes; + + public PnfQuery(String pnfName) { + this.startNodes = asList("/nodes/pnfs/pnf/" + pnfName); + } + + @Override + public HttpMethod method() { + return PUT; + } + + @Override + public String uri() { + return "/query?format=resource&subgraph=star&nodesOnly=true"; + } +}
\ No newline at end of file diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/utils/PrhModelAwareGsonBuilder.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/utils/PrhModelAwareGsonBuilder.java new file mode 100644 index 00000000..e01711a7 --- /dev/null +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/utils/PrhModelAwareGsonBuilder.java @@ -0,0 +1,41 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2019 NOKIA 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.dcaegen2.services.prh.model.utils; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.TypeAdapterFactory; +import java.util.ServiceLoader; +import org.onap.dcaegen2.services.prh.model.queries.NamedNode; +import org.onap.dcaegen2.services.prh.model.queries.NamedNodeAdapter; + +public final class PrhModelAwareGsonBuilder { + + private static final Iterable<TypeAdapterFactory> TYPE_ADAPTER_FACTORIES = + ServiceLoader.load(TypeAdapterFactory.class); + + public static Gson createGson() { + GsonBuilder gsonBuilder = new GsonBuilder(); + TYPE_ADAPTER_FACTORIES.forEach(gsonBuilder::registerTypeAdapterFactory); + gsonBuilder.registerTypeAdapter(NamedNode.class, new NamedNodeAdapter()); + return gsonBuilder.create(); + } +} diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/ssl/SslFactory.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/ssl/SslFactory.java deleted file mode 100644 index 60e1224e..00000000 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/ssl/SslFactory.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA 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.dcaegen2.services.prh.ssl; - -import io.netty.handler.ssl.SslContext; -import io.netty.handler.ssl.SslContextBuilder; -import io.netty.handler.ssl.util.InsecureTrustManagerFactory; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.security.GeneralSecurityException; -import java.security.KeyStore; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLException; -import javax.net.ssl.TrustManagerFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SslFactory { - - private static final Logger LOGGER = LoggerFactory.getLogger(SslFactory.class); - - /** - * Function for creating secure ssl context. - * - * @param keyStorePath - path to file with keystore - * @param keyStorePasswordPath - path to file with keystore password - * @param trustStorePath - path to file with truststore - * @param trustStorePasswordPath - path to file with truststore password - * @return configured ssl context - */ - public SslContext createSecureContext(String keyStorePath, - String keyStorePasswordPath, - String trustStorePath, - String trustStorePasswordPath) throws SSLException { - LOGGER.info("Creating secure ssl context for: {} {}", keyStorePath, trustStorePath); - try { - return SslContextBuilder - .forClient() - .keyManager(keyManagerFactory(keyStorePath, loadPasswordFromFile(keyStorePasswordPath))) - .trustManager(trustManagerFactory(trustStorePath, loadPasswordFromFile(trustStorePasswordPath))) - .build(); - } catch (GeneralSecurityException | IOException ex) { - throw new SSLException(ex); - } - } - - /** - * Function for creating insecure ssl context. - * - * @return configured insecure ssl context - */ - public SslContext createInsecureContext() throws SSLException { - LOGGER.info("Creating insecure ssl context"); - return SslContextBuilder - .forClient() - .trustManager(InsecureTrustManagerFactory.INSTANCE) - .build(); - } - - private KeyManagerFactory keyManagerFactory(String path, String password) - throws GeneralSecurityException, IOException { - KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); - kmf.init(loadKeyStoreFromFile(path, password), - password.toCharArray()); - return kmf; - } - - private TrustManagerFactory trustManagerFactory(String path, String password) - throws GeneralSecurityException, IOException { - TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - tmf.init(loadKeyStoreFromFile(path, password)); - return tmf; - } - - private KeyStore loadKeyStoreFromFile(String path, String keyStorePassword) - throws GeneralSecurityException, IOException { - KeyStore ks = KeyStore.getInstance("jks"); - ks.load(getResource(path), keyStorePassword.toCharArray()); - return ks; - } - - private InputStream getResource(String path) throws FileNotFoundException { - return new FileInputStream(path); - } - - private String loadPasswordFromFile(String path) throws IOException { - return new String(Files.readAllBytes(Paths.get(path))); - } -} diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderTest.java new file mode 100644 index 00000000..60ce520c --- /dev/null +++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderTest.java @@ -0,0 +1,114 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2018 NOKIA 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.dcaegen2.services.prh.model; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import org.junit.jupiter.api.Test; + +class AaiJsonBodyBuilderTest { + + @Test + void createJsonBody_shouldReturnJsonInString() { + + ConsumerDmaapModel model = ImmutableConsumerDmaapModel.builder() + .correlationId("NOKnhfsadhff") + .ipv4("256.22.33.155") + .ipv6("200J:0db8:85a3:0000:0000:8a2e:0370:7334") + .serialNumber("1234") + .equipVendor("NOKIA") + .equipModel("3310") + .equipType("cell") + .nfRole("role") + .swVersion("1.2.3") + .build(); + + String expectedResult = "{" + + "\"correlationId\":\"NOKnhfsadhff\"," + + "\"ipaddress-v4-oam\":\"256.22.33.155\"," + + "\"ipaddress-v6-oam\":\"200J:0db8:85a3:0000:0000:8a2e:0370:7334\"," + + "\"serial-number\":\"1234\"," + + "\"equip-vendor\":\"NOKIA\"," + + "\"equip-model\":\"3310\"," + + "\"equip-type\":\"cell\"," + + "\"nf-role\":\"role\"," + + "\"sw-version\":\"1.2.3\"" + + "}"; + + assertEquals(expectedResult, new AaiJsonBodyBuilderImpl().createJsonBody(model)); + } + + @Test + void createJsonBodyWithoutIPs_shouldReturnJsonInString() { + + ConsumerDmaapModel model = ImmutableConsumerDmaapModel.builder() + .correlationId("NOKnhfsadhff") + .serialNumber("1234") + .equipVendor("NOKIA") + .equipModel("3310") + .equipType("cell") + .nfRole("role") + .swVersion("1.2.3") + .build(); + + String expectedResult = "{" + + "\"correlationId\":\"NOKnhfsadhff\"," + + "\"serial-number\":\"1234\"," + + "\"equip-vendor\":\"NOKIA\"," + + "\"equip-model\":\"3310\"," + + "\"equip-type\":\"cell\"," + + "\"nf-role\":\"role\"," + + "\"sw-version\":\"1.2.3\"" + + "}"; + + assertEquals(expectedResult, new AaiJsonBodyBuilderImpl().createJsonBody(model)); + } + + @Test + void createJsonBodyWithEmptyIPs_shouldReturnJsonInString() { + + ConsumerDmaapModel model = ImmutableConsumerDmaapModel.builder() + .correlationId("NOKnhfsadhff") + .ipv4("") + .ipv6("") + .serialNumber("1234") + .equipVendor("NOKIA") + .equipModel("3310") + .equipType("cell") + .nfRole("role") + .swVersion("1.2.3") + .build(); + + String expectedResult = "{" + + "\"correlationId\":\"NOKnhfsadhff\"," + + "\"serial-number\":\"1234\"," + + "\"equip-vendor\":\"NOKIA\"," + + "\"equip-model\":\"3310\"," + + "\"equip-type\":\"cell\"," + + "\"nf-role\":\"role\"," + + "\"sw-version\":\"1.2.3\"" + + "}"; + + assertEquals(expectedResult, new AaiJsonBodyBuilderImpl().createJsonBody(model)); + } +} diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/AaiPnfResultModelTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/AaiPnfResultModelTest.java new file mode 100644 index 00000000..3f396e82 --- /dev/null +++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/AaiPnfResultModelTest.java @@ -0,0 +1,87 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2019 NOKIA 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.dcaegen2.services.prh.model; + +import com.google.gson.Gson; +import org.junit.jupiter.api.Test; +import org.onap.dcaegen2.services.prh.model.utils.PrhModelAwareGsonBuilder; + +import java.io.InputStreamReader; +import java.util.Objects; + +import static org.assertj.core.api.Assertions.assertThat; + +class AaiPnfResultModelTest { + + @Test + void shouldParseAaiPnf() { + Gson gson = PrhModelAwareGsonBuilder.createGson(); + AaiPnfResultModel pnf = gson.fromJson(new InputStreamReader(Objects.requireNonNull( + ClassLoader.getSystemResourceAsStream("some_aai_pnf.json"))), AaiPnfResultModel.class); + + assertThat(pnf.getPnfName()).isEqualTo("some pnfName"); + assertThat(pnf.getPnfName2()).isEqualTo("some pnfName2"); + assertThat(pnf.getSelflink()).isEqualTo("some selflink"); + assertThat(pnf.getPnfName2Source()).isEqualTo("some pnfName2Source"); + assertThat(pnf.getPnfId()).isEqualTo("some pnfId"); + assertThat(pnf.getEquipType()).isEqualTo("some equipType"); + assertThat(pnf.getEquipVendor()).isEqualTo("some equipVendor"); + assertThat(pnf.getEquipModel()).isEqualTo("some equipModel"); + assertThat(pnf.getManagementOption()).isEqualTo("some managementOption"); + assertThat(pnf.getIpaddressV4Oam()).isEqualTo("some ipaddressV4Oam"); + assertThat(pnf.getSwVersion()).isEqualTo("some swVersion"); + assertThat(pnf.isInMaint()).isFalse(); + assertThat(pnf.getFrameId()).isEqualTo("some frameId"); + assertThat(pnf.getSerialNumber()).isEqualTo("some serialNumber"); + assertThat(pnf.getIpaddressV4Loopback0()).isEqualTo("some ipaddressV4Loopback0"); + assertThat(pnf.getIpaddressV6Loopback0()).isEqualTo("some ipaddressV6Loopback0"); + assertThat(pnf.getIpaddressV4Aim()).isEqualTo("some ipaddressV4Aim"); + assertThat(pnf.getIpaddressV6Aim()).isEqualTo("some ipaddressV6Aim"); + assertThat(pnf.getIpaddressV6Oam()).isEqualTo("some ipaddressV6Oam"); + assertThat(pnf.getInvStatus()).isEqualTo("some invStatus"); + assertThat(pnf.getResourceVersion()).isEqualTo("some resourceVersion"); + assertThat(pnf.getProvStatus()).isEqualTo("some provStatus"); + assertThat(pnf.getNfRole()).isEqualTo("some nfRole"); + + assertThat(pnf.getRelationshipList().getRelationship()).hasSize(1); + RelationshipDict relationshipDict = pnf.getRelationshipList().getRelationship().get(0); + assertThat(relationshipDict.getRelatedTo()).isEqualTo("some relatedTo"); + assertThat(relationshipDict.getRelationshipData()).hasSize(1); + RelationshipData relationshipData = relationshipDict.getRelationshipData().get(0); + assertThat(relationshipData.getRelationshipKey()).isEqualTo("some relationshipKey"); + assertThat(relationshipData.getRelationshipValue()).isEqualTo("some relationshipValue"); + } + + @Test + void shouldProvideEmptyRelationshipListForEmptyJson() { + Gson gson = PrhModelAwareGsonBuilder.createGson(); + AaiPnfResultModel pnf = gson.fromJson("{}", AaiPnfResultModel.class); + assertThat(pnf.getRelationshipList()).isNotNull(); + assertThat(pnf.getRelationshipList().getRelationship()).isEmpty(); + } + + @Test + void shouldIgnoreUnexpectedFieldsInJson() { + Gson gson = PrhModelAwareGsonBuilder.createGson(); + gson.fromJson("{\"foo\":\"bar\"}", AaiPnfResultModel.class); + } + +}
\ No newline at end of file diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/AaiServiceInstanceResultModelTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/AaiServiceInstanceResultModelTest.java new file mode 100644 index 00000000..5f9ca14d --- /dev/null +++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/AaiServiceInstanceResultModelTest.java @@ -0,0 +1,89 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2019 NOKIA 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.dcaegen2.services.prh.model; + +import com.google.gson.Gson; +import org.junit.jupiter.api.Test; +import org.onap.dcaegen2.services.prh.model.utils.PrhModelAwareGsonBuilder; + +import java.io.InputStreamReader; +import java.util.Objects; + +import static org.assertj.core.api.Assertions.assertThat; + +class AaiServiceInstanceResultModelTest { + + @Test + void shouldParseAaiServiceInstance() { + AaiServiceInstanceResultModel serviceInstance = PrhModelAwareGsonBuilder.createGson().fromJson( + new InputStreamReader(Objects.requireNonNull( + ClassLoader.getSystemResourceAsStream("some_aai_service_instance.json"))), + AaiServiceInstanceResultModel.class); + + assertThat(serviceInstance.getServiceInstanceId()).isEqualTo("some serviceInstanceId"); + assertThat(serviceInstance.getServiceInstanceName()).isEqualTo("some serviceInstanceName"); + assertThat(serviceInstance.getServiceType()).isEqualTo("some serviceType"); + assertThat(serviceInstance.getServiceRole()).isEqualTo("some serviceRole"); + assertThat(serviceInstance.getEnvironmentContext()).isEqualTo("some environmentContext"); + assertThat(serviceInstance.getWorkloadContext()).isEqualTo("some workloadContext"); + assertThat(serviceInstance.getCreatedAt()).isEqualTo("some createdAt"); + assertThat(serviceInstance.getUpdatedAt()).isEqualTo("some updatedAt"); + assertThat(serviceInstance.getDescription()).isEqualTo("some description"); + assertThat(serviceInstance.getModelInvariantId()).isEqualTo("some modelInvariantId"); + assertThat(serviceInstance.getModelVersionId()).isEqualTo("some modelVersionId"); + assertThat(serviceInstance.getPersonaModelVersion()).isEqualTo("some personaModelVersion"); + assertThat(serviceInstance.getWidgetModelId()).isEqualTo("some widgetModelId"); + assertThat(serviceInstance.getWidgetModelVersion()).isEqualTo("some widgetModelVersion"); + assertThat(serviceInstance.getBandwidthTotal()).isEqualTo("some bandwidthTotal"); + assertThat(serviceInstance.getBandwidthUpWan1()).isEqualTo("some bandwidthUpWan1"); + assertThat(serviceInstance.getBandwidthDownWan1()).isEqualTo("some bandwidthDownWan1"); + assertThat(serviceInstance.getBandwidthUpWan2()).isEqualTo("some bandwidthUpWan2"); + assertThat(serviceInstance.getBandwidthDownWan2()).isEqualTo("some bandwidthDownWan2"); + assertThat(serviceInstance.getVhnPortalUrl()).isEqualTo("some vhnPortalUrl"); + assertThat(serviceInstance.getServiceInstanceLocationId()).isEqualTo("some serviceInstanceLocationId"); + assertThat(serviceInstance.getResourceVersion()).isEqualTo("some resourceVersion"); + assertThat(serviceInstance.getSelflink()).isEqualTo("some selflink"); + assertThat(serviceInstance.getOrchestrationStatus()).isEqualTo("some orchestrationStatus"); + + RelationshipDict relationshipDict = serviceInstance.getRelationshipList().getRelationship().get(0); + assertThat(relationshipDict.getRelatedTo()).isEqualTo("some relatedTo"); + assertThat(relationshipDict.getRelationshipData()).hasSize(1); + RelationshipData relationshipData = relationshipDict.getRelationshipData().get(0); + assertThat(relationshipData.getRelationshipKey()).isEqualTo("some relationshipKey"); + assertThat(relationshipData.getRelationshipValue()).isEqualTo("some relationshipValue"); + } + + + @Test + void shouldProvideEmptyRelationshipListForEmptyJson() { + Gson gson = PrhModelAwareGsonBuilder.createGson(); + AaiServiceInstanceResultModel serviceInstance = gson.fromJson("{}", AaiServiceInstanceResultModel.class); + assertThat(serviceInstance.getRelationshipList()).isNotNull(); + assertThat(serviceInstance.getRelationshipList().getRelationship()).isEmpty(); + } + + @Test + void shouldIgnoreUnexpectedFieldsInJson() { + Gson gson = PrhModelAwareGsonBuilder.createGson(); + gson.fromJson("{\"foo\":\"bar\"}", AaiServiceInstanceResultModel.class); + } + +}
\ No newline at end of file diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/PnfReadyJsonBodyBuilderTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/PnfReadyJsonBodyBuilderTest.java new file mode 100644 index 00000000..769e1673 --- /dev/null +++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/PnfReadyJsonBodyBuilderTest.java @@ -0,0 +1,82 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2018 NOKIA 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.dcaegen2.services.prh.model; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import org.junit.jupiter.api.Test; + +class PnfReadyJsonBodyBuilderTest { + + @Test + void createJsonBody_shouldReturnJsonInString() { + + JsonObject jsonObject = parse("{\n" + + " \"attachmentPoint\": \"bla-bla-30-3\",\n" + + " \"cvlan\": \"678\",\n" + + " \"svlan\": \"1005\"\n" + + " }"); + + ConsumerDmaapModel model = ImmutableConsumerDmaapModel.builder() + .correlationId("NOKnhfsadhff") + .additionalFields(jsonObject) + .build(); + + JsonObject expectedResult = parse("{" + + "\"correlationId\":\"NOKnhfsadhff\"," + + "\"additionalFields\":{\"attachmentPoint\":\"bla-bla-30-3\",\"cvlan\":\"678\",\"svlan\":\"1005\"}" + + "}"); + + assertEquals(expectedResult, new PnfReadyJsonBodyBuilder().createJsonBody(model)); + } + + @Test + void createJsonBodyWithNullableFieldsNotSet_shouldReturnJsonInString() { + + ConsumerDmaapModel model = ImmutableConsumerDmaapModel.builder() + .correlationId("NOKnhfsadhff") + .build(); + + JsonObject expectedResult = parse("{\"correlationId\":\"NOKnhfsadhff\"}"); + + assertEquals(expectedResult, new PnfReadyJsonBodyBuilder().createJsonBody(model)); + } + + @Test + void createJsonBodyWithEmptyOptionalPnfRegistrationFields_shouldReturnJsonInString() { + JsonObject jsonObject = new JsonObject(); + + ConsumerDmaapModel model = ImmutableConsumerDmaapModel.builder() + .correlationId("NOKnhfsadhff") + .additionalFields(jsonObject) + .build(); + + JsonObject expectedResult = parse("{\"correlationId\":\"NOKnhfsadhff\"}"); + + assertEquals(expectedResult, new PnfReadyJsonBodyBuilder().createJsonBody(model)); + } + + private static JsonObject parse(String jsonString) { + return new JsonParser().parse(jsonString).getAsJsonObject(); + } +} diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/queries/NamedNodesTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/queries/NamedNodesTest.java new file mode 100644 index 00000000..0991d31f --- /dev/null +++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/queries/NamedNodesTest.java @@ -0,0 +1,58 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2019 NOKIA 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.dcaegen2.services.prh.model.queries; + +import static java.util.Objects.requireNonNull; +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.gson.Gson; +import java.io.InputStreamReader; +import org.junit.jupiter.api.Test; +import org.onap.dcaegen2.services.prh.model.utils.PrhModelAwareGsonBuilder; + +class NamedNodesTest { + + @Test + void shouldParseJsonToNamedNodes() { + // given + InputStreamReader inputStream = getJsonFromFile("pnf_query_response.json"); + Gson gson = PrhModelAwareGsonBuilder.createGson(); + + // when + NamedNodes nodes = gson.fromJson(inputStream, NamedNodes.class); + + // then + assertThat(nodes.results().size()).isEqualTo(3); + assertThat(nodes.results().get(0)) + .matches(node -> "pnf".equals(node.name())) + .matches(node -> node.properties().get("pnf-name").equals("foo")); + assertThat(nodes.results().get(1)) + .matches(node -> "logical-link".equals(node.name())) + .matches(node -> node.properties().get("link-name").equals("bar")); + assertThat(nodes.results().get(2)) + .matches(node -> "service-instance".equals(node.name())) + .matches(node -> node.properties().get("service-instance-name").equals("baz")); + } + + private InputStreamReader getJsonFromFile(String file) { + return new InputStreamReader(requireNonNull(getClass().getClassLoader().getResourceAsStream(file))); + } +} diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/queries/PnfQueryTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/queries/PnfQueryTest.java new file mode 100644 index 00000000..0ab0b17b --- /dev/null +++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/queries/PnfQueryTest.java @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START======================================================= + * PNF-REGISTRATION-HANDLER + * ================================================================================ + * Copyright (C) 2019 NOKIA 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.dcaegen2.services.prh.model.queries; + +import static java.util.Objects.requireNonNull; +import static java.util.stream.Collectors.joining; +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.gson.Gson; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import org.junit.jupiter.api.Test; +import org.onap.dcaegen2.services.prh.model.utils.PrhModelAwareGsonBuilder; + +class PnfQueryTest { + + @Test + void shouldParseToCorrectJson() throws IOException { + // given + PnfQuery pnfQuery = new PnfQuery("foo"); + + // when + Gson gson = PrhModelAwareGsonBuilder.createGson(); + + // then + String json = gson.toJson(pnfQuery); + assertThat(json).isEqualToIgnoringWhitespace(getJsonFromFile("pnf_query_request.json")); + } + + private String getJsonFromFile(String file) throws IOException { + try (BufferedReader br = new BufferedReader(new InputStreamReader( + requireNonNull(getClass().getClassLoader().getResourceAsStream(file))))) { + return br.lines().collect(joining(System.lineSeparator())); + } + } +}
\ No newline at end of file diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/ssl/SslFactoryTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/ssl/SslFactoryTest.java deleted file mode 100644 index dbd63911..00000000 --- a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/ssl/SslFactoryTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 NOKIA 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.dcaegen2.services.prh.ssl; - -import javax.net.ssl.SSLException; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - - -class SslFactoryTest { - - private static final String KEY_STORE = "org.onap.dcae.jks"; - private static final String KEYSTORE_PASSWORD = "keystore.password"; - private static final String TRUSTSTORE_PASSWORD = "truststore.password"; - private static final String TRUST_STORE = "org.onap.dcae.trust.jks"; - private SslFactory sslFactory = new SslFactory(); - - @Test - void shouldCreateInsecureContext() throws SSLException { - Assertions.assertNotNull(sslFactory.createInsecureContext()); - } - - @Test - void shouldCreateSecureContext() throws SSLException { - Assertions.assertNotNull(sslFactory.createSecureContext( - getPath(KEY_STORE), - getPath(KEYSTORE_PASSWORD), - getPath(TRUST_STORE), - getPath(TRUSTSTORE_PASSWORD))); - } - - @Test - void shouldThrowSslExceptionWhenKeystorePasswordIsIncorrect() { - Assertions.assertThrows(SSLException.class, () -> sslFactory.createSecureContext( - getPath(KEY_STORE), - getPath(TRUSTSTORE_PASSWORD), - getPath(TRUST_STORE), - getPath(TRUSTSTORE_PASSWORD))); - } - - private String getPath(String fileName) { - return this.getClass().getClassLoader().getResource(fileName).getPath(); - } -}
\ No newline at end of file diff --git a/prh-commons/src/test/resources/keystore.password b/prh-commons/src/test/resources/keystore.password deleted file mode 100644 index 39823872..00000000 --- a/prh-commons/src/test/resources/keystore.password +++ /dev/null @@ -1 +0,0 @@ -mYHC98!qX}7h?W}jRv}MIXTJ
\ No newline at end of file diff --git a/prh-commons/src/test/resources/org.onap.dcae.jks b/prh-commons/src/test/resources/org.onap.dcae.jks Binary files differdeleted file mode 100644 index e74ce64f..00000000 --- a/prh-commons/src/test/resources/org.onap.dcae.jks +++ /dev/null diff --git a/prh-commons/src/test/resources/org.onap.dcae.trust.jks b/prh-commons/src/test/resources/org.onap.dcae.trust.jks Binary files differdeleted file mode 100644 index 10103cfb..00000000 --- a/prh-commons/src/test/resources/org.onap.dcae.trust.jks +++ /dev/null diff --git a/prh-commons/src/test/resources/pnf_query_request.json b/prh-commons/src/test/resources/pnf_query_request.json new file mode 100644 index 00000000..2a171c76 --- /dev/null +++ b/prh-commons/src/test/resources/pnf_query_request.json @@ -0,0 +1,5 @@ +{ + "start": [ + "/nodes/pnfs/pnf/foo" + ] +}
\ No newline at end of file diff --git a/prh-commons/src/test/resources/pnf_query_response.json b/prh-commons/src/test/resources/pnf_query_response.json new file mode 100644 index 00000000..f74b37a6 --- /dev/null +++ b/prh-commons/src/test/resources/pnf_query_response.json @@ -0,0 +1,27 @@ +{ + "results": [ + { + "pnf": { + "pnf-name": "foo", + "in-maint": false, + "resource-version": "1559732370039" + } + }, + { + "logical-link": { + "link-name": "bar", + "in-maint": false, + "link-type": "attachment-point", + "resource-version": "1559805666899" + } + }, + { + "service-instance": { + "service-instance-id": "pnf-service-id", + "service-instance-name": "baz", + "resource-version": "1559732385933", + "orchestration-status": "ACTIVE" + } + } + ] +}
\ No newline at end of file diff --git a/prh-commons/src/test/resources/some_aai_pnf.json b/prh-commons/src/test/resources/some_aai_pnf.json new file mode 100644 index 00000000..ee158dff --- /dev/null +++ b/prh-commons/src/test/resources/some_aai_pnf.json @@ -0,0 +1,38 @@ +{ + "pnf-name": "some pnfName", + "pnf-name2": "some pnfName2", + "selflink": "some selflink", + "pnf-name2-source": "some pnfName2Source", + "pnf-id": "some pnfId", + "equip-type": "some equipType", + "equip-vendor": "some equipVendor", + "equip-model": "some equipModel", + "management-option": "some managementOption", + "ipaddress-v4-oam": "some ipaddressV4Oam", + "sw-version": "some swVersion", + "in-maint": false, + "frame-id": "some frameId", + "serial-number": "some serialNumber", + "ipaddress-v4-loopback-0": "some ipaddressV4Loopback0", + "ipaddress-v6-loopback-0": "some ipaddressV6Loopback0", + "ipaddress-v4-aim": "some ipaddressV4Aim", + "ipaddress-v6-aim": "some ipaddressV6Aim", + "ipaddress-v6-oam": "some ipaddressV6Oam", + "inv-status": "some invStatus", + "resource-version": "some resourceVersion", + "prov-status": "some provStatus", + "nf-role": "some nfRole", + "relationship-list": { + "relationship": [ + { + "related-to": "some relatedTo", + "relationship-data": [ + { + "relationship-key": "some relationshipKey", + "relationship-value": "some relationshipValue" + } + ] + } + ] + } +}
\ No newline at end of file diff --git a/prh-commons/src/test/resources/some_aai_service_instance.json b/prh-commons/src/test/resources/some_aai_service_instance.json new file mode 100644 index 00000000..31857314 --- /dev/null +++ b/prh-commons/src/test/resources/some_aai_service_instance.json @@ -0,0 +1,39 @@ +{ + "service-instance-id": "some serviceInstanceId", + "service-instance-name": "some serviceInstanceName", + "service-type": "some serviceType", + "service-role": "some serviceRole", + "environment-context": "some environmentContext", + "workload-context": "some workloadContext", + "created-at": "some createdAt", + "updated-at": "some updatedAt", + "description": "some description", + "model-invariant-id": "some modelInvariantId", + "model-version-id": "some modelVersionId", + "persona-model-version": "some personaModelVersion", + "widget-model-id": "some widgetModelId", + "widget-model-version": "some widgetModelVersion", + "bandwidth-total": "some bandwidthTotal", + "bandwidth-up-wan1": "some bandwidthUpWan1", + "bandwidth-down-wan1": "some bandwidthDownWan1", + "bandwidth-up-wan2": "some bandwidthUpWan2", + "bandwidth-down-wan2": "some bandwidthDownWan2", + "vhn-portal-url": "some vhnPortalUrl", + "service-instance-location-id": "some serviceInstanceLocationId", + "resource-version": "some resourceVersion", + "selflink": "some selflink", + "orchestration-status": "some orchestrationStatus", + "relationship-list": { + "relationship": [ + { + "related-to": "some relatedTo", + "relationship-data": [ + { + "relationship-key": "some relationshipKey", + "relationship-value": "some relationshipValue" + } + ] + } + ] + } +}
\ No newline at end of file diff --git a/prh-commons/src/test/resources/truststore.password b/prh-commons/src/test/resources/truststore.password deleted file mode 100644 index 168e64bd..00000000 --- a/prh-commons/src/test/resources/truststore.password +++ /dev/null @@ -1 +0,0 @@ -*TQH?Lnszprs4LmlAj38yds(
\ No newline at end of file |