diff options
author | grabinsk <maciej.grabinski@nokia.com> | 2019-04-05 13:34:14 +0200 |
---|---|---|
committer | Maciej Grabinski <maciej.grabinski@nokia.com> | 2019-04-05 13:23:14 +0000 |
commit | f34a9a055140573c759df8e34e3121d4956668da (patch) | |
tree | 72c2662c069f54ea2254ba018373a5fadebcd1b0 /prh-commons/src/test | |
parent | 2abfecad9aeb88ba95d62d718376535fb6e00325 (diff) |
Remove unused code from autogenerated AAI model objects
Hand written pojos will have to be replaced with autogenerated ones
Change-Id: I5d6fd37e8ce56ab1e0cda3d1b308ce51c5e0ebd1
Issue-ID: DCAEGEN2-1391
Signed-off-by: grabinsk <maciej.grabinski@nokia.com>
Diffstat (limited to 'prh-commons/src/test')
2 files changed, 318 insertions, 0 deletions
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..4bafd90e --- /dev/null +++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/AaiPnfResultModelTest.java @@ -0,0 +1,158 @@ +/* + * ============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.GsonBuilder; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + +class AaiPnfResultModelTest { + + private static final String SOME_AAI_PNF_JSON = "{" + + "\"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\":[{}]}" + + "}"; + + private static AaiPnfResultModel getAaiPnfResultModel() { + AaiPnfResultModel aaiPnf = new AaiPnfResultModel(); + aaiPnf.setPnfName("some pnfName"); + aaiPnf.setPnfName2("some pnfName2"); + aaiPnf.setSelflink("some selflink"); + aaiPnf.setPnfName2Source("some pnfName2Source"); + aaiPnf.setPnfId("some pnfId"); + aaiPnf.setEquipType("some equipType"); + aaiPnf.setEquipVendor("some equipVendor"); + aaiPnf.setEquipModel("some equipModel"); + aaiPnf.setManagementOption("some managementOption"); + aaiPnf.setIpaddressV4Oam("some ipaddressV4Oam"); + aaiPnf.setSwVersion("some swVersion"); + aaiPnf.setInMaint(false); + aaiPnf.setFrameId("some frameId"); + aaiPnf.setSerialNumber("some serialNumber"); + aaiPnf.setIpaddressV4Loopback0("some ipaddressV4Loopback0"); + aaiPnf.setIpaddressV6Loopback0("some ipaddressV6Loopback0"); + aaiPnf.setIpaddressV4Aim("some ipaddressV4Aim"); + aaiPnf.setIpaddressV6Aim("some ipaddressV6Aim"); + aaiPnf.setIpaddressV6Oam("some ipaddressV6Oam"); + aaiPnf.setInvStatus("some invStatus"); + aaiPnf.setResourceVersion("some resourceVersion"); + aaiPnf.setProvStatus("some provStatus"); + aaiPnf.setNfRole("some nfRole"); + aaiPnf.setRelationshipList(getSomeRelationshipList()); + return aaiPnf; + } + + private static Relationship getSomeRelationshipList() { + return new Relationship().addRelationshipItem( + new RelationshipDict()); + } + + @Test + void shouldSerializeAaiPnf() { + String json = new GsonBuilder().create().toJson(getAaiPnfResultModel()); + + assertEquals(SOME_AAI_PNF_JSON, json); + } + + @Test + void shouldParseAaiPnf() { + AaiPnfResultModel pnf = new GsonBuilder().create().fromJson(SOME_AAI_PNF_JSON, AaiPnfResultModel.class); + + assertEquals("some pnfName", pnf.getPnfName()); + assertEquals("some pnfName2", pnf.getPnfName2()); + assertEquals("some selflink", pnf.getSelflink()); + assertEquals("some pnfName2Source", pnf.getPnfName2Source()); + assertEquals("some pnfId", pnf.getPnfId()); + assertEquals("some equipType", pnf.getEquipType()); + assertEquals("some equipVendor", pnf.getEquipVendor()); + assertEquals("some equipModel", pnf.getEquipModel()); + assertEquals("some managementOption", pnf.getManagementOption()); + assertEquals("some ipaddressV4Oam", pnf.getIpaddressV4Oam()); + assertEquals("some swVersion", pnf.getSwVersion()); + assertEquals(false, pnf.isInMaint()); + assertEquals("some frameId", pnf.getFrameId()); + assertEquals("some serialNumber", pnf.getSerialNumber()); + assertEquals("some ipaddressV4Loopback0", pnf.getIpaddressV4Loopback0()); + assertEquals("some ipaddressV6Loopback0", pnf.getIpaddressV6Loopback0()); + assertEquals("some ipaddressV4Aim", pnf.getIpaddressV4Aim()); + assertEquals("some ipaddressV6Aim", pnf.getIpaddressV6Aim()); + assertEquals("some ipaddressV6Oam", pnf.getIpaddressV6Oam()); + assertEquals("some invStatus", pnf.getInvStatus()); + assertEquals("some resourceVersion", pnf.getResourceVersion()); + assertEquals("some provStatus", pnf.getProvStatus()); + assertEquals("some nfRole", pnf.getNfRole()); + assertEquals(1, pnf.getRelationshipList().getRelationship().size()); + } + + @Test + void shouldBePrintable() { + String s = getAaiPnfResultModel().toString(); + assertThat(s).contains("some pnfName"); + assertThat(s).contains("some pnfName2"); + assertThat(s).contains("some selflink"); + assertThat(s).contains("some pnfName2Source"); + assertThat(s).contains("some pnfId"); + assertThat(s).contains("some equipType"); + assertThat(s).contains("some equipVendor"); + assertThat(s).contains("some equipModel"); + assertThat(s).contains("some managementOption"); + assertThat(s).contains("some ipaddressV4Oam"); + assertThat(s).contains("some swVersion"); + assertThat(s).contains("false"); + assertThat(s).contains("some frameId"); + assertThat(s).contains("some serialNumber"); + assertThat(s).contains("some ipaddressV4Loopback0"); + assertThat(s).contains("some ipaddressV6Loopback0"); + assertThat(s).contains("some ipaddressV4Aim"); + assertThat(s).contains("some ipaddressV6Aim"); + assertThat(s).contains("some ipaddressV6Oam"); + assertThat(s).contains("some invStatus"); + assertThat(s).contains("some resourceVersion"); + assertThat(s).contains("some provStatus"); + assertThat(s).contains("some nfRole"); + } + + +}
\ 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..2b02436b --- /dev/null +++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/AaiServiceInstanceResultModelTest.java @@ -0,0 +1,160 @@ +/* + * ============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.GsonBuilder; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + +class AaiServiceInstanceResultModelTest { + + private static final String SOME_AAI_SERVICE_INSTANCE_JSON = "{" + + "\"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\":[{}]}" + + "}"; + + private static AaiServiceInstanceResultModel getSomeAaiServiceInstance() { + AaiServiceInstanceResultModel serviceInstance = new AaiServiceInstanceResultModel(); + serviceInstance.setServiceInstanceId("some serviceInstanceId"); + serviceInstance.setServiceInstanceName("some serviceInstanceName"); + serviceInstance.setServiceType("some serviceType"); + serviceInstance.setServiceRole("some serviceRole"); + serviceInstance.setEnvironmentContext("some environmentContext"); + serviceInstance.setWorkloadContext("some workloadContext"); + serviceInstance.setCreatedAt("some createdAt"); + serviceInstance.setUpdatedAt("some updatedAt"); + serviceInstance.setDescription("some description"); + serviceInstance.setModelInvariantId("some modelInvariantId"); + serviceInstance.setModelVersionId("some modelVersionId"); + serviceInstance.setPersonaModelVersion("some personaModelVersion"); + serviceInstance.setWidgetModelId("some widgetModelId"); + serviceInstance.setWidgetModelVersion("some widgetModelVersion"); + serviceInstance.setBandwidthTotal("some bandwidthTotal"); + serviceInstance.setBandwidthUpWan1("some bandwidthUpWan1"); + serviceInstance.setBandwidthDownWan1("some bandwidthDownWan1"); + serviceInstance.setBandwidthUpWan2("some bandwidthUpWan2"); + serviceInstance.setBandwidthDownWan2("some bandwidthDownWan2"); + serviceInstance.setVhnPortalUrl("some vhnPortalUrl"); + serviceInstance.setServiceInstanceLocationId("some serviceInstanceLocationId"); + serviceInstance.setResourceVersion("some resourceVersion"); + serviceInstance.setSelflink("some selflink"); + serviceInstance.setOrchestrationStatus("some orchestrationStatus"); + serviceInstance.setRelationshipList(getSomeRelationshipList()); + return serviceInstance; + } + + private static Relationship getSomeRelationshipList() { + return new Relationship().addRelationshipItem( + new RelationshipDict()); + } + + @Test + void shouldSerializeAaiServiceInstance() { + String json = new GsonBuilder().create().toJson(getSomeAaiServiceInstance()); + assertEquals(SOME_AAI_SERVICE_INSTANCE_JSON, json); + } + + @Test + void shouldParseAaiServiceInstance() { + AaiServiceInstanceResultModel serviceInstance = new GsonBuilder().create() + .fromJson(SOME_AAI_SERVICE_INSTANCE_JSON, AaiServiceInstanceResultModel.class); + + assertEquals("some serviceInstanceId", serviceInstance.getServiceInstanceId()); + assertEquals("some serviceInstanceName", serviceInstance.getServiceInstanceName()); + assertEquals("some serviceType", serviceInstance.getServiceType()); + assertEquals("some serviceRole", serviceInstance.getServiceRole()); + assertEquals("some environmentContext", serviceInstance.getEnvironmentContext()); + assertEquals("some workloadContext", serviceInstance.getWorkloadContext()); + assertEquals("some createdAt", serviceInstance.getCreatedAt()); + assertEquals("some updatedAt", serviceInstance.getUpdatedAt()); + assertEquals("some description", serviceInstance.getDescription()); + assertEquals("some modelInvariantId", serviceInstance.getModelInvariantId()); + assertEquals("some modelVersionId", serviceInstance.getModelVersionId()); + assertEquals("some personaModelVersion", serviceInstance.getPersonaModelVersion()); + assertEquals("some widgetModelId", serviceInstance.getWidgetModelId()); + assertEquals("some widgetModelVersion", serviceInstance.getWidgetModelVersion()); + assertEquals("some bandwidthTotal", serviceInstance.getBandwidthTotal()); + assertEquals("some bandwidthUpWan1", serviceInstance.getBandwidthUpWan1()); + assertEquals("some bandwidthDownWan1", serviceInstance.getBandwidthDownWan1()); + assertEquals("some bandwidthUpWan2", serviceInstance.getBandwidthUpWan2()); + assertEquals("some bandwidthDownWan2", serviceInstance.getBandwidthDownWan2()); + assertEquals("some vhnPortalUrl", serviceInstance.getVhnPortalUrl()); + assertEquals("some serviceInstanceLocationId", serviceInstance.getServiceInstanceLocationId()); + assertEquals("some resourceVersion", serviceInstance.getResourceVersion()); + assertEquals("some selflink", serviceInstance.getSelflink()); + assertEquals("some orchestrationStatus", serviceInstance.getOrchestrationStatus()); + assertEquals(1, serviceInstance.getRelationshipList().getRelationship().size()); + } + + @Test + void shouldBePrintable() { + String s = getSomeAaiServiceInstance().toString(); + assertThat(s).contains("some serviceInstanceId"); + assertThat(s).contains("some serviceInstanceName"); + assertThat(s).contains("some serviceType"); + assertThat(s).contains("some serviceRole"); + assertThat(s).contains("some environmentContext"); + assertThat(s).contains("some workloadContext"); + assertThat(s).contains("some createdAt"); + assertThat(s).contains("some updatedAt"); + assertThat(s).contains("some description"); + assertThat(s).contains("some modelInvariantId"); + assertThat(s).contains("some modelVersionId"); + assertThat(s).contains("some personaModelVersion"); + assertThat(s).contains("some widgetModelId"); + assertThat(s).contains("some widgetModelVersion"); + assertThat(s).contains("some bandwidthTotal"); + assertThat(s).contains("some bandwidthUpWan1"); + assertThat(s).contains("some bandwidthDownWan1"); + assertThat(s).contains("some bandwidthUpWan2"); + assertThat(s).contains("some bandwidthDownWan2"); + assertThat(s).contains("some vhnPortalUrl"); + assertThat(s).contains("some serviceInstanceLocationId"); + assertThat(s).contains("some resourceVersion"); + assertThat(s).contains("some selflink"); + assertThat(s).contains("some orchestrationStatus"); + } +}
\ No newline at end of file |