From 5f147731796cdc11dffde548c3307ea9042640e3 Mon Sep 17 00:00:00 2001 From: tgolabek Date: Mon, 21 May 2018 12:13:08 +0200 Subject: Getter/setter tests inside the aai model Refactor of a tests of aai model for getters/setters using google matchers Issue-ID: VID-228 Change-Id: I5e7912bbcc4bd605002278b50b63d976a2dc55cc Signed-off-by: tgolabek --- vid-app-common/pom.xml | 6 + .../main/java/org/vid/dao/FnAppDoaImplTest.java | 45 ------ .../OperationalEnvironmentListTest.java | 27 +--- .../onap/vid/aai/model/AaiGetPnfResponseTest.java | 52 ++++--- .../org/onap/vid/aai/model/AaiGetPnfs/PnfTest.java | 145 +----------------- .../vid/aai/model/AaiRelationResponseTest.java | 45 +----- ...viceModelsByDistributionStatusResponseTest.java | 27 +--- .../vid/aai/model/LogicalLinkResponseTest.java | 121 +-------------- .../java/org/onap/vid/aai/model/ModelTest.java | 85 +---------- .../java/org/onap/vid/aai/model/ModelVerTest.java | 126 +--------------- .../java/org/onap/vid/aai/model/ModelVersTest.java | 28 +--- .../org/onap/vid/aai/model/OwningEntityTest.java | 46 +----- .../org/onap/vid/aai/model/PnfPropertiesTest.java | 42 +++--- .../java/org/onap/vid/aai/model/PnfResultTest.java | 38 +++-- .../onap/vid/aai/model/ProjectResponseTest.java | 28 +--- .../java/org/onap/vid/aai/model/ProjectTest.java | 26 +--- .../onap/vid/aai/model/RelatedToPropertyTest.java | 49 +----- .../onap/vid/aai/model/RelationshipDataTest.java | 50 +------ .../org/onap/vid/aai/model/RelationshipTest.java | 102 +------------ .../java/org/onap/vid/aai/model/ResultTest.java | 26 +--- .../vid/aai/model/ServiceRelationshipsTest.java | 164 +-------------------- 21 files changed, 152 insertions(+), 1126 deletions(-) delete mode 100644 vid-app-common/src/test/java/org/onap/src/main/java/org/vid/dao/FnAppDoaImplTest.java diff --git a/vid-app-common/pom.xml b/vid-app-common/pom.xml index 7a4852280..a42a2b33b 100755 --- a/vid-app-common/pom.xml +++ b/vid-app-common/pom.xml @@ -346,6 +346,12 @@ junit 4.12 + + com.google.code.bean-matchers + bean-matchers + 0.11 + test + org.json json diff --git a/vid-app-common/src/test/java/org/onap/src/main/java/org/vid/dao/FnAppDoaImplTest.java b/vid-app-common/src/test/java/org/onap/src/main/java/org/vid/dao/FnAppDoaImplTest.java deleted file mode 100644 index e98e7b205..000000000 --- a/vid-app-common/src/test/java/org/onap/src/main/java/org/vid/dao/FnAppDoaImplTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.src.main.java.org.vid.dao; - -import java.io.IOException; -import java.sql.SQLException; - -import org.junit.Test; - -import org.onap.vid.dao.FnAppDoaImpl; - -public class FnAppDoaImplTest { - - //@Test - public void testGetconnection() throws ClassNotFoundException, IOException, SQLException{ - FnAppDoaImpl impl=new FnAppDoaImpl(); - impl.getConnection(null,null,null, null); - - } - - //@Test - public void testProfileCount() throws ClassNotFoundException, IOException, SQLException{ - FnAppDoaImpl impl=new FnAppDoaImpl(); - impl.getProfileCount(null,null,null, null); - } - -} diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentListTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentListTest.java index 87d2bd88b..28b939ef3 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentListTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiGetOperationalEnvironments/OperationalEnvironmentListTest.java @@ -1,33 +1,14 @@ package org.onap.vid.aai.model.AaiGetOperationalEnvironments; -import java.util.List; - +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; import org.junit.Test; -import org.onap.vid.aai.OperationalEnvironment; public class OperationalEnvironmentListTest { - private OperationalEnvironmentList createTestSubject() { - return new OperationalEnvironmentList(); - } - @Test - public void testGetOperationalEnvironment() throws Exception { - OperationalEnvironmentList testSubject; - List result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getOperationalEnvironment(); + public void shouldHaveValidGettersAndSetters(){ + assertThat(OperationalEnvironmentList.class, hasValidGettersAndSetters()); } - @Test - public void testSetOperationalEnvironment() throws Exception { - OperationalEnvironmentList testSubject; - List operationalEnvironment = null; - - // default test - testSubject = createTestSubject(); - testSubject.setOperationalEnvironment(operationalEnvironment); - } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiGetPnfResponseTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiGetPnfResponseTest.java index bf248a396..7b5b8aa39 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiGetPnfResponseTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiGetPnfResponseTest.java @@ -1,43 +1,41 @@ package org.onap.vid.aai.model; -import java.util.Map; +import java.io.IOException; +import java.util.ArrayList; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Before; import org.junit.Test; -public class AaiGetPnfResponseTest { +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.StringContains.containsString; +import static org.hamcrest.core.IsEqual.equalTo; - private AaiGetPnfResponse createTestSubject() { - return new AaiGetPnfResponse(); - } +public class AaiGetPnfResponseTest { - @Test - public void testGetAdditionalProperties() throws Exception { - AaiGetPnfResponse testSubject; - Map result; + private AaiGetPnfResponse aaiGetPnfResponse; - // default test - testSubject = createTestSubject(); - result = testSubject.getAdditionalProperties(); + @Before + public void setUp(){ + aaiGetPnfResponse = new AaiGetPnfResponse(); + aaiGetPnfResponse.results = new ArrayList<>(); + aaiGetPnfResponse.setAdditionalProperty("key1", "value1"); + aaiGetPnfResponse.setAdditionalProperty("key2", "value2"); } @Test - public void testSetAdditionalProperty() throws Exception { - AaiGetPnfResponse testSubject; - String name = ""; - Object value = null; - - // default test - testSubject = createTestSubject(); - testSubject.setAdditionalProperty(name, value); + public void shouldHaveValidGettersAndSetters() throws IOException { + String result = new ObjectMapper().writeValueAsString(aaiGetPnfResponse); + assertThat(result, containsString("key1")); + assertThat(result, containsString("value2")); + assertThat(result, containsString("key2")); + assertThat(result, containsString("value2")); } @Test - public void testToString() throws Exception { - AaiGetPnfResponse testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); + public void shouldHaveValidToString(){ + assertThat(aaiGetPnfResponse.toString(), + equalTo("AaiGetPnfResponse{results=[], additionalProperties={key1=value1, key2=value2}}")); } + } \ No newline at end of file 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 22aad6eae..6f5a9125f 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 @@ -2,149 +2,14 @@ package org.onap.vid.aai.model.AaiGetPnfs; import org.junit.Test; -public class PnfTest { - - private Pnf createTestSubject() { - return new Pnf(); - } - - @Test - public void testGetPnfName() throws Exception { - Pnf testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getPnfName(); - } - - @Test - public void testSetPnfName() throws Exception { - Pnf testSubject; - String pnfName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setPnfName(pnfName); - } - - @Test - public void testGetEquipType() throws Exception { - Pnf testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getEquipType(); - } - - @Test - public void testSetEquipType() throws Exception { - Pnf testSubject; - String equipType = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setEquipType(equipType); - } - - @Test - public void testGetEquipVendor() throws Exception { - Pnf testSubject; - String result; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; - // default test - testSubject = createTestSubject(); - result = testSubject.getEquipVendor(); - } - - @Test - public void testSetEquipVendor() throws Exception { - Pnf testSubject; - String equipVendor = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setEquipVendor(equipVendor); - } - - @Test - public void testGetPnfName2() throws Exception { - Pnf testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getPnfName2(); - } - - @Test - public void testSetPnfName2() throws Exception { - Pnf testSubject; - String pnfName2 = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setPnfName2(pnfName2); - } - - @Test - public void testGetPnfId() throws Exception { - Pnf testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getPnfId(); - } - - @Test - public void testSetPnfId() throws Exception { - Pnf testSubject; - String pnfId = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setPnfId(pnfId); - } - - @Test - public void testGetEquipModel() throws Exception { - Pnf testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getEquipModel(); - } - - @Test - public void testSetEquipModel() throws Exception { - Pnf testSubject; - String equipModel = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setEquipModel(equipModel); - } +public class PnfTest { @Test - public void testGetPnfName2Source() throws Exception { - Pnf testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getPnfName2Source(); + public void shouldHaveValidGettersAndSetters(){ + assertThat(Pnf.class, hasValidGettersAndSetters()); } - @Test - public void testSetPnfName2Source() throws Exception { - Pnf testSubject; - String pnfName2Source = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setPnfName2Source(pnfName2Source); - } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiRelationResponseTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiRelationResponseTest.java index d9f3fe522..3eaa75d37 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiRelationResponseTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/AaiRelationResponseTest.java @@ -2,49 +2,14 @@ package org.onap.vid.aai.model; import org.junit.Test; -public class AaiRelationResponseTest { - - private AaiRelationResponse createTestSubject() { - return new AaiRelationResponse(); - } - - @Test - public void testGetResourceVersion() throws Exception { - AaiRelationResponse testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceVersion(); - } +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; - @Test - public void testSetResourceVersion() throws Exception { - AaiRelationResponse testSubject; - String resourceVersion = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceVersion(resourceVersion); - } +public class AaiRelationResponseTest { @Test - public void testGetRelationshipList() throws Exception { - AaiRelationResponse testSubject; - RelationshipList result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelationshipList(); + public void shouldHaveValidGettersAndSetters(){ + assertThat(AaiRelationResponse.class, hasValidGettersAndSetters()); } - @Test - public void testSetRelationshipList() throws Exception { - AaiRelationResponse testSubject; - RelationshipList relationshipList = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRelationshipList(relationshipList); - } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/GetServiceModelsByDistributionStatusResponseTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/GetServiceModelsByDistributionStatusResponseTest.java index 748a18187..437f139e7 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/GetServiceModelsByDistributionStatusResponseTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/GetServiceModelsByDistributionStatusResponseTest.java @@ -1,32 +1,15 @@ package org.onap.vid.aai.model; -import java.util.List; - import org.junit.Test; -public class GetServiceModelsByDistributionStatusResponseTest { +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; - private GetServiceModelsByDistributionStatusResponse createTestSubject() { - return new GetServiceModelsByDistributionStatusResponse(); - } +public class GetServiceModelsByDistributionStatusResponseTest { @Test - public void testGetResults() throws Exception { - GetServiceModelsByDistributionStatusResponse testSubject; - List result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResults(); + public void shouldHaveValidGettersAndSetters(){ + assertThat(GetServiceModelsByDistributionStatusResponse.class, hasValidGettersAndSetters()); } - @Test - public void testSetResults() throws Exception { - GetServiceModelsByDistributionStatusResponse testSubject; - List results = null; - - // default test - testSubject = createTestSubject(); - testSubject.setResults(results); - } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/LogicalLinkResponseTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/LogicalLinkResponseTest.java index 99ee59584..a2eb474b0 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/LogicalLinkResponseTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/LogicalLinkResponseTest.java @@ -2,6 +2,9 @@ package org.onap.vid.aai.model; import org.junit.Test; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; + public class LogicalLinkResponseTest { private LogicalLinkResponse createTestSubject() { @@ -9,122 +12,8 @@ public class LogicalLinkResponseTest { } @Test - public void testGetLinkName() throws Exception { - LogicalLinkResponse testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getLinkName(); - } - - @Test - public void testSetLinkName() throws Exception { - LogicalLinkResponse testSubject; - String linkName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setLinkName(linkName); - } - - @Test - public void testGetInMaint() throws Exception { - LogicalLinkResponse testSubject; - Boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getInMaint(); + public void shouldHaveValidGettersAndSetters(){ + assertThat(LogicalLinkResponse.class, hasValidGettersAndSetters()); } - @Test - public void testSetInMaint() throws Exception { - LogicalLinkResponse testSubject; - Boolean inMaint = null; - - // default test - testSubject = createTestSubject(); - testSubject.setInMaint(inMaint); - } - - @Test - public void testGetLinkType() throws Exception { - LogicalLinkResponse testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getLinkType(); - } - - @Test - public void testSetLinkType() throws Exception { - LogicalLinkResponse testSubject; - String linkType = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setLinkType(linkType); - } - - @Test - public void testGetResourceVersion() throws Exception { - LogicalLinkResponse testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceVersion(); - } - - @Test - public void testSetResourceVersion() throws Exception { - LogicalLinkResponse testSubject; - String resourceVersion = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceVersion(resourceVersion); - } - - @Test - public void testGetPurpose() throws Exception { - LogicalLinkResponse testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getPurpose(); - } - - @Test - public void testSetPurpose() throws Exception { - LogicalLinkResponse testSubject; - String purpose = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setPurpose(purpose); - } - - @Test - public void testGetRelationshipList() throws Exception { - LogicalLinkResponse testSubject; - RelationshipList result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelationshipList(); - } - - @Test - public void testSetRelationshipList() throws Exception { - LogicalLinkResponse testSubject; - RelationshipList relationshipList = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRelationshipList(relationshipList); - } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/ModelTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/ModelTest.java index 413c0b33e..5b8d43938 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/ModelTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/ModelTest.java @@ -2,89 +2,14 @@ package org.onap.vid.aai.model; import org.junit.Test; -public class ModelTest { - - private Model createTestSubject() { - return new Model(); - } - - @Test - public void testGetModelInvariantId() throws Exception { - Model testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getModelInvariantId(); - } - - @Test - public void testSetModelInvariantId() throws Exception { - Model testSubject; - String modelInvariantId = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setModelInvariantId(modelInvariantId); - } - - @Test - public void testGetModelType() throws Exception { - Model testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getModelType(); - } +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; - @Test - public void testSetModelType() throws Exception { - Model testSubject; - String modelType = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setModelType(modelType); - } - - @Test - public void testGetResourceVersion() throws Exception { - Model testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceVersion(); - } - - @Test - public void testSetResourceVersion() throws Exception { - Model testSubject; - String resourceVersion = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceVersion(resourceVersion); - } +public class ModelTest { @Test - public void testGetModelVers() throws Exception { - Model testSubject; - ModelVers result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getModelVers(); + public void shouldHaveValidGettersAndSetters(){ + assertThat(Model.class, hasValidGettersAndSetters()); } - @Test - public void testSetModelVers() throws Exception { - Model testSubject; - ModelVers modelVers = null; - - // default test - testSubject = createTestSubject(); - testSubject.setModelVers(modelVers); - } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/ModelVerTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/ModelVerTest.java index 99a7a7a0e..46098ef4d 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/ModelVerTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/ModelVerTest.java @@ -2,129 +2,13 @@ package org.onap.vid.aai.model; import org.junit.Test; -public class ModelVerTest { - - private ModelVer createTestSubject() { - return new ModelVer(); - } - - @Test - public void testGetModelVersionId() throws Exception { - ModelVer testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getModelVersionId(); - } - - @Test - public void testSetModelVersionId() throws Exception { - ModelVer testSubject; - String modelVersionId = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setModelVersionId(modelVersionId); - } - - @Test - public void testGetModelName() throws Exception { - ModelVer testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getModelName(); - } - - @Test - public void testSetModelName() throws Exception { - ModelVer testSubject; - String modelName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setModelName(modelName); - } - - @Test - public void testGetModelVersion() throws Exception { - ModelVer testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getModelVersion(); - } - - @Test - public void testSetModelVersion() throws Exception { - ModelVer testSubject; - String modelVersion = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setModelVersion(modelVersion); - } - - @Test - public void testGetDistributionStatus() throws Exception { - ModelVer testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDistributionStatus(); - } - - @Test - public void testSetDistributionStatus() throws Exception { - ModelVer testSubject; - String distributionStatus = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setDistributionStatus(distributionStatus); - } - - @Test - public void testGetResourceVersion() throws Exception { - ModelVer testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceVersion(); - } - - @Test - public void testSetResourceVersion() throws Exception { - ModelVer testSubject; - String resourceVersion = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceVersion(resourceVersion); - } - - @Test - public void testGetModelDescription() throws Exception { - ModelVer testSubject; - String result; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; - // default test - testSubject = createTestSubject(); - result = testSubject.getModelDescription(); - } +public class ModelVerTest { @Test - public void testSetModelDescription() throws Exception { - ModelVer testSubject; - String modelDescription = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setModelDescription(modelDescription); + public void shouldHaveValidGettersAndSetters(){ + assertThat(ModelVer.class, hasValidGettersAndSetters()); } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/ModelVersTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/ModelVersTest.java index 83bda0e55..bea3b82de 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/ModelVersTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/ModelVersTest.java @@ -1,32 +1,14 @@ package org.onap.vid.aai.model; -import java.util.List; - import org.junit.Test; -public class ModelVersTest { +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; - private ModelVers createTestSubject() { - return new ModelVers(); - } - - @Test - public void testGetModelVer() throws Exception { - ModelVers testSubject; - List result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getModelVer(); - } +public class ModelVersTest { @Test - public void testSetModelVer() throws Exception { - ModelVers testSubject; - List modelVer = null; - - // default test - testSubject = createTestSubject(); - testSubject.setModelVer(modelVer); + public void shouldHaveValidGettersAndSetters(){ + assertThat(ModelVers.class, hasValidGettersAndSetters()); } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/OwningEntityTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/OwningEntityTest.java index 1e160d297..9cb6a2f14 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/OwningEntityTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/OwningEntityTest.java @@ -2,49 +2,13 @@ package org.onap.vid.aai.model; import org.junit.Test; -public class OwningEntityTest { - - private OwningEntity createTestSubject() { - return new OwningEntity(); - } - - @Test - public void testGetOwningEntityId() throws Exception { - OwningEntity testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getOwningEntityId(); - } - - @Test - public void testSetOwningEntityId() throws Exception { - OwningEntity testSubject; - String owningEntityId = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setOwningEntityId(owningEntityId); - } - - @Test - public void testGetOwningEntityName() throws Exception { - OwningEntity testSubject; - String result; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; - // default test - testSubject = createTestSubject(); - result = testSubject.getOwningEntityName(); - } +public class OwningEntityTest { @Test - public void testSetOwningEntityName() throws Exception { - OwningEntity testSubject; - String owningEntityName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setOwningEntityName(owningEntityName); + public void shouldHaveValidGettersAndSetters(){ + assertThat(OwningEntity.class, hasValidGettersAndSetters()); } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/PnfPropertiesTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/PnfPropertiesTest.java index 46709af92..e2a62c0e8 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/PnfPropertiesTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/PnfPropertiesTest.java @@ -1,33 +1,33 @@ package org.onap.vid.aai.model; -import java.util.Map; - +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Before; import org.junit.Test; -public class PnfPropertiesTest { +import java.io.IOException; +import java.util.ArrayList; - private PnfProperties createTestSubject() { - return new PnfProperties(); - } +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.StringContains.containsString; - @Test - public void testGetAdditionalProperties() throws Exception { - PnfProperties testSubject; - Map result; +public class PnfPropertiesTest { + + private PnfProperties pnfProperties; - // default test - testSubject = createTestSubject(); - result = testSubject.getAdditionalProperties(); + @Before + public void setUp(){ + pnfProperties = new PnfProperties(); + pnfProperties.setAdditionalProperty("key1", "value1"); + pnfProperties.setAdditionalProperty("key2", "value2"); } @Test - public void testSetAdditionalProperty() throws Exception { - PnfProperties testSubject; - String name = ""; - Object value = null; - - // default test - testSubject = createTestSubject(); - testSubject.setAdditionalProperty(name, value); + public void shouldHaveValidGettersAndSetters() throws IOException { + String result = new ObjectMapper().writeValueAsString(pnfProperties); + assertThat(result, containsString("key1")); + assertThat(result, containsString("value2")); + assertThat(result, containsString("key2")); + assertThat(result, containsString("value2")); } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/PnfResultTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/PnfResultTest.java index 0f66df02f..912eea9d7 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/PnfResultTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/PnfResultTest.java @@ -1,33 +1,31 @@ package org.onap.vid.aai.model; -import java.util.Map; +import java.io.IOException; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Before; import org.junit.Test; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.StringContains.containsString; + public class PnfResultTest { - private PnfResult createTestSubject() { - return new PnfResult(); - } + private PnfResult pnfResult; - @Test - public void testGetAdditionalProperties() throws Exception { - PnfResult testSubject; - Map result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAdditionalProperties(); + @Before + public void setUp(){ + pnfResult = new PnfResult(); + pnfResult.setAdditionalProperty("key1", "value1"); + pnfResult.setAdditionalProperty("key2", "value2"); } @Test - public void testSetAdditionalProperty() throws Exception { - PnfResult testSubject; - String name = ""; - Object value = null; - - // default test - testSubject = createTestSubject(); - testSubject.setAdditionalProperty(name, value); + public void shouldHaveValidGettersAndSetters() throws IOException { + String result = new ObjectMapper().writeValueAsString(pnfResult); + assertThat(result, containsString("key1")); + assertThat(result, containsString("value2")); + assertThat(result, containsString("key2")); + assertThat(result, containsString("value2")); } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/ProjectResponseTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/ProjectResponseTest.java index 1784ea5ad..dc0960990 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/ProjectResponseTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/ProjectResponseTest.java @@ -1,32 +1,14 @@ package org.onap.vid.aai.model; -import java.util.List; - import org.junit.Test; -public class ProjectResponseTest { +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; - private ProjectResponse createTestSubject() { - return new ProjectResponse(); - } - - @Test - public void testGetProject() throws Exception { - ProjectResponse testSubject; - List result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getProject(); - } +public class ProjectResponseTest { @Test - public void testSetProject() throws Exception { - ProjectResponse testSubject; - List project = null; - - // default test - testSubject = createTestSubject(); - testSubject.setProject(project); + public void shouldHaveValidGettersAndSetters(){ + assertThat(ProjectResponse.class, hasValidGettersAndSetters()); } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/ProjectTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/ProjectTest.java index 8de772d48..7d5637f02 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/ProjectTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/ProjectTest.java @@ -2,29 +2,13 @@ package org.onap.vid.aai.model; import org.junit.Test; -public class ProjectTest { - - private Project createTestSubject() { - return new Project(); - } - - @Test - public void testGetProjectName() throws Exception { - Project testSubject; - String result; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; - // default test - testSubject = createTestSubject(); - result = testSubject.getProjectName(); - } +public class ProjectTest { @Test - public void testSetProjectName() throws Exception { - Project testSubject; - String projectName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setProjectName(projectName); + public void shouldHaveValidGettersAndSetters(){ + assertThat(Project.class, hasValidGettersAndSetters()); } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/RelatedToPropertyTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelatedToPropertyTest.java index 0d26f5607..fd01e133c 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/RelatedToPropertyTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelatedToPropertyTest.java @@ -2,54 +2,13 @@ package org.onap.vid.aai.model; import org.junit.Test; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; public class RelatedToPropertyTest { - private RelatedToProperty createTestSubject() { - return new RelatedToProperty(); - } - - - @Test - public void testGetPropertyKey() throws Exception { - RelatedToProperty testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getPropertyKey(); - } - - @Test - public void testSetPropertyKey() throws Exception { - RelatedToProperty testSubject; - String propertyKey = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setPropertyKey(propertyKey); - } - - - @Test - public void testGetPropertyValue() throws Exception { - RelatedToProperty testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getPropertyValue(); - } - - - @Test - public void testSetPropertyValue() throws Exception { - RelatedToProperty testSubject; - String propertyValue = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setPropertyValue(propertyValue); + public void shouldHaveValidGettersAndSetters(){ + assertThat(RelatedToProperty.class, hasValidGettersAndSetters()); } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipDataTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipDataTest.java index ae5f7c39a..9e112f1e3 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipDataTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipDataTest.java @@ -2,54 +2,14 @@ package org.onap.vid.aai.model; import org.junit.Test; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; -public class RelationshipDataTest { - - private RelationshipData createTestSubject() { - return new RelationshipData(); - } - - - @Test - public void testGetRelationshipKey() throws Exception { - RelationshipData testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelationshipKey(); - } - - - @Test - public void testSetRelationshipKey() throws Exception { - RelationshipData testSubject; - String relationshipKey = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setRelationshipKey(relationshipKey); - } - - - @Test - public void testGetRelationshipValue() throws Exception { - RelationshipData testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelationshipValue(); - } +public class RelationshipDataTest { @Test - public void testSetRelationshipValue() throws Exception { - RelationshipData testSubject; - String relationshipValue = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setRelationshipValue(relationshipValue); + public void shouldHaveValidGettersAndSetters(){ + assertThat(RelationshipData.class, hasValidGettersAndSetters()); } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipTest.java index 893fc51fc..7ae9ca59b 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/RelationshipTest.java @@ -1,103 +1,15 @@ package org.onap.vid.aai.model; -import java.util.List; - import org.junit.Test; -import org.onap.vid.aai.model.Relationship; -import org.onap.vid.aai.model.RelationshipData; - - -public class RelationshipTest { - - private Relationship createTestSubject() { - return new Relationship(); - } - - - @Test - public void testGetRelatedTo() throws Exception { - Relationship testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelatedTo(); - } - - - @Test - public void testSetRelatedTo() throws Exception { - Relationship testSubject; - String relatedTo = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setRelatedTo(relatedTo); - } - - - @Test - public void testGetRelatedLink() throws Exception { - Relationship testSubject; - String result; - // default test - testSubject = createTestSubject(); - result = testSubject.getRelatedLink(); - } +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; - @Test - public void testSetRelatedLink() throws Exception { - Relationship testSubject; - String relatedLink = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setRelatedLink(relatedLink); - } - - - @Test - public void testGetRelationDataList() throws Exception { - Relationship testSubject; - List result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelationDataList(); - } - - - @Test - public void testSetRelationDataList() throws Exception { - Relationship testSubject; - List relationDataList = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRelationDataList(relationDataList); - } - - - @Test - public void testGetRelatedToPropertyList() throws Exception { - Relationship testSubject; - List result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelatedToPropertyList(); - } - - - @Test - public void testSetRelatedToPropertyList() throws Exception { - Relationship testSubject; - List relatedToPropertyList = null; +public class RelationshipTest { - // default test - testSubject = createTestSubject(); - testSubject.setRelatedToPropertyList(relatedToPropertyList); - } + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(Relationship.class, hasValidGettersAndSetters()); + } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/ResultTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/ResultTest.java index 91d7763ec..9f71959fc 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/ResultTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/ResultTest.java @@ -2,29 +2,13 @@ package org.onap.vid.aai.model; import org.junit.Test; -public class ResultTest { - - private Result createTestSubject() { - return new Result(); - } - - @Test - public void testGetModel() throws Exception { - Result testSubject; - Model result; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; - // default test - testSubject = createTestSubject(); - result = testSubject.getModel(); - } +public class ResultTest { @Test - public void testSetModel() throws Exception { - Result testSubject; - Model model = null; - - // default test - testSubject = createTestSubject(); - testSubject.setModel(model); + public void shouldHaveValidGettersAndSetters() { + assertThat(Result.class, hasValidGettersAndSetters()); } } \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/ServiceRelationshipsTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/ServiceRelationshipsTest.java index e8bcf5f57..9b51ee196 100644 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/ServiceRelationshipsTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/aai/model/ServiceRelationshipsTest.java @@ -2,164 +2,14 @@ package org.onap.vid.aai.model; import org.junit.Test; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.hamcrest.MatcherAssert.assertThat; -public class ServiceRelationshipsTest { - - private ServiceRelationships createTestSubject() { - return new ServiceRelationships(); - } - - - @Test - public void testGetServiceInstanceId() throws Exception { - ServiceRelationships testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceInstanceId(); - } - - - @Test - public void testSetServiceInstanceId() throws Exception { - ServiceRelationships testSubject; - String serviceInstanceId = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceInstanceId(serviceInstanceId); - } - - - @Test - public void testGetServiceInstanceName() throws Exception { - ServiceRelationships testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getServiceInstanceName(); - } - - - @Test - public void testSetServiceInstanceName() throws Exception { - ServiceRelationships testSubject; - String serviceInstanceName = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setServiceInstanceName(serviceInstanceName); - } - - - @Test - public void testGetModelInvariantId() throws Exception { - ServiceRelationships testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getModelInvariantId(); - } - - - @Test - public void testSetModelInvariantId() throws Exception { - ServiceRelationships testSubject; - String modelInvariantId = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setModelInvariantId(modelInvariantId); - } - - - @Test - public void testGetModelVersionId() throws Exception { - ServiceRelationships testSubject; - String result; - // default test - testSubject = createTestSubject(); - result = testSubject.getModelVersionId(); - } - - - @Test - public void testSetModelVersionId() throws Exception { - ServiceRelationships testSubject; - String modelVersionId = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setModelVersionId(modelVersionId); - } - - - @Test - public void testGetResourceVersion() throws Exception { - ServiceRelationships testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getResourceVersion(); - } - - - @Test - public void testSetResourceVersion() throws Exception { - ServiceRelationships testSubject; - String resourceVersion = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setResourceVersion(resourceVersion); - } - - - @Test - public void testGetOrchestrationStatus() throws Exception { - ServiceRelationships testSubject; - String result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getOrchestrationStatus(); - } - - - @Test - public void testSetOrchestrationStatus() throws Exception { - ServiceRelationships testSubject; - String orchestrationStatus = ""; - - // default test - testSubject = createTestSubject(); - testSubject.setOrchestrationStatus(orchestrationStatus); - } - - - @Test - public void testGetRelationshipList() throws Exception { - ServiceRelationships testSubject; - RelationshipList result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getRelationshipList(); - } - - - @Test - public void testSetRelationshipList() throws Exception { - ServiceRelationships testSubject; - RelationshipList relationshipList = null; +public class ServiceRelationshipsTest { - // default test - testSubject = createTestSubject(); - testSubject.setRelationshipList(relationshipList); - } + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(ServiceRelationships.class, hasValidGettersAndSetters()); + } } \ No newline at end of file -- cgit 1.2.3-korg