aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-03-06 14:25:02 +0200
committerIttay Stern <ittay.stern@att.com>2019-03-06 17:54:56 +0200
commit54aad7deb7a02ecca4bc7ed4d7913ccd59eb3bf9 (patch)
tree84250549f1d7e91234a41960866098d5d147ebbf /vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java
parent7c64fbbaff5985acb3a6aea977c5c15b4f2f59e1 (diff)
Fix cyclic CategoryParameterOption::hashCode
Issue-ID: VID-430 Change-Id: Ib49b71726fe508f1ec9bfe8c60836af1c5ca786b Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java186
1 files changed, 32 insertions, 154 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java b/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java
index dc18c3065..c515a34d4 100644
--- a/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/model/CategoryParameterTest.java
@@ -20,186 +20,64 @@
package org.onap.vid.model;
-import java.io.Serializable;
-import java.util.Date;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanEqualsExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidBeanHashCodeExcluding;
+import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.onap.vid.testUtils.TestUtils.allPropertiesOf;
+
+import com.google.common.collect.ImmutableSet;
import java.util.Set;
-
+import org.apache.commons.lang3.ArrayUtils;
import org.junit.Test;
+import org.onap.portalsdk.core.domain.support.DomainVo;
public class CategoryParameterTest {
- private CategoryParameter createTestSubject() {
- return new CategoryParameter();
- }
-
- @Test
- public void testGetFamily() throws Exception {
- CategoryParameter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getFamily();
- }
-
- @Test
- public void testSetFamily() throws Exception {
- CategoryParameter testSubject;
- String family = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setFamily(family);
- }
-
- @Test
- public void testGetId() throws Exception {
- CategoryParameter testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getId();
- }
-
- @Test
- public void testGetCreated() throws Exception {
- CategoryParameter testSubject;
- Date result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCreated();
- }
-
- @Test
- public void testGetModified() throws Exception {
- CategoryParameter testSubject;
- Date result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModified();
- }
-
- @Test
- public void testGetCreatedId() throws Exception {
- CategoryParameter testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getCreatedId();
- }
-
- @Test
- public void testGetModifiedId() throws Exception {
- CategoryParameter testSubject;
- Long result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getModifiedId();
- }
-
- @Test
- public void testGetName() throws Exception {
- CategoryParameter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
- @Test
- public void testSetName() throws Exception {
- CategoryParameter testSubject;
- String name = "";
+ final private String[] excludedProperties = allPropertiesOf(DomainVo.class);
- // default test
- testSubject = createTestSubject();
- testSubject.setName(name);
+ private ImmutableSet<CategoryParameterOption> optionsWithRefTo(CategoryParameter categoryParameter) {
+ return ImmutableSet.of(
+ new CategoryParameterOption("appId1", "name1", categoryParameter),
+ new CategoryParameterOption("appId2", "name2", categoryParameter)
+ );
}
@Test
- public void testGetAuditUserId() throws Exception {
- CategoryParameter testSubject;
- Serializable result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAuditUserId();
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(CategoryParameter.class, hasValidGettersAndSettersExcluding("options"));
}
@Test
- public void testGetRowNum() throws Exception {
- CategoryParameter testSubject;
- Long result;
+ public void testSetAndGetOptions() {
+ CategoryParameter testSubject = new CategoryParameter();
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRowNum();
- }
-
- @Test
- public void testGetAuditTrail() throws Exception {
- CategoryParameter testSubject;
- Set result;
+ Set<CategoryParameterOption> options = optionsWithRefTo(testSubject);
- // default test
- testSubject = createTestSubject();
- result = testSubject.getAuditTrail();
+ testSubject.setOptions(options);
+ assertThat(testSubject.getOptions(), containsInAnyOrder(optionsWithRefTo(testSubject).toArray()));
}
@Test
- public void testGetOptions() throws Exception {
- CategoryParameter testSubject;
- Set<CategoryParameterOption> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getOptions();
+ public void shouldHaveValidBeanHashCodeWithCycleReference() {
+ assertThat(CategoryParameter.class,
+ hasValidBeanHashCodeExcluding(ArrayUtils.addAll(new String[]{"options"}, excludedProperties)));
}
@Test
- public void testSetOptions() throws Exception {
- CategoryParameter testSubject;
- Set<CategoryParameterOption> options = null;
-
- // default test
- testSubject = createTestSubject();
+ public void hashCodeShouldNotExplodeWhenCycleReference() {
+ CategoryParameter testSubject = new CategoryParameter();
+ Set<CategoryParameterOption> options = optionsWithRefTo(testSubject);
testSubject.setOptions(options);
- }
- @Test
- public void testAddOption() throws Exception {
- CategoryParameter testSubject;
- CategoryParameterOption option = null;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.addOption(option);
+ testSubject.hashCode(); // don't stackOverflow
}
@Test
- public void testIsIdSupported() throws Exception {
- CategoryParameter testSubject;
- boolean result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.isIdSupported();
+ public void shouldHaveValidBeanEquals() {
+ assertThat(CategoryParameter.class, hasValidBeanEqualsExcluding(excludedProperties));
}
- @Test
- public void testSetIdSupported() throws Exception {
- CategoryParameter testSubject;
- boolean idSupported = false;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setIdSupported(idSupported);
- }
}