> data() {
return Arrays.asList(new Class>[]{
CcmObject.class,
- EmailAddress.class,
-// GroupMembership.class,
-// Subject.class,
-// Permission.class,
-// PersonName.class,
-// Privilege.class,
- ResourceType.class,
-// Role.class,
-// User.class,
-// Group.class
- });
+ EmailAddress.class,});
}
public EqualsAndHashCodeTest(final Class> entityClass) {
- super(entityClass);
+ this.entityClass = entityClass;
}
-
+
+ @Test
+ public void verifyEqualsAndHashCode() {
+
+ final CcmObject ccmObject1 = new CcmObject();
+ ccmObject1.setObjectId(-100);
+ ccmObject1.setDisplayName("Object 1");
+
+ final CcmObject ccmObject2 = new CcmObject();
+ ccmObject1.setObjectId(-200);
+ ccmObject1.setDisplayName("Object 2");
+
+ final Role role1 = new Role();
+ role1.setName("role1");
+
+ final Role role2 = new Role();
+ role2.setName("role2");
+
+ final Group group1 = new Group();
+ group1.setName("group1");
+
+ final Group group2 = new Group();
+ group2.setName("group2");
+
+ final User user1 = new TestUser();
+ user1.setName("user1");
+
+ final User user2 = new TestUser();
+ user2.setName("user2");
+
+ final Category category1 = new Category();
+ category1.setName("Category One");
+
+ final Category category2 = new Category();
+ category2.setName("Category Two");
+
+ EqualsVerifier
+ .forClass(entityClass)
+ .suppress(Warning.STRICT_INHERITANCE)
+ .suppress(Warning.NONFINAL_FIELDS)
+ .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
+ .withRedefinedSuperclass()
+ .withPrefabValues(CcmObject.class, ccmObject1, ccmObject2)
+ .withPrefabValues(Role.class, role1, role2)
+ .withPrefabValues(Group.class, group1, group2)
+ .withPrefabValues(User.class, user1, user2)
+ .withPrefabValues(Category.class, category1, category2)
+ .verify();
+ }
+
+ /**
+ * {@link User} has a protected constructor, so have have do this to create
+ * users for the test...
+ */
+ private class TestUser extends User {
+
+ private static final long serialVersionUID = -9052762220990453621L;
+
+ protected TestUser() {
+ super();
+ }
+
+ }
+
}
diff --git a/ccm-core/src/test/java/org/libreccm/formbuilder/EqualsAndHashCodeTest.java b/ccm-core/src/test/java/org/libreccm/formbuilder/EqualsAndHashCodeTest.java
index b7234bed1..6b2fced3e 100644
--- a/ccm-core/src/test/java/org/libreccm/formbuilder/EqualsAndHashCodeTest.java
+++ b/ccm-core/src/test/java/org/libreccm/formbuilder/EqualsAndHashCodeTest.java
@@ -64,38 +64,39 @@ public class EqualsAndHashCodeTest {
public void verifyEqualsAndHashCode() {
final Component component1 = new Component();
component1.setAdminName("Component One");
-
+
final Component component2 = new Component();
component2.setAdminName("Component Two");
-
+
final WidgetLabel widgetLabel1 = new WidgetLabel();
widgetLabel1.setAdminName("WidgetLabel One");
-
+
final WidgetLabel widgetLabel2 = new WidgetLabel();
widgetLabel2.setAdminName("WidgetLabel Two");
-
+
final Widget widget1 = new Widget();
widget1.setAdminName("Widget 1");
-
+
final Widget widget2 = new Widget();
widget2.setAdminName("Widget 2");
-
+
final FormSection formSection1 = new FormSection();
formSection1.setAdminName("FormSection One");
-
+
final FormSection formSection2 = new FormSection();
formSection2.setAdminName("FormSection Two");
-
+
EqualsVerifier
- .forClass(entityClass)
- .suppress(Warning.STRICT_INHERITANCE)
- .suppress(Warning.NONFINAL_FIELDS)
- .withRedefinedSuperclass()
- .withPrefabValues(Component.class, component1, component2)
- .withPrefabValues(WidgetLabel.class, widgetLabel1, widgetLabel2)
- .withPrefabValues(Widget.class, widget1, widget2)
- .withPrefabValues(FormSection.class, formSection1, formSection2)
- .verify();
+ .forClass(entityClass)
+ .suppress(Warning.STRICT_INHERITANCE)
+ .suppress(Warning.NONFINAL_FIELDS)
+ .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
+ .withRedefinedSuperclass()
+ .withPrefabValues(Component.class, component1, component2)
+ .withPrefabValues(WidgetLabel.class, widgetLabel1, widgetLabel2)
+ .withPrefabValues(Widget.class, widget1, widget2)
+ .withPrefabValues(FormSection.class, formSection1, formSection2)
+ .verify();
}
}
diff --git a/ccm-core/src/test/java/org/libreccm/formbuilder/actions/EqualsAndHashCodeTest.java b/ccm-core/src/test/java/org/libreccm/formbuilder/actions/EqualsAndHashCodeTest.java
index 8ffaab766..ad17c8302 100644
--- a/ccm-core/src/test/java/org/libreccm/formbuilder/actions/EqualsAndHashCodeTest.java
+++ b/ccm-core/src/test/java/org/libreccm/formbuilder/actions/EqualsAndHashCodeTest.java
@@ -21,7 +21,6 @@ package org.libreccm.formbuilder.actions;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import org.junit.Test;
-import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.libreccm.formbuilder.Component;
@@ -30,13 +29,18 @@ import org.libreccm.tests.categories.UnitTest;
import java.util.Arrays;
import java.util.Collection;
+import org.libreccm.categorization.Category;
+import org.libreccm.core.CcmObject;
+import org.libreccm.security.Group;
+import org.libreccm.security.Role;
+import org.libreccm.security.User;
/**
*
* @author Jens Pelzetter
*/
@RunWith(Parameterized.class)
-@Category(UnitTest.class)
+@org.junit.experimental.categories.Category(UnitTest.class)
public class EqualsAndHashCodeTest {
private final Class> entityClass;
@@ -61,24 +65,76 @@ public class EqualsAndHashCodeTest {
public void verifyEqualsAndHashCode() {
final Component component1 = new Component();
component1.setAdminName("Component One");
-
+
final Component component2 = new Component();
component2.setAdminName("Component Two");
-
+
final FormSection formSection1 = new FormSection();
formSection1.setAdminName("FormSection One");
-
+
final FormSection formSection2 = new FormSection();
formSection2.setAdminName("FormSection Two");
-
+
+ final CcmObject ccmObject1 = new CcmObject();
+ ccmObject1.setObjectId(-100);
+ ccmObject1.setDisplayName("Object 1");
+
+ final CcmObject ccmObject2 = new CcmObject();
+ ccmObject1.setObjectId(-200);
+ ccmObject1.setDisplayName("Object 2");
+
+ final Role role1 = new Role();
+ role1.setName("role1");
+
+ final Role role2 = new Role();
+ role2.setName("role2");
+
+ final Group group1 = new Group();
+ group1.setName("group1");
+
+ final Group group2 = new Group();
+ group2.setName("group2");
+
+ final User user1 = new TestUser();
+ user1.setName("user1");
+
+ final User user2 = new TestUser();
+ user2.setName("user2");
+
+ final Category category1 = new Category();
+ category1.setName("Category One");
+
+ final Category category2 = new Category();
+ category2.setName("Category Two");
+
EqualsVerifier
- .forClass(entityClass)
- .suppress(Warning.STRICT_INHERITANCE)
- .suppress(Warning.NONFINAL_FIELDS)
- .withRedefinedSuperclass()
- .withPrefabValues(Component.class, component1, component2)
- .withPrefabValues(FormSection.class, formSection1, formSection2)
- .verify();
+ .forClass(entityClass)
+ .suppress(Warning.STRICT_INHERITANCE)
+ .suppress(Warning.NONFINAL_FIELDS)
+ .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
+ .withRedefinedSuperclass()
+ .withPrefabValues(Component.class, component1, component2)
+ .withPrefabValues(FormSection.class, formSection1, formSection2)
+ .withPrefabValues(CcmObject.class, ccmObject1, ccmObject2)
+ .withPrefabValues(Role.class, role1, role2)
+ .withPrefabValues(Group.class, group1, group2)
+ .withPrefabValues(User.class, user1, user2)
+ .withPrefabValues(Category.class, category1, category2)
+ .verify();
+ }
+
+ /**
+ * {@link User} has a protected constructor, so have have do this to create
+ * users for the test...
+ */
+ private class TestUser extends User {
+
+ private static final long serialVersionUID = -9052762220990453621L;
+
+ protected TestUser() {
+ super();
+ }
+
}
}
diff --git a/ccm-testutils/src/main/java/org/libreccm/testutils/EqualsVerifier.java b/ccm-testutils/src/main/java/org/libreccm/testutils/EqualsVerifier.java
index a325ef7ba..208df4dae 100644
--- a/ccm-testutils/src/main/java/org/libreccm/testutils/EqualsVerifier.java
+++ b/ccm-testutils/src/main/java/org/libreccm/testutils/EqualsVerifier.java
@@ -23,47 +23,48 @@ import org.junit.Test;
import org.junit.runners.Parameterized;
/**
- * A base class for verifying the implementations of the {@code equals()}
- * and {@code hashCode} methods of an object using the {@link Parameterized}
- * test runner from JUnit.
- *
- * To use this class create a new JUnit test class which extends this class
- * and which uses the {@link Parameterized} test runner. The class must have a
+ * A base class for verifying the implementations of the {@code equals()} and
+ * {@code hashCode} methods of an object using the {@link Parameterized} test
+ * runner from JUnit.
+ *
+ * To use this class create a new JUnit test class which extends this class and
+ * which uses the {@link Parameterized} test runner. The class must have a
* static method which provides the classes to be tested. Example for testing
* the classes {@code Foo} and {@code Bar} (imports have been omitted):
- *
+ *
*
*
* @RunWith(Parameterized.class)
* @Category(UnitTest.class)
* public class FooBarTest extends EqualsVerifier {
- *
+ *
* @Parameterized.Parameters(name = "{0}")
* public static Collection> data() {
* return Arrays.asList(new Class>[] {
* Foo.class,
* Bar.class
- * });
+ * });
* }
- *
+ *
* public FooBarTest(final Class> entityClass) {
* super(entityClass);
* }
* }
*
*
- *
+ *
* An example in ccm-core is the
- * EqualsAndHashCodeTest
+ * EqualsAndHashCodeTest
* in the {@code org.libreccm.core} package.
- *
- * For testing {@code equals} and {@code hashCode} this class uses the
- * http://www.jqno.nl/equalsverifier/ utility. If
+ *
+ * For testing {@code equals} and {@code hashCode} this class uses the
+ * http://www.jqno.nl/equalsverifier/ utility. If
* the classes to verify are part of complex inheritance hierarchy you may need
- * to create your own test using the {@code EqualsVerifier}. An example in
- * ccm-core is the ResourceEntityTest
+ * to create your own test using the {@code EqualsVerifier}. An example in
+ * ccm-core is the
+ * ResourceEntityTest
* in the {@code org.libreccm.core} package.
- *
+ *
* @author Jens Pelzetter
*/
public class EqualsVerifier {
@@ -77,10 +78,11 @@ public class EqualsVerifier {
@Test
public void verifyEqualsAndHashCode() {
nl.jqno.equalsverifier.EqualsVerifier
- .forClass(entityClass)
- .suppress(Warning.STRICT_INHERITANCE)
- .suppress(Warning.NONFINAL_FIELDS)
- .withRedefinedSuperclass()
- .verify();
+ .forClass(entityClass)
+ .suppress(Warning.STRICT_INHERITANCE)
+ .suppress(Warning.NONFINAL_FIELDS)
+ .suppress(Warning.ALL_FIELDS_SHOULD_BE_USED)
+ .withRedefinedSuperclass()
+ .verify();
}
}
diff --git a/pom.xml b/pom.xml
index 309c11e96..c6bbaa026 100644
--- a/pom.xml
+++ b/pom.xml
@@ -542,7 +542,8 @@
nl.jqno.equalsverifier
equalsverifier
- 1.7.8
+
+ 2.0.2