diff options
author | 2019-07-19 12:12:28 +0200 | |
---|---|---|
committer | 2019-07-19 12:12:28 +0200 | |
commit | 25245136c711cb4b1ed3c8e351a79e3572512434 (patch) | |
tree | 2107dbda36dc54817ef2db37967febf2cf31e356 /vid-app-common/src/test/java/org/onap | |
parent | f4c052df50487af25e4508978bd1b667bc37dbc2 (diff) |
Pnf pojo improvements
- added builder
- immutable
- improved json serialization
Change-Id: If0c9128dfd27d1c04e2f8683bade16700789276e
Issue-ID: VID-478
Signed-off-by: Michal Kabaj <michal.kabaj@nokia.com>
Diffstat (limited to 'vid-app-common/src/test/java/org/onap')
4 files changed, 34 insertions, 19 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiGetPnfs/PnfTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiGetPnfs/PnfTest.java index 2d7d2aad3..7a5d3ad91 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiGetPnfs/PnfTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiGetPnfs/PnfTest.java @@ -3,13 +3,14 @@ * VID * ================================================================================ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nokia. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,16 +21,30 @@ package org.onap.vid.aai.model.AaiGetPnfs; -import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThat; -import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; -import static org.hamcrest.MatcherAssert.assertThat; +import org.junit.Test; public class PnfTest { @Test - public void shouldHaveValidGettersAndSetters(){ - assertThat(Pnf.class, hasValidGettersAndSetters()); - } + public void builder_shouldProperlyConstructObject() { + Pnf pnf = Pnf.builder() + .withPnfId("pnfId") + .withPnfName("TestPnf") + .withPnfName2("pnfName2") + .withPnfName2Source("pnfNameSource") + .withEquipModel("model") + .withEquipType("type") + .withEquipVendor("vendor") + .build(); + assertThat(pnf.getPnfId()).isEqualTo("pnfId"); + assertThat(pnf.getPnfName()).isEqualTo("TestPnf"); + assertThat(pnf.getPnfName2()).isEqualTo("pnfName2"); + assertThat(pnf.getPnfName2Source()).isEqualTo("pnfNameSource"); + assertThat(pnf.getEquipModel()).isEqualTo("model"); + assertThat(pnf.getEquipType()).isEqualTo("type"); + assertThat(pnf.getEquipVendor()).isEqualTo("vendor"); + } } diff --git a/vid-app-common/src/test/java/org/onap/vid/bl/AaiServiceTest.java b/vid-app-common/src/test/java/org/onap/vid/bl/AaiServiceTest.java index 1b50681fc..1d4556535 100644 --- a/vid-app-common/src/test/java/org/onap/vid/bl/AaiServiceTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/bl/AaiServiceTest.java @@ -67,8 +67,7 @@ public class AaiServiceTest { @Test public void testGetSpecificPnf(){ - Pnf pnf = new Pnf(); - pnf.setPnfId("11111"); + Pnf pnf = Pnf.builder().withPnfId("11111").build(); AaiResponse<Pnf> aaiResponse = new AaiResponse<>(pnf, "aaaa", 200); Mockito.doReturn(aaiResponse).when(aaiClientInterface).getSpecificPnf(Mockito.anyString()); AaiResponse<Pnf> specificPnf = aaiService.getSpecificPnf("1345667"); diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java index 2df28d973..a60aa7ea6 100644 --- a/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/controller/AaiControllerTest.java @@ -173,7 +173,15 @@ public class AaiControllerTest { @Test public void getSpecificPnf_shouldReturnPnfObjectForPnfId() throws Exception { String pnfId = "MyPnfId"; - Pnf pnf = createPnf(pnfId); + Pnf pnf = Pnf.builder() + .withPnfId(pnfId) + .withPnfName("TestPnf") + .withPnfName2("pnfName2") + .withPnfName2Source("pnfNameSource") + .withEquipModel("model") + .withEquipType("type") + .withEquipVendor("vendor") + .build(); AaiResponse<Pnf> aaiResponse = new AaiResponse<>(pnf, "", HttpStatus.OK.value()); given(aaiService.getSpecificPnf(pnfId)).willReturn(aaiResponse); @@ -197,13 +205,6 @@ public class AaiControllerTest { .andExpect(content().string(expectedErrorMessage)); } - private Pnf createPnf(String pnfId) { - Pnf pnf = new Pnf(); - pnf.setPnfId(pnfId); - pnf.setPnfName("TestPnf"); - return pnf; - } - public void getPNFInstances_shouldReturnOKResponseFromAAIService() throws Exception { String globalCustomerId = "testCustomerId"; String serviceType = "testServiceType"; diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java index 068cc0053..bb47180e4 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AaiServiceImplTest.java @@ -213,7 +213,7 @@ public class AaiServiceImplTest { @Test public void shouldGetSpecificPnf() { - AaiResponse<Pnf> expectedResponse = new AaiResponse<>(new Pnf(), null, HttpStatus.SC_OK); + AaiResponse<Pnf> expectedResponse = new AaiResponse<>(Pnf.builder().build(), null, HttpStatus.SC_OK); when(aaiClient.getSpecificPnf(anyString())).thenReturn(expectedResponse); AaiResponse<Pnf> actualResponse = aaiService.getSpecificPnf(anyString()); |