Disabled EqualsAndHashCode, needs refactoring for new version of

EqualsVerifier
pull/1/head
Jens Pelzetter 2019-09-06 12:31:19 +02:00
parent a16579771c
commit 8828cfbfc6
4 changed files with 188 additions and 15 deletions

View File

@ -101,6 +101,13 @@ public class Publication implements Serializable {
@Column(name = "LANGUAGE_OF_PUBLICATION")
private Locale languageOfPublication;
public Publication() {
title = new LocalizedString();
shortDescription = new LocalizedString();
publicationAbstract = new LocalizedString();
misc = new LocalizedString();
}
public long getPublicationId() {
return publicationId;
}

View File

@ -0,0 +1,65 @@
/*
* 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.scientificcms.publications;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.tests.categories.UnitTest;
import org.libreccm.testutils.EqualsVerifier;
import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RunWith(Parameterized.class)
@org.junit.experimental.categories.Category(UnitTest.class)
public class EqualsAndHashCodeTest extends EqualsVerifier {
@Parameterized.Parameters(name = "{0}")
public static Collection<Class<?>> data() {
return Arrays.asList(new Class<?>[]{
ArticleInCollectedVolume.class,
ArticleInJournal.class,
CollectedVolume.class,
Expertise.class,
GreyLiterature.class,
InProceedings.class,
InternetArticle.class,
Journal.class,
Monograph.class,
Proceedings.class,
Publication.class,
PublicationWithPublisher.class,
Publisher.class,
Talk.class,
UnPublished.class,
WorkingPaper.class
});
}
public EqualsAndHashCodeTest(final Class<?> clazz) {
super(clazz);
}
@Override
protected void addPrefabValues(
final nl.jqno.equalsverifier.EqualsVerifier<?> verifier) {
final CollectedVolume volume1 = new CollectedVolume();
volume1.getTitle().addValue(Locale.ENGLISH, "Test 1");
final CollectedVolume volume2 = new CollectedVolume();
volume2.getTitle().addValue(Locale.ENGLISH, "Test 2");
verifier.withPrefabValues(CollectedVolume.class, volume1, volume2);
}
}

View File

@ -0,0 +1,104 @@
/*
* 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.scientificcms.publications.assets;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.libreccm.tests.categories.UnitTest;
import org.libreccm.testutils.EqualsVerifier;
import org.librecms.contentsection.AttachmentList;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentType;
import org.librecms.contentsection.ItemAttachment;
import org.scientificcms.publications.ArticleInJournal;
import org.scientificcms.publications.CollectedVolume;
import org.scientificcms.publications.Journal;
import org.scientificcms.publications.Publisher;
import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RunWith(Parameterized.class)
@org.junit.experimental.categories.Category(UnitTest.class)
public class EqualsAndHashCodeTest extends EqualsVerifier {
@Parameterized.Parameters(name = "{0}")
public static Collection<Class<?>> data() {
return Arrays.asList(new Class<?>[]{
CollectedVolumeAsset.class,
JournalAsset.class,
ProceedingsAsset.class,
PublisherAsset.class
});
}
public EqualsAndHashCodeTest(final Class<?> clazz) {
super(clazz);
}
@Override
protected void addPrefabValues(
final nl.jqno.equalsverifier.EqualsVerifier<?> verifier) {
final CollectedVolume volume1 = new CollectedVolume();
volume1.getTitle().addValue(Locale.ENGLISH, "Test 1");
final CollectedVolume volume2 = new CollectedVolume();
volume2.getTitle().addValue(Locale.ENGLISH, "Test 2");
verifier.withPrefabValues(CollectedVolume.class, volume1, volume2);
final CollectedVolumeAsset volumeAsset1 = new CollectedVolumeAsset();
volumeAsset1.setCollectedVolume(volume1);
final CollectedVolumeAsset volumeAsset2 = new CollectedVolumeAsset();
volumeAsset2.setCollectedVolume(volume2);
verifier.withPrefabValues(CollectedVolumeAsset.class,
volumeAsset1,
volumeAsset2);
final ContentSection section1 = new ContentSection();
section1.setDisplayName("section1");
final ContentSection section2 = new ContentSection();
section2.setDisplayName("section2");
verifier.withPrefabValues(ContentSection.class, section1, section2);
final ContentType type1 = new ContentType();
type1.setDisplayName("type1");
final ContentType type2 = new ContentType();
type2.setDisplayName("type2");
verifier.withPrefabValues(ContentType.class, type1, type2);
final ContentItem item1 = new ContentItem();
item1.setDisplayName("item1");
final ContentItem item2 = new ContentItem();
item2.setDisplayName("item2");
verifier.withPrefabValues(ContentItem.class, item1, item2);
final AttachmentList list1 = new AttachmentList();
list1.setName("list1");
final AttachmentList list2 = new AttachmentList();
list2.setName("list2");
verifier.withPrefabValues(AttachmentList.class, list1, list2);
final Journal journal1 = new Journal();
journal1.setTitle("Journal 1");
final Journal journal2 = new Journal();
journal2.setTitle("Journal 2");
verifier.withPrefabValues(Journal.class, journal1, journal2);
final ArticleInJournal article1 = new ArticleInJournal();
article1.getTitle().addValue(Locale.ENGLISH, "Article 1");
final ArticleInJournal article2 = new ArticleInJournal();
article2.getTitle().addValue(Locale.ENGLISH, "Article 2");
verifier.withPrefabValues(ArticleInJournal.class, article1, article2);
}
}

View File

@ -3,27 +3,15 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.scientificcms.publications.assets;
package org.scientificcms.publications.contenttypes;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.libreccm.categorization.Category;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.security.SecurityEntitiesPrefabProvider;
import org.libreccm.tests.categories.UnitTest;
import org.libreccm.testutils.EqualsVerifier;
import org.libreccm.workflow.Workflow;
import org.librecms.assets.Organization;
import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentSection;
import org.librecms.contentsection.ContentType;
import org.librecms.contentsection.ItemAttachment;
import org.librecms.lifecycle.Lifecycle;
import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
/**
*
@ -37,8 +25,17 @@ public class EqualsAndHashCodeTest extends EqualsVerifier {
public static Collection<Class<?>> data() {
return Arrays.asList(new Class<?>[]{
JournalAsset.class,
PublisherAsset.class
ArticleInCollectedVolumeItem.class,
ArticleInJournalItem.class,
CollectedVolumeItem.class,
ExpertiseItem.class,
GreyLiteratureItem.class,
InProceedingsItem.class,
InternetArticleItem.class,
MonographItem.class,
ProceedingsItem.class,
TalkItem.class,
WorkingPaperItem.class
});
}