diff options
author | Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> | 2019-03-04 15:49:50 +0100 |
---|---|---|
committer | Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> | 2019-03-14 14:30:44 +0100 |
commit | 1d08ac7a18f134c9d707d2c280f9531829ef1bf3 (patch) | |
tree | b719064d7441c97cc6da05bdb987a019c3894eb5 /vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestListTest.java | |
parent | e603e0dfbd8bacbb9cf944d209f155651639c250 (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/RequestListTest.java')
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestListTest.java | 99 |
1 files changed, 35 insertions, 64 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestListTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestListTest.java index 12c11e091..f7e6deea8 100644 --- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestListTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/RequestListTest.java @@ -7,9 +7,9 @@ * 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,86 +20,57 @@ package org.onap.vid.mso.rest; -import java.util.List; -import java.util.Map; +import org.assertj.core.api.AssertionsForClassTypes; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; -import org.junit.Test; +import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding; +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding; +import static org.hamcrest.MatcherAssert.assertThat; public class RequestListTest { - private RequestList createTestSubject() { - return new RequestList(); - } + private RequestList requestList; - @Test - public void testGetRequestList() throws Exception { - RequestList testSubject; - List<RequestWrapper> result; + private String propertyName = "testProperty"; + private String additionalProperty = "testAdditionalProperty"; - // default test - testSubject = createTestSubject(); - result = testSubject.getRequestList(); + @BeforeMethod + public void setUp() { + requestList = new RequestList(); } @Test - public void testSetRequestList() throws Exception { - RequestList testSubject; - List<RequestWrapper> l = null; - - // default test - testSubject = createTestSubject(); - testSubject.setRequestList(l); + public void shouldHaveProperSettersAndGetters() { + assertThat(RequestList.class, hasValidGettersAndSettersExcluding("additionalProperties")); } @Test - public void testToString() throws Exception { - RequestList testSubject; - String result; + public void shouldHaveProperGetterAndSetterForAdditionalProperties() { + // when + requestList.setAdditionalProperty(propertyName,additionalProperty); - // default test - testSubject = createTestSubject(); - result = testSubject.toString(); + // then + AssertionsForClassTypes.assertThat( requestList.getAdditionalProperties().get(propertyName) ).isEqualTo(additionalProperty); } @Test - public void testGetAdditionalProperties() throws Exception { - RequestList testSubject; - Map<String, Object> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getAdditionalProperties(); + public void shouldProperlyCheckIfObjectsAreEqual() { + assertThat(RequestList.class, hasValidBeanEqualsExcluding("additionalProperties")); } @Test - public void testSetAdditionalProperty() throws Exception { - RequestList testSubject; - String name = ""; - Object value = null; - - // default test - testSubject = createTestSubject(); - testSubject.setAdditionalProperty(name, value); - } - - @Test - public void testHashCode() throws Exception { - RequestList testSubject; - int result; - - // default test - testSubject = createTestSubject(); - result = testSubject.hashCode(); - } - - @Test - public void testEquals() throws Exception { - RequestList testSubject; - Object other = null; - boolean result; - - // default test - testSubject = createTestSubject(); - result = testSubject.equals(other); + public void shouldProperlyConvertRelatedInstanceObjectToString() { + // given + requestList.setAdditionalProperty(propertyName,additionalProperty); + + // when + String response = requestList.toString(); + + // then + System.out.println(response); + AssertionsForClassTypes.assertThat(response).contains( + "additionalProperties={"+propertyName+"="+additionalProperty+"}]" + ); } } |