CCM NG: More entities, parameterised test class for verifing equals implementation of the entities.

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3430 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2015-05-26 16:49:11 +00:00
parent c05c7b20e1
commit 3cccfdc215
10 changed files with 634 additions and 0 deletions

View File

@ -0,0 +1,107 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.libreccm.formbuilder.actions;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import org.libreccm.formbuilder.ProcessListener;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "formbuilder_confirm_email_listener")
public class ConfirmEmailListener
extends ProcessListener
implements Serializable {
private static final long serialVersionUID = -7009695795355273248L;
@Column(name = "from_email")
private String fromEmail;
@Column(name = "subject")
private String subject;
@Column(name = "body")
@Lob
private String body;
public String getFromEmail() {
return fromEmail;
}
public void setFromEmail(final String fromEmail) {
this.fromEmail = fromEmail;
}
public String getSubject() {
return subject;
}
public void setSubject(final String subject) {
this.subject = subject;
}
public String getBody() {
return body;
}
public void setBody(final String body) {
this.body = body;
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 19 * hash + Objects.hashCode(this.fromEmail);
hash = 19 * hash + Objects.hashCode(this.subject);
hash = 19 * hash + Objects.hashCode(this.body);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ConfirmEmailListener other = (ConfirmEmailListener) obj;
if (!other.canEqual(this)) {
return false;
}
if (!Objects.equals(this.fromEmail, other.fromEmail)) {
return false;
}
if (!Objects.equals(this.subject, other.subject)) {
return false;
}
return Objects.equals(this.body, other.body);
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof ConfirmEmailListener;
}
@Override
public String toString(final String data) {
return super.toString(String.format(", fromEmail = \"%s\","
+ "subject = \"%s\", ",
fromEmail,
subject,
data));
}
}

View File

@ -0,0 +1,73 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.libreccm.formbuilder.actions;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.libreccm.formbuilder.ProcessListener;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "formbuilder_confirm_redirect_listeners")
public class ConfirmRedirectListener
extends ProcessListener
implements Serializable {
private static final long serialVersionUID = 7891034630202555922L;
@Column(name = "url")
private String url;
public String getUrl() {
return url;
}
public void setUrl(final String url) {
this.url = url;
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 97 * hash + Objects.hashCode(this.url);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ConfirmRedirectListener other = (ConfirmRedirectListener) obj;
if (!other.canEqual(this)) {
return false;
}
return Objects.equals(this.url, other.url);
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof ConfirmRedirectListener;
}
@Override
public String toString(final String data) {
return super.toString(String.format(", url = \"%s\"%s",
url,
data));
}
}

View File

@ -0,0 +1,66 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.libreccm.formbuilder.actions;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.libreccm.formbuilder.ProcessListener;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "formbuilder_remote_server_post_listener")
public class RemoteServerPostListener
extends ProcessListener
implements Serializable {
private static final long serialVersionUID = 7095242410811956838L;
private String remoteUrl;
public String getRemoteUrl() {
return remoteUrl;
}
public void setRemoteUrl(final String remoteUrl) {
this.remoteUrl = remoteUrl;
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 37 * hash + Objects.hashCode(this.remoteUrl);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final RemoteServerPostListener other = (RemoteServerPostListener) obj;
if (!other.canEqual(this)) {
return false;
}
return Objects.equals(this.remoteUrl, other.remoteUrl);
}
@Override
public String toString(final String data) {
return super.toString(String.format(", remoteUrl = \"%s\"%s",
remoteUrl,
data));
}
}

View File

@ -0,0 +1,49 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.libreccm.formbuilder.actions;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.annotations.CollectionId;
import org.libreccm.formbuilder.ProcessListener;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "formbuilder_simple_email_listeners")
public class SimpleEmailListener
extends ProcessListener
implements Serializable {
@Column(name = "recipient")
private String recipient;
@Column(name = "subject")
private String subject;
public String getRecipient() {
return recipient;
}
public void setRecipient(final String recipient) {
this.recipient = recipient;
}
public String getSubject() {
return subject;
}
public void setSubject(final String subject) {
this.subject = subject;
}
}

View File

@ -0,0 +1,107 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.libreccm.formbuilder.actions;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import org.libreccm.formbuilder.ProcessListener;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "formbuilder_template_email_listeners")
public class TemplateEmailListener
extends ProcessListener
implements Serializable {
private static final long serialVersionUID = -4476860960485494976L;
@Column(name = "recipient")
private String recipient;
@Column(name = "subject")
private String subject;
@Column(name = "body")
@Lob
private String body;
public String getRecipient() {
return recipient;
}
public void setRecipient(final String recipient) {
this.recipient = recipient;
}
public String getSubject() {
return subject;
}
public void setSubject(final String subject) {
this.subject = subject;
}
public String getBody() {
return body;
}
public void setBody(final String body) {
this.body = body;
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 67 * hash + Objects.hashCode(this.recipient);
hash = 67 * hash + Objects.hashCode(this.subject);
hash = 67 * hash + Objects.hashCode(this.body);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final TemplateEmailListener other = (TemplateEmailListener) obj;
if (!other.canEqual(this)) {
return false;
}
if (!Objects.equals(this.recipient, other.recipient)) {
return false;
}
if (!Objects.equals(this.subject, other.subject)) {
return false;
}
return Objects.equals(this.body, other.body);
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof TemplateEmailListener;
}
@Override
public String toString(final String data) {
return super.toString(String.format(", recipient = \"%s\", "
+ "subject = \"%s\"%s",
recipient,
subject,
data));
}
}

View File

@ -0,0 +1,88 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.libreccm.formbuilder.actions;
import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.libreccm.formbuilder.ProcessListener;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "formbuilder_xml_email_listeners")
public class XmlEmailListener extends ProcessListener implements Serializable {
private static final long serialVersionUID = -4607965414018004925L;
@Column(name = "recipient")
private String recipient;
@Column(name = "subject")
private String subject;
public String getRecipient() {
return recipient;
}
public void setRecipient(final String recipient) {
this.recipient = recipient;
}
public String getSubject() {
return subject;
}
public void setSubject(final String subject) {
this.subject = subject;
}
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 59 * hash + Objects.hashCode(this.recipient);
hash = 59 * hash + Objects.hashCode(this.subject);
return hash;
}
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final XmlEmailListener other = (XmlEmailListener) obj;
if (!other.canEqual(this)) {
return false;
}
if (!Objects.equals(this.recipient, other.recipient)) {
return false;
}
return Objects.equals(this.subject, other.subject);
}
@Override
public boolean canEqual(final Object obj) {
return obj instanceof XmlEmailListener;
}
@Override
public String toString(final String data) {
return super.toString(String.format(", recipient = \"%s\", "
+ "subject = \"%s\"%s",
recipient,
subject,
data));
}
}

View File

@ -0,0 +1,28 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.libreccm.formbuilder.actions;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.libreccm.formbuilder.ProcessListener;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Entity
@Table(name = "formbuilder_xml_listeners")
public class XmlListener extends ProcessListener implements Serializable {
private static final long serialVersionUID = -8674849210363260180L;
@Override
public boolean canEqual(final Object obj) {
return obj instanceof XmlListener;
}
}

View File

@ -0,0 +1,39 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.libreccm.core;
import java.util.Arrays;
import java.util.Collection;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.libreccm.categorization.Categorization;
import org.libreccm.categorization.Domain;
import org.libreccm.categorization.DomainOwnership;
import org.libreccm.tests.categories.UnitTest;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RunWith(Parameterized.class)
@Category(UnitTest.class)
public class CategorizationEntitiesTest extends EntitiesTestCore {
@Parameterized.Parameters
public static Collection<Class<?>> data() {
return Arrays.asList(new Class<?>[]{
Categorization.class,
org.libreccm.categorization.Category.class,
Domain.class,
DomainOwnership.class});
}
public CategorizationEntitiesTest(final Class<?> entitiesClass) {
super(entitiesClass);
}
}

View File

@ -0,0 +1,45 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.libreccm.core;
import java.util.Arrays;
import java.util.Collection;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.libreccm.tests.categories.UnitTest;
/**
* The tests in this class are used to verify the implementations of the
* {@code equals}, {@code hashCode} and {@code toString} methods of the entities
* in the {@code org.libreccm.core} package.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RunWith(Parameterized.class)
@Category(UnitTest.class)
public class CcmCoreEntitiesTest extends EntitiesTestCore {
@Parameterized.Parameters
public static Collection<Class<?>> data() {
return Arrays.asList(new Class<?>[]{
CcmObject.class,
EmailAddress.class,
GroupMembership.class,
Party.class,
Permission.class,
PersonName.class,
Privilege.class,
Resource.class,
Role.class,
User.class,
UserGroup.class});
}
public CcmCoreEntitiesTest(final Class<?> entityClass) {
super(entityClass);
}
}

View File

@ -0,0 +1,32 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.libreccm.core;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
import org.junit.Test;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class EntitiesTestCore {
private final Class<?> entityClass;
public EntitiesTestCore(final Class<?> entityClass) {
this.entityClass = entityClass;
}
@Test
public void verifyEqualsAndHashCode() {
EqualsVerifier
.forClass(entityClass)
.suppress(Warning.STRICT_INHERITANCE)
.withRedefinedSuperclass()
.verify();
}
}