aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java
diff options
context:
space:
mode:
authorBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>2019-03-04 15:49:50 +0100
committerBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>2019-03-14 14:30:44 +0100
commit1d08ac7a18f134c9d707d2c280f9531829ef1bf3 (patch)
treeb719064d7441c97cc6da05bdb987a019c3894eb5 /vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java
parente603e0dfbd8bacbb9cf944d209f155651639c250 (diff)
Increasing test coverage for vid.mso.rest
Change-Id: I48a5827875f9d0023f183cff58b0aaed0e28910b Issue-ID: VID-387 Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com>
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java113
1 files changed, 43 insertions, 70 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java
index 1a8aa3b48..c76298442 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RelatedInstanceTest.java
@@ -3,13 +3,14 @@
* VID
* ================================================================================
* Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nokia. 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.
@@ -20,94 +21,66 @@
package org.onap.vid.mso.rest;
-import org.junit.Test;
-import org.onap.vid.mso.model.ModelInfo;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
-import java.util.Map;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
public class RelatedInstanceTest {
- private RelatedInstance createTestSubject() {
- return new RelatedInstance();
- }
+ private RelatedInstance relatedInstance = new RelatedInstance();
-
- @Test
- public void testGetModelInfo() throws Exception {
- RelatedInstance testSubject;
- ModelInfo result;
+ private String instanceId = "testInstanceId";
+ private String InstanceName = "testInstance";
+ private String propertyName = "testProperty";
+ private String additionalProperty = "testAdditionalProperty";
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModelInfo();
+ @BeforeMethod
+ public void setUp() {
+ relatedInstance = new RelatedInstance();
}
-
@Test
- public void testSetModelInfo() throws Exception {
- RelatedInstance testSubject;
- ModelInfo modelInfo = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setModelInfo(modelInfo);
+ public void shouldHaveProperGettersAndSetters() {
+ assertThat(RelatedInstance.class, hasValidGettersAndSettersExcluding("additionalProperties"));
}
-
@Test
- public void testToString() throws Exception {
- RelatedInstance testSubject;
- String result;
+ public void shouldHaveProperGetterAndSetterForAdditionalProperties() {
+ // when
+ relatedInstance.setAdditionalProperty(propertyName,additionalProperty);
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
+ // then
+ assertThat( relatedInstance.getAdditionalProperties().get(propertyName) ).isEqualTo(additionalProperty);
}
-
@Test
- public void testGetAdditionalProperties() throws Exception {
- RelatedInstance testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAdditionalProperties();
+ public void shouldProperlyConvertRelatedInstanceObjectToString() {
+ // given
+ relatedInstance.setInstanceId(instanceId);
+ relatedInstance.setInstanceName(InstanceName);
+ relatedInstance.setAdditionalProperty(propertyName,additionalProperty);
+
+ // when
+ String response = relatedInstance.toString();
+
+ // then
+ assertThat(response).contains(
+ "instanceName="+InstanceName+"," +
+ "instanceId="+instanceId+"," +
+ "modelInfo=<null>," +
+ "additionalProperties={"+propertyName+"="+additionalProperty+"}]"
+ );
}
-
@Test
- public void testSetAdditionalProperty() throws Exception {
- RelatedInstance testSubject;
- String name = "";
- Object value = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setAdditionalProperty(name, value);
+ public void shouldProperlyCheckIfObjectsAreEqual() {
+ assertThat(RelatedInstance.class, hasValidBeanEqualsExcluding("additionalProperties"));
}
-
- @Test
- public void testHashCode() throws Exception {
- RelatedInstance testSubject;
- int result;
- // default test
- testSubject = createTestSubject();
- result = testSubject.hashCode();
- }
-
-
- @Test
- public void testEquals() throws Exception {
- RelatedInstance testSubject;
- Object other = null;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.equals(other);
- }
-}
+} \ No newline at end of file