diff --git a/src/main/java/org/jabref/logic/importer/fileformat/BiblioscapeImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/BiblioscapeImporter.java index 99e0e0a6ab1..f1a847bf5a0 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/BiblioscapeImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/BiblioscapeImporter.java @@ -13,6 +13,7 @@ import org.jabref.logic.importer.ParserResult; import org.jabref.logic.util.StandardFileType; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; /** @@ -255,7 +256,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { if (!comments.isEmpty()) { // set comment if present hm.put(FieldName.COMMENT, String.join(";", comments)); } - BibEntry b = new BibEntry(bibtexType); + BibEntry b = new BibEntry(BibtexEntryTypes.getTypeOrDefault(bibtexType)); b.setField(hm); bibItems.add(b); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java index 16093dca0b3..06accaed956 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java @@ -29,6 +29,7 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.database.KeyCollisionException; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.BibtexString; import org.jabref.model.entry.CustomEntryType; import org.jabref.model.entry.EntryType; @@ -504,7 +505,8 @@ private String parsePreamble() throws IOException { } private BibEntry parseEntry(String entryType) throws IOException { - BibEntry result = new BibEntry(entryType); + BibEntry result = new BibEntry(BibtexEntryTypes.getTypeOrDefault(entryType)); + skipWhitespace(); consume('{', '('); int character = peek(); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/CopacImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/CopacImporter.java index 5ed722b8bb2..a3c09f6ae2f 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/CopacImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/CopacImporter.java @@ -11,6 +11,7 @@ import org.jabref.logic.importer.ParserResult; import org.jabref.logic.util.StandardFileType; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; /** @@ -98,7 +99,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { // Copac does not contain enough information on the type of the // document. A book is assumed. - BibEntry b = new BibEntry("book"); + BibEntry b = new BibEntry(BibtexEntryTypes.BOOK); String[] lines = entry.split("\n"); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/EndnoteImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/EndnoteImporter.java index 2f51300d43d..119f947d3ec 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/EndnoteImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/EndnoteImporter.java @@ -15,6 +15,7 @@ import org.jabref.logic.util.StandardFileType; import org.jabref.model.entry.AuthorList; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; /** @@ -253,7 +254,7 @@ else if ("P".equals(prefix)) { hm.put(FieldName.PAGES, artnum); } - BibEntry b = new BibEntry(type); + BibEntry b = new BibEntry(BibtexEntryTypes.getTypeOrDefault(type)); b.setField(hm); if (!b.getFieldNames().isEmpty()) { bibitems.add(b); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/GvkParser.java b/src/main/java/org/jabref/logic/importer/fileformat/GvkParser.java index a13fed8d53d..99b01ba20e7 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/GvkParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/GvkParser.java @@ -12,6 +12,7 @@ import org.jabref.logic.importer.ParseException; import org.jabref.logic.importer.Parser; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; import com.google.common.base.Strings; @@ -360,7 +361,7 @@ private BibEntry parseEntry(Element e) { * dann @incollection annehmen, wenn weder ISBN noch * ZDB-ID vorhanden sind. */ - BibEntry result = new BibEntry(entryType); + BibEntry result = new BibEntry(BibtexEntryTypes.getTypeOrDefault(entryType)); // Zuordnung der Felder in Abhängigkeit vom Dokumenttyp if (author != null) { diff --git a/src/main/java/org/jabref/logic/importer/fileformat/InspecImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/InspecImporter.java index 1b47f8bde40..36009366535 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/InspecImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/InspecImporter.java @@ -13,6 +13,7 @@ import org.jabref.logic.util.StandardFileType; import org.jabref.model.entry.AuthorList; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; /** @@ -120,7 +121,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } } } - BibEntry b = new BibEntry(type); + BibEntry b = new BibEntry(BibtexEntryTypes.getTypeOrDefault(type)); b.setField(h); bibitems.add(b); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java index db686fcd1a3..1db5b39feeb 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/IsiImporter.java @@ -17,6 +17,7 @@ import org.jabref.logic.importer.ParserResult; import org.jabref.logic.util.StandardFileType; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; import org.jabref.model.entry.Month; @@ -301,7 +302,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { continue; } - BibEntry b = new BibEntry(Type); + BibEntry b = new BibEntry(BibtexEntryTypes.getTypeOrDefault(Type)); // id assumes an existing database so don't // Remove empty fields: diff --git a/src/main/java/org/jabref/logic/importer/fileformat/MedlineImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/MedlineImporter.java index 8adf2a0a142..934219824cd 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/MedlineImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/MedlineImporter.java @@ -74,6 +74,7 @@ import org.jabref.logic.importer.fileformat.medline.Text; import org.jabref.logic.util.StandardFileType; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; import org.jabref.model.strings.StringUtil; @@ -262,7 +263,7 @@ private void parseBookArticle(PubmedBookArticle currentArticle, List b putIfValueNotNull(fields, "pubstatus", bookData.getPublicationStatus()); } - BibEntry entry = new BibEntry("article"); + BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE); entry.setField(fields); bibItems.add(entry); @@ -410,7 +411,7 @@ private void parseArticle(PubmedArticle article, List bibItems) { } } - BibEntry entry = new BibEntry("article"); + BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE); entry.setField(fields); bibItems.add(entry); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/MedlinePlainImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/MedlinePlainImporter.java index dcaf590cbfe..1389c15d40e 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/MedlinePlainImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/MedlinePlainImporter.java @@ -16,6 +16,7 @@ import org.jabref.logic.util.StandardFileType; import org.jabref.model.entry.AuthorList; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; /** @@ -208,7 +209,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { fields.put(FieldName.COMMENT, comment); } - BibEntry b = new BibEntry(type); + BibEntry b = new BibEntry(BibtexEntryTypes.getTypeOrDefault(type)); // Remove empty fields: fields.entrySet().stream().filter(n -> n.getValue().trim().isEmpty()).forEach(fields::remove); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/OvidImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/OvidImporter.java index 26ec3309987..23107e695cf 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/OvidImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/OvidImporter.java @@ -14,6 +14,7 @@ import org.jabref.logic.util.StandardFileType; import org.jabref.model.entry.AuthorList; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; /** @@ -207,7 +208,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { // Move the "chaptertitle" to just "title": h.put(FieldName.TITLE, h.remove("chaptertitle")); } - BibEntry b = new BibEntry(entryType); + BibEntry b = new BibEntry(BibtexEntryTypes.getTypeOrDefault(entryType)); b.setField(h); bibitems.add(b); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/RisImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/RisImporter.java index 116e08e5539..d778dd3d357 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/RisImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/RisImporter.java @@ -16,6 +16,7 @@ import org.jabref.logic.util.StandardFileType; import org.jabref.model.entry.AuthorList; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; import org.jabref.model.entry.Month; @@ -265,7 +266,7 @@ else if ("AV".equals(tag)) { // create one here // type is set in the loop above - BibEntry entry = new BibEntry(type); + BibEntry entry = new BibEntry(BibtexEntryTypes.getTypeOrDefault(type)); entry.setField(fields); // month has a special treatment as we use the separate method "setMonth" of BibEntry instead of directly setting the value month.ifPresent(entry::setMonth); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/SilverPlatterImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/SilverPlatterImporter.java index e3cea08b106..1b1d0f96559 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/SilverPlatterImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/SilverPlatterImporter.java @@ -14,6 +14,7 @@ import org.jabref.logic.util.StandardFileType; import org.jabref.model.entry.AuthorList; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; /** @@ -180,7 +181,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { } - BibEntry b = new BibEntry(type); + BibEntry b = new BibEntry(BibtexEntryTypes.getTypeOrDefault(type)); // create one here b.setField(h); diff --git a/src/main/java/org/jabref/logic/msbib/BibTeXConverter.java b/src/main/java/org/jabref/logic/msbib/BibTeXConverter.java index 42b36413a82..a95721fedd7 100644 --- a/src/main/java/org/jabref/logic/msbib/BibTeXConverter.java +++ b/src/main/java/org/jabref/logic/msbib/BibTeXConverter.java @@ -9,6 +9,7 @@ import java.util.stream.Collectors; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; import org.jabref.model.entry.Month; @@ -29,7 +30,7 @@ public static BibEntry convert(MSBibEntry entry) { Map fieldValues = new HashMap<>(); String bibTexEntryType = MSBibMapping.getBiblatexEntryType(entry.getType()); - result = new BibEntry(bibTexEntryType); + result = new BibEntry(BibtexEntryTypes.getTypeOrDefault(bibTexEntryType)); // add String fields for (Map.Entry field : entry.fields.entrySet()) { diff --git a/src/main/java/org/jabref/logic/util/TestEntry.java b/src/main/java/org/jabref/logic/util/TestEntry.java index 8d2b3920b87..6c98136c848 100644 --- a/src/main/java/org/jabref/logic/util/TestEntry.java +++ b/src/main/java/org/jabref/logic/util/TestEntry.java @@ -1,6 +1,7 @@ package org.jabref.logic.util; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; public class TestEntry { @@ -10,7 +11,7 @@ private TestEntry() { public static BibEntry getTestEntry() { - BibEntry entry = new BibEntry("article"); + BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE); entry.setCiteKey("Smith2016"); entry.setField(FieldName.AUTHOR, "Smith, Bill and Jones, Bob and Williams, Jeff"); entry.setField(FieldName.EDITOR, "Taylor, Phil"); diff --git a/src/main/java/org/jabref/model/entry/BibEntry.java b/src/main/java/org/jabref/model/entry/BibEntry.java index 370b3d655df..5a59a45fc6c 100644 --- a/src/main/java/org/jabref/model/entry/BibEntry.java +++ b/src/main/java/org/jabref/model/entry/BibEntry.java @@ -111,7 +111,7 @@ private BibEntry(String id, String type) { * Constructs a new BibEntry. The internal ID is set to IdGenerator.next() */ public BibEntry(EntryType type) { - this(type.getName()); + this(IdGenerator.next(),type.getName()); } public Optional setMonth(Month parsedMonth) { @@ -544,7 +544,7 @@ private boolean atLeastOnePresent(String[] fieldsToCheck, BibDatabase database) */ @Override public Object clone() { - BibEntry clone = new BibEntry(type.getValue()); + BibEntry clone = new BibEntry(IdGenerator.next(),type.getValue()); clone.fields = FXCollections.observableMap(new ConcurrentHashMap<>(fields)); return clone; } diff --git a/src/main/java/org/jabref/model/entry/BibtexEntryTypes.java b/src/main/java/org/jabref/model/entry/BibtexEntryTypes.java index 352411976e5..04909d1b954 100644 --- a/src/main/java/org/jabref/model/entry/BibtexEntryTypes.java +++ b/src/main/java/org/jabref/model/entry/BibtexEntryTypes.java @@ -287,4 +287,8 @@ private BibtexEntryTypes() { public static Optional getType(String name) { return ALL.stream().filter(e -> e.getName().equalsIgnoreCase(name)).findFirst(); } + + public static EntryType getTypeOrDefault(String name) { + return getType(name).orElseGet(() -> new CustomEntryType(name, "required", "optional")); + } } diff --git a/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java b/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java index e25495e99f2..ae1b46fe557 100644 --- a/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java +++ b/src/test/java/org/jabref/gui/externalfiles/AutoSetFileLinksUtilTest.java @@ -10,6 +10,7 @@ import org.jabref.logic.util.io.AutoLinkPreferences; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.LinkedFile; import org.jabref.model.metadata.FilePreferences; @@ -30,7 +31,7 @@ public class AutoSetFileLinksUtilTest { private final AutoLinkPreferences autoLinkPrefs = new AutoLinkPreferences(false, "", true, ';'); private final BibDatabaseContext databaseContext = mock(BibDatabaseContext.class); private final ExternalFileTypes externalFileTypes = mock(ExternalFileTypes.class); - private final BibEntry entry = new BibEntry("article"); + private final BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE); @BeforeEach public void setUp(@TempDirectory.TempDir Path folder) throws Exception { diff --git a/src/test/java/org/jabref/logic/TypedBibEntryTest.java b/src/test/java/org/jabref/logic/TypedBibEntryTest.java index 8b72810ecc9..9415bdcd28c 100644 --- a/src/test/java/org/jabref/logic/TypedBibEntryTest.java +++ b/src/test/java/org/jabref/logic/TypedBibEntryTest.java @@ -3,6 +3,7 @@ import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibtexEntryTypes; +import org.jabref.model.entry.CustomEntryType; import org.junit.jupiter.api.Test; @@ -14,7 +15,7 @@ public class TypedBibEntryTest { @Test public void hasAllRequiredFieldsFail() { - BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE); e.setField("author", "abc"); e.setField("title", "abc"); e.setField("journal", "abc"); @@ -25,7 +26,7 @@ public void hasAllRequiredFieldsFail() { @Test public void hasAllRequiredFields() { - BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE); e.setField("author", "abc"); e.setField("title", "abc"); e.setField("journal", "abc"); @@ -37,7 +38,7 @@ public void hasAllRequiredFields() { @Test public void hasAllRequiredFieldsForUnknownTypeReturnsTrue() { - BibEntry e = new BibEntry("articlllleeeee"); + BibEntry e = new BibEntry(new CustomEntryType("articlllleeeee","required","optional")); TypedBibEntry typedEntry = new TypedBibEntry(e, BibDatabaseMode.BIBTEX); assertTrue(typedEntry.hasAllRequiredFields()); @@ -45,7 +46,7 @@ public void hasAllRequiredFieldsForUnknownTypeReturnsTrue() { @Test public void getTypeForDisplayReturnsTypeName() { - BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS); TypedBibEntry typedEntry = new TypedBibEntry(e, BibDatabaseMode.BIBTEX); assertEquals("InProceedings", typedEntry.getTypeForDisplay()); @@ -53,7 +54,7 @@ public void getTypeForDisplayReturnsTypeName() { @Test public void getTypeForDisplayForUnknownTypeCapitalizeFirstLetter() { - BibEntry e = new BibEntry("articlllleeeee"); + BibEntry e = new BibEntry(new CustomEntryType("articlllleeeee","required","optional")); TypedBibEntry typedEntry = new TypedBibEntry(e, BibDatabaseMode.BIBTEX); assertEquals("Articlllleeeee", typedEntry.getTypeForDisplay()); diff --git a/src/test/java/org/jabref/logic/bibtex/BibEntryWriterTest.java b/src/test/java/org/jabref/logic/bibtex/BibEntryWriterTest.java index a340fdc7b59..e7e9808bc8a 100644 --- a/src/test/java/org/jabref/logic/bibtex/BibEntryWriterTest.java +++ b/src/test/java/org/jabref/logic/bibtex/BibEntryWriterTest.java @@ -13,6 +13,7 @@ import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BiblatexEntryTypes; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.LinkedFile; import org.jabref.model.util.DummyFileUpdateMonitor; import org.jabref.model.util.FileUpdateMonitor; @@ -43,7 +44,7 @@ public void setUpWriter() { public void testSerialization() throws IOException { StringWriter stringWriter = new StringWriter(); - BibEntry entry = new BibEntry("article"); + BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE); //set a required field entry.setField("author", "Foo Bar"); entry.setField("journal", "International Journal of Something"); @@ -405,7 +406,7 @@ public void addFieldWithLongerLength() throws IOException { public void doNotWriteEmptyFields() throws IOException { StringWriter stringWriter = new StringWriter(); - BibEntry entry = new BibEntry("article"); + BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE); entry.setField("author", " "); entry.setField("note", "some note"); @@ -424,7 +425,7 @@ public void doNotWriteEmptyFields() throws IOException { public void trimFieldContents() throws IOException { StringWriter stringWriter = new StringWriter(); - BibEntry entry = new BibEntry("article"); + BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE); entry.setField("note", " some note \t"); writer.write(entry, stringWriter, BibDatabaseMode.BIBTEX); @@ -442,7 +443,7 @@ public void trimFieldContents() throws IOException { public void writeThrowsErrorIfFieldContainsUnbalancedBraces() { StringWriter stringWriter = new StringWriter(); - BibEntry entry = new BibEntry("article"); + BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE); entry.setField("note", "some text with unbalanced { braces"); assertThrows(IOException.class, () -> writer.write(entry, stringWriter, BibDatabaseMode.BIBTEX)); diff --git a/src/test/java/org/jabref/logic/bibtex/DuplicateCheckTest.java b/src/test/java/org/jabref/logic/bibtex/DuplicateCheckTest.java index ace796173fe..7f3dbfcdd55 100644 --- a/src/test/java/org/jabref/logic/bibtex/DuplicateCheckTest.java +++ b/src/test/java/org/jabref/logic/bibtex/DuplicateCheckTest.java @@ -21,22 +21,22 @@ public class DuplicateCheckTest { @BeforeEach public void setUp() { - simpleArticle = new BibEntry(BibtexEntryTypes.ARTICLE.getName()) + simpleArticle = new BibEntry(BibtexEntryTypes.ARTICLE) .withField(FieldName.AUTHOR, "Single Author") .withField(FieldName.TITLE, "A serious paper about something") .withField(FieldName.YEAR, "2017"); - unrelatedArticle = new BibEntry(BibtexEntryTypes.ARTICLE.getName()) + unrelatedArticle = new BibEntry(BibtexEntryTypes.ARTICLE) .withField(FieldName.AUTHOR, "Completely Different") .withField(FieldName.TITLE, "Holy Moly Uffdada und Trallalla") .withField(FieldName.YEAR, "1992"); - simpleInbook = new BibEntry(BibtexEntryTypes.INBOOK.getName()) + simpleInbook = new BibEntry(BibtexEntryTypes.INBOOK) .withField(FieldName.TITLE, "Alice in Wonderland") .withField(FieldName.AUTHOR, "Charles Lutwidge Dodgson") .withField(FieldName.CHAPTER, "Chapter One – Down the Rabbit Hole") .withField(FieldName.LANGUAGE, "English") .withField(FieldName.PUBLISHER, "Macmillan") .withField(FieldName.YEAR, "1865"); - simpleIncollection = new BibEntry(BibtexEntryTypes.INCOLLECTION.getName()) + simpleIncollection = new BibEntry(BibtexEntryTypes.INCOLLECTION) .withField(FieldName.TITLE, "Innovation and Intellectual Property Rights") .withField(FieldName.AUTHOR, "Ove Grandstrand") .withField(FieldName.BOOKTITLE, "The Oxford Handbook of Innovation") @@ -46,9 +46,9 @@ public void setUp() { @Test public void testDuplicateDetection() { - BibEntry one = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry one = new BibEntry(BibtexEntryTypes.ARTICLE); - BibEntry two = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry two = new BibEntry(BibtexEntryTypes.ARTICLE); one.setField("author", "Billy Bob"); two.setField("author", "Billy Bob"); @@ -204,14 +204,14 @@ public void inbookWithoutChapterCouldBeDuplicateOfInbookWithChapter() { @Test public void twoBooksWithDifferentEditionsAreNotDuplicates() { - BibEntry editionOne = new BibEntry(BibtexEntryTypes.BOOK.getName()); + BibEntry editionOne = new BibEntry(BibtexEntryTypes.BOOK); editionOne.setField(FieldName.TITLE, "Effective Java"); editionOne.setField(FieldName.AUTHOR, "Bloch, Joshua"); editionOne.setField(FieldName.PUBLISHER, "Prentice Hall"); editionOne.setField(FieldName.DATE, "2001"); editionOne.setField(FieldName.EDITION, "1"); - BibEntry editionTwo = new BibEntry(BibtexEntryTypes.BOOK.getName()); + BibEntry editionTwo = new BibEntry(BibtexEntryTypes.BOOK); editionTwo.setField(FieldName.TITLE, "Effective Java"); editionTwo.setField(FieldName.AUTHOR, "Bloch, Joshua"); editionTwo.setField(FieldName.PUBLISHER, "Prentice Hall"); @@ -223,13 +223,13 @@ public void twoBooksWithDifferentEditionsAreNotDuplicates() { @Test public void sameBooksWithMissingEditionAreDuplicates() { - BibEntry editionOne = new BibEntry(BibtexEntryTypes.BOOK.getName()); + BibEntry editionOne = new BibEntry(BibtexEntryTypes.BOOK); editionOne.setField(FieldName.TITLE, "Effective Java"); editionOne.setField(FieldName.AUTHOR, "Bloch, Joshua"); editionOne.setField(FieldName.PUBLISHER, "Prentice Hall"); editionOne.setField(FieldName.DATE, "2001"); - BibEntry editionTwo = new BibEntry(BibtexEntryTypes.BOOK.getName()); + BibEntry editionTwo = new BibEntry(BibtexEntryTypes.BOOK); editionTwo.setField(FieldName.TITLE, "Effective Java"); editionTwo.setField(FieldName.AUTHOR, "Bloch, Joshua"); editionTwo.setField(FieldName.PUBLISHER, "Prentice Hall"); @@ -240,13 +240,13 @@ public void sameBooksWithMissingEditionAreDuplicates() { @Test public void sameBooksWithPartiallyMissingEditionAreDuplicates() { - BibEntry editionOne = new BibEntry(BibtexEntryTypes.BOOK.getName()); + BibEntry editionOne = new BibEntry(BibtexEntryTypes.BOOK); editionOne.setField(FieldName.TITLE, "Effective Java"); editionOne.setField(FieldName.AUTHOR, "Bloch, Joshua"); editionOne.setField(FieldName.PUBLISHER, "Prentice Hall"); editionOne.setField(FieldName.DATE, "2001"); - BibEntry editionTwo = new BibEntry(BibtexEntryTypes.BOOK.getName()); + BibEntry editionTwo = new BibEntry(BibtexEntryTypes.BOOK); editionTwo.setField(FieldName.TITLE, "Effective Java"); editionTwo.setField(FieldName.AUTHOR, "Bloch, Joshua"); editionTwo.setField(FieldName.PUBLISHER, "Prentice Hall"); @@ -258,7 +258,7 @@ public void sameBooksWithPartiallyMissingEditionAreDuplicates() { @Test public void sameBooksWithDifferentEditionsAreNotDuplicates() { - BibEntry editionTwo = new BibEntry(BibtexEntryTypes.BOOK.getName()); + BibEntry editionTwo = new BibEntry(BibtexEntryTypes.BOOK); editionTwo.setCiteKey("Sutton17reinfLrnIntroBook"); editionTwo.setField(FieldName.TITLE, "Reinforcement learning:An introduction"); editionTwo.setField(FieldName.PUBLISHER, "MIT Press"); @@ -269,7 +269,7 @@ public void sameBooksWithDifferentEditionsAreNotDuplicates() { editionTwo.setField(FieldName.JOURNAL, "MIT Press"); editionTwo.setField(FieldName.URL, "https://webdocs.cs.ualberta.ca/~sutton/book/the-book-2nd.html"); - BibEntry editionOne = new BibEntry(BibtexEntryTypes.BOOK.getName()); + BibEntry editionOne = new BibEntry(BibtexEntryTypes.BOOK); editionOne.setCiteKey("Sutton98reinfLrnIntroBook"); editionOne.setField(FieldName.TITLE, "Reinforcement learning: An introduction"); editionOne.setField(FieldName.PUBLISHER, "MIT press Cambridge"); diff --git a/src/test/java/org/jabref/logic/bibtex/comparator/FieldComparatorTest.java b/src/test/java/org/jabref/logic/bibtex/comparator/FieldComparatorTest.java index 80742aff2ab..02ee8ea0907 100644 --- a/src/test/java/org/jabref/logic/bibtex/comparator/FieldComparatorTest.java +++ b/src/test/java/org/jabref/logic/bibtex/comparator/FieldComparatorTest.java @@ -1,6 +1,7 @@ package org.jabref.logic.bibtex.comparator; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.junit.jupiter.api.Test; @@ -94,7 +95,7 @@ public void compareYearFieldBiggerDescending() throws Exception { @Test public void compareTypeFieldIdentity() throws Exception { FieldComparator comparator = new FieldComparator("entrytype"); - BibEntry equal = new BibEntry("article"); + BibEntry equal = new BibEntry(BibtexEntryTypes.ARTICLE); assertEquals(0, comparator.compare(equal, equal)); } @@ -102,9 +103,9 @@ public void compareTypeFieldIdentity() throws Exception { @Test public void compareTypeFieldEquality() throws Exception { FieldComparator comparator = new FieldComparator("entrytype"); - BibEntry equal = new BibEntry("article"); + BibEntry equal = new BibEntry(BibtexEntryTypes.ARTICLE); equal.setId("1"); - BibEntry equal2 = new BibEntry("article"); + BibEntry equal2 = new BibEntry(BibtexEntryTypes.ARTICLE); equal2.setId("1"); assertEquals(0, comparator.compare(equal, equal2)); @@ -113,8 +114,8 @@ public void compareTypeFieldEquality() throws Exception { @Test public void compareTypeFieldBiggerAscending() throws Exception { FieldComparator comparator = new FieldComparator("entrytype"); - BibEntry smaller = new BibEntry("article"); - BibEntry bigger = new BibEntry("book"); + BibEntry smaller = new BibEntry(BibtexEntryTypes.ARTICLE); + BibEntry bigger = new BibEntry(BibtexEntryTypes.BOOK); assertEquals(1, comparator.compare(bigger, smaller)); } @@ -122,8 +123,8 @@ public void compareTypeFieldBiggerAscending() throws Exception { @Test public void compareTypeFieldBiggerDescending() throws Exception { FieldComparator comparator = new FieldComparator("entrytype", true); - BibEntry bigger = new BibEntry("article"); - BibEntry smaller = new BibEntry("book"); + BibEntry bigger = new BibEntry(BibtexEntryTypes.ARTICLE); + BibEntry smaller = new BibEntry(BibtexEntryTypes.BOOK); assertEquals(1, comparator.compare(bigger, smaller)); } diff --git a/src/test/java/org/jabref/logic/cleanup/BibtexBiblatexRoundtripTest.java b/src/test/java/org/jabref/logic/cleanup/BibtexBiblatexRoundtripTest.java index 1a2e903673f..01da069febd 100644 --- a/src/test/java/org/jabref/logic/cleanup/BibtexBiblatexRoundtripTest.java +++ b/src/test/java/org/jabref/logic/cleanup/BibtexBiblatexRoundtripTest.java @@ -1,6 +1,7 @@ package org.jabref.logic.cleanup; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -13,7 +14,7 @@ class BibtexBiblatexRoundtripTest { @BeforeEach void setUp() { - bibtex = new BibEntry("article"); + bibtex = new BibEntry(BibtexEntryTypes.ARTICLE); bibtex.setField("author", "Frame, J. S. and Robinson, G. de B. and Thrall, R. M."); bibtex.setField("title", "The hook graphs of the symmetric groups"); bibtex.setField("journal", "Canadian J. Math."); @@ -26,7 +27,7 @@ void setUp() { bibtex.setField("mrnumber", "0062127"); bibtex.setField("mrreviewer", "D. E. Littlewood"); - biblatex = new BibEntry("article"); + biblatex = new BibEntry(BibtexEntryTypes.ARTICLE); biblatex.setField("author", "Frame, J. S. and Robinson, G. de B. and Thrall, R. M."); biblatex.setField("title", "The hook graphs of the symmetric groups"); biblatex.setField("journaltitle", "Canadian J. Math."); diff --git a/src/test/java/org/jabref/logic/importer/fetcher/ACMPortalFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/ACMPortalFetcherTest.java index df85c30857f..8ab746da3d2 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/ACMPortalFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/ACMPortalFetcherTest.java @@ -29,7 +29,7 @@ void setUp() { @Test void searchByQueryFindsEntry() throws Exception { - BibEntry expected = new BibEntry(BibtexEntryTypes.INPROCEEDINGS.getName()); + BibEntry expected = new BibEntry(BibtexEntryTypes.INPROCEEDINGS); expected.setCiteKey("Olsson:2017:RCC:3129790.3129810"); expected.setField("acmid", "3129810"); expected.setField("address", "New York, NY, USA"); diff --git a/src/test/java/org/jabref/logic/importer/fetcher/INSPIREFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/INSPIREFetcherTest.java index d919f96ce1d..fba34218798 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/INSPIREFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/INSPIREFetcherTest.java @@ -29,7 +29,7 @@ void setUp() { @Test void searchByQueryFindsEntry() throws Exception { - BibEntry expected = new BibEntry(BibtexEntryTypes.MASTERSTHESIS.getName()); + BibEntry expected = new BibEntry(BibtexEntryTypes.MASTERSTHESIS); expected.setCiteKey("Diez:2014ppa"); expected.setField("author", "Diez, Tobias"); expected.setField("title", "Slice theorem for Fr\\'echet group actions and covariant symplectic field theory"); diff --git a/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java b/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java index 866a5a39e57..98c3a8cc2f8 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/BibtexParserTest.java @@ -25,6 +25,7 @@ import org.jabref.model.cleanup.FieldFormatterCleanups; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.BibtexString; import org.jabref.model.entry.Date; import org.jabref.model.entry.EntryType; @@ -325,7 +326,7 @@ void parseRecognizesEntryWithAtInField() throws IOException { List parsed = result.getDatabase().getEntries(); - BibEntry expected = new BibEntry("article").withField(BibEntry.KEY_FIELD, "test") + BibEntry expected = new BibEntry(BibtexEntryTypes.ARTICLE).withField(BibEntry.KEY_FIELD, "test") .withField("author", "Ed von T@st"); assertEquals(Collections.singletonList(expected), parsed); @@ -336,7 +337,7 @@ void parseRecognizesEntryPrecedingComment() throws IOException { String comment = "@Comment{@article{myarticle,}" + OS.NEWLINE + "@inproceedings{blabla, title={the proceedings of bl@bl@}; }" + OS.NEWLINE + "}"; String entryWithComment = comment + OS.NEWLINE + "@article{test,author={Ed von T@st}}"; - BibEntry expected = new BibEntry("article") + BibEntry expected = new BibEntry(BibtexEntryTypes.ARTICLE) .withField(BibEntry.KEY_FIELD, "test") .withField("author", "Ed von T@st"); expected.setCommentsBeforeEntry(comment); diff --git a/src/test/java/org/jabref/logic/layout/LayoutTest.java b/src/test/java/org/jabref/logic/layout/LayoutTest.java index 34c8ae2418f..1e737784520 100644 --- a/src/test/java/org/jabref/logic/layout/LayoutTest.java +++ b/src/test/java/org/jabref/logic/layout/LayoutTest.java @@ -8,6 +8,7 @@ import org.jabref.logic.layout.format.FileLinkPreferences; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibtexEntryTypes; +import org.jabref.model.entry.CustomEntryType; import org.jabref.model.entry.LinkedFile; import org.junit.jupiter.api.BeforeEach; @@ -37,7 +38,7 @@ private String layout(String layout, BibEntry entry) throws IOException { @Test void entryTypeForUnknown() throws IOException { - BibEntry entry = new BibEntry("unknown").withField("author", "test"); + BibEntry entry = new BibEntry(new CustomEntryType("unknown","required","optional")).withField("author", "test"); assertEquals("Unknown", layout("\\bibtextype", entry)); } diff --git a/src/test/java/org/jabref/logic/pdf/EntryAnnotationImporterTest.java b/src/test/java/org/jabref/logic/pdf/EntryAnnotationImporterTest.java index 1a94f42a49a..0ad5b9bca30 100644 --- a/src/test/java/org/jabref/logic/pdf/EntryAnnotationImporterTest.java +++ b/src/test/java/org/jabref/logic/pdf/EntryAnnotationImporterTest.java @@ -8,6 +8,7 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.CustomEntryType; import org.jabref.model.entry.FieldName; import org.jabref.model.metadata.FilePreferences; import org.jabref.model.pdf.FileAnnotation; @@ -23,7 +24,7 @@ public class EntryAnnotationImporterTest { private final BibDatabaseContext databaseContext = mock(BibDatabaseContext.class); - private final BibEntry entry = new BibEntry("EntryKey"); + private final BibEntry entry = new BibEntry(new CustomEntryType("EntryKey","required","optional")); @BeforeEach public void setUp() { diff --git a/src/test/java/org/jabref/logic/search/SearchQueryTest.java b/src/test/java/org/jabref/logic/search/SearchQueryTest.java index 2718943d6a6..e4463f75155 100644 --- a/src/test/java/org/jabref/logic/search/SearchQueryTest.java +++ b/src/test/java/org/jabref/logic/search/SearchQueryTest.java @@ -58,7 +58,7 @@ public void testGrammarSearchFullEntry() { @Test public void testSearchingForOpenBraketInBooktitle() { - BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS); e.setField(FieldName.BOOKTITLE, "Super Conference (SC)"); SearchQuery searchQuery = new SearchQuery("booktitle=\"(\"", false, false); @@ -67,7 +67,7 @@ public void testSearchingForOpenBraketInBooktitle() { @Test public void testSearchMatchesSingleKeywordNotPart() { - BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS); e.setField("keywords", "banana, pineapple, orange"); SearchQuery searchQuery = new SearchQuery("anykeyword==apple", false, false); @@ -76,7 +76,7 @@ public void testSearchMatchesSingleKeywordNotPart() { @Test public void testSearchMatchesSingleKeyword() { - BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS); e.setField("keywords", "banana, pineapple, orange"); SearchQuery searchQuery = new SearchQuery("anykeyword==pineapple", false, false); @@ -85,7 +85,7 @@ public void testSearchMatchesSingleKeyword() { @Test public void testSearchAllFields() { - BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS); e.setField("title", "Fruity features"); e.setField("keywords", "banana, pineapple, orange"); @@ -95,7 +95,7 @@ public void testSearchAllFields() { @Test public void testSearchAllFieldsNotForSpecificField() { - BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS); e.setField("title", "Fruity features"); e.setField("keywords", "banana, pineapple, orange"); @@ -105,7 +105,7 @@ public void testSearchAllFieldsNotForSpecificField() { @Test public void testSearchAllFieldsAndSpecificField() { - BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS); e.setField("title", "Fruity features"); e.setField("keywords", "banana, pineapple, orange"); diff --git a/src/test/java/org/jabref/logic/util/io/CiteKeyBasedFileFinderTest.java b/src/test/java/org/jabref/logic/util/io/CiteKeyBasedFileFinderTest.java index 0629afe3a97..70c8ea51941 100644 --- a/src/test/java/org/jabref/logic/util/io/CiteKeyBasedFileFinderTest.java +++ b/src/test/java/org/jabref/logic/util/io/CiteKeyBasedFileFinderTest.java @@ -29,7 +29,7 @@ class CiteKeyBasedFileFinderTest { @BeforeEach void setUp(@TempDirectory.TempDir Path temporaryFolder) throws IOException { - entry = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + entry = new BibEntry(BibtexEntryTypes.ARTICLE); entry.setCiteKey("HipKro03"); rootDir = temporaryFolder; diff --git a/src/test/java/org/jabref/logic/util/io/RegExpBasedFileFinderTests.java b/src/test/java/org/jabref/logic/util/io/RegExpBasedFileFinderTests.java index d024017ff34..4e5edbc0322 100644 --- a/src/test/java/org/jabref/logic/util/io/RegExpBasedFileFinderTests.java +++ b/src/test/java/org/jabref/logic/util/io/RegExpBasedFileFinderTests.java @@ -46,7 +46,7 @@ public void setUp() { @Test public void testFindFiles() throws Exception { //given - BibEntry localEntry = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry localEntry = new BibEntry(BibtexEntryTypes.ARTICLE); localEntry.setCiteKey("pdfInDatabase"); localEntry.setField("year", "2001"); @@ -82,7 +82,7 @@ public void testYearAuthFirspageFindFiles() throws Exception { @Test public void testAuthorWithDiacritics() throws Exception { //given - BibEntry localEntry = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry localEntry = new BibEntry(BibtexEntryTypes.ARTICLE); localEntry.setCiteKey("Grazulis2017"); localEntry.setField("year", "2017"); localEntry.setField("author", "Gražulis, Saulius and O. Kitsune"); @@ -104,7 +104,7 @@ public void testAuthorWithDiacritics() throws Exception { @Test public void testFindFileInSubdirectory() throws Exception { //given - BibEntry localEntry = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry localEntry = new BibEntry(BibtexEntryTypes.ARTICLE); localEntry.setCiteKey("pdfInSubdirectory"); localEntry.setField("year", "2017"); @@ -124,7 +124,7 @@ public void testFindFileInSubdirectory() throws Exception { @Test public void testFindFileNonRecursive() throws Exception { //given - BibEntry localEntry = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry localEntry = new BibEntry(BibtexEntryTypes.ARTICLE); localEntry.setCiteKey("pdfInSubdirectory"); localEntry.setField("year", "2017"); diff --git a/src/test/java/org/jabref/model/BibDatabaseContextTest.java b/src/test/java/org/jabref/model/BibDatabaseContextTest.java index 701833e223d..42fc88abab6 100644 --- a/src/test/java/org/jabref/model/BibDatabaseContextTest.java +++ b/src/test/java/org/jabref/model/BibDatabaseContextTest.java @@ -4,6 +4,7 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.BibDatabaseMode; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.IEEETranEntryTypes; import org.jabref.model.metadata.MetaData; import org.junit.jupiter.api.Test; @@ -42,7 +43,7 @@ public void testTypeBasedOnInferredModeBibTeX() { @Test public void testTypeBasedOnInferredModeBiblatex() { BibDatabase db = new BibDatabase(); - BibEntry e1 = new BibEntry("electronic"); + BibEntry e1 = new BibEntry(IEEETranEntryTypes.ELECTRONIC); db.insertEntry(e1); BibDatabaseContext bibDatabaseContext = new BibDatabaseContext(db); diff --git a/src/test/java/org/jabref/model/database/BibDatabaseModeDetectionTest.java b/src/test/java/org/jabref/model/database/BibDatabaseModeDetectionTest.java index 3902da07a58..5a82943b0e0 100644 --- a/src/test/java/org/jabref/model/database/BibDatabaseModeDetectionTest.java +++ b/src/test/java/org/jabref/model/database/BibDatabaseModeDetectionTest.java @@ -16,14 +16,14 @@ public class BibDatabaseModeDetectionTest { @Test public void detectBiblatex() { - Collection entries = Arrays.asList(new BibEntry(BiblatexEntryTypes.MVBOOK.getName())); + Collection entries = Arrays.asList(new BibEntry(BiblatexEntryTypes.MVBOOK)); assertEquals(BibDatabaseMode.BIBLATEX, BibDatabaseModeDetection.inferMode(BibDatabases.createDatabase(entries))); } @Test public void detectUndistinguishableAsBibtex() { - BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry entry = new BibEntry(BibtexEntryTypes.ARTICLE); entry.setField("title", "My cool paper"); Collection entries = Arrays.asList(entry); @@ -32,9 +32,9 @@ public void detectUndistinguishableAsBibtex() { @Test public void detectMixedModeAsBiblatex() { - BibEntry bibtex = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry bibtex = new BibEntry(BibtexEntryTypes.ARTICLE); bibtex.setField("journal", "IEEE Trans. Services Computing"); - BibEntry biblatex = new BibEntry(BiblatexEntryTypes.ARTICLE.getName()); + BibEntry biblatex = new BibEntry(BiblatexEntryTypes.ARTICLE); biblatex.setField("translator", "Stefan Kolb"); Collection entries = Arrays.asList(bibtex, biblatex); @@ -43,7 +43,7 @@ public void detectMixedModeAsBiblatex() { @Test public void detectUnknownTypeAsBibtex() { - BibEntry entry = new BibEntry(new CustomEntryType("unknowntype", new ArrayList<>(0), new ArrayList<>(0)).getName()); + BibEntry entry = new BibEntry(new CustomEntryType("unknowntype", new ArrayList<>(0), new ArrayList<>(0))); Collection entries = Arrays.asList(entry); assertEquals(BibDatabaseMode.BIBTEX, BibDatabaseModeDetection.inferMode(BibDatabases.createDatabase(entries))); @@ -51,9 +51,9 @@ public void detectUnknownTypeAsBibtex() { @Test public void ignoreUnknownTypesForBibtexDecision() { - BibEntry custom = new BibEntry(new CustomEntryType("unknowntype", new ArrayList<>(0), new ArrayList<>(0)).getName()); - BibEntry bibtex = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); - BibEntry biblatex = new BibEntry(BiblatexEntryTypes.ARTICLE.getName()); + BibEntry custom = new BibEntry(new CustomEntryType("unknowntype", new ArrayList<>(0), new ArrayList<>(0))); + BibEntry bibtex = new BibEntry(BibtexEntryTypes.ARTICLE); + BibEntry biblatex = new BibEntry(BiblatexEntryTypes.ARTICLE); Collection entries = Arrays.asList(custom, bibtex, biblatex); assertEquals(BibDatabaseMode.BIBTEX, BibDatabaseModeDetection.inferMode(BibDatabases.createDatabase(entries))); @@ -61,9 +61,9 @@ public void ignoreUnknownTypesForBibtexDecision() { @Test public void ignoreUnknownTypesForBiblatexDecision() { - BibEntry custom = new BibEntry(new CustomEntryType("unknowntype", new ArrayList<>(0), new ArrayList<>(0)).getName()); - BibEntry bibtex = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); - BibEntry biblatex = new BibEntry(BiblatexEntryTypes.MVBOOK.getName()); + BibEntry custom = new BibEntry(new CustomEntryType("unknowntype", new ArrayList<>(0), new ArrayList<>(0))); + BibEntry bibtex = new BibEntry(BibtexEntryTypes.ARTICLE); + BibEntry biblatex = new BibEntry(BiblatexEntryTypes.MVBOOK); Collection entries = Arrays.asList(custom, bibtex, biblatex); assertEquals(BibDatabaseMode.BIBLATEX, BibDatabaseModeDetection.inferMode(BibDatabases.createDatabase(entries))); diff --git a/src/test/java/org/jabref/model/database/BibDatabaseTest.java b/src/test/java/org/jabref/model/database/BibDatabaseTest.java index 84fcbb426e7..8e3f3b89194 100644 --- a/src/test/java/org/jabref/model/database/BibDatabaseTest.java +++ b/src/test/java/org/jabref/model/database/BibDatabaseTest.java @@ -11,7 +11,10 @@ import java.util.Set; import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BiblatexEntryTypes; +import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.BibtexString; +import org.jabref.model.entry.CustomEntryType; import org.jabref.model.entry.IdGenerator; import org.jabref.model.event.TestEventListener; @@ -250,7 +253,7 @@ public void resolveForStringsOddHashMarkAtTheEnd() { @Test public void getUsedStrings() { - BibEntry entry = new BibEntry(IdGenerator.next()); + BibEntry entry = new BibEntry(new CustomEntryType(IdGenerator.next(),"required","optional")); entry.setField("author", "#AAA#"); BibtexString tripleA = new BibtexString("AAA", "Some other #BBB#"); BibtexString tripleB = new BibtexString("BBB", "Some more text"); @@ -298,9 +301,9 @@ public void getUsedStringsNoString() { @Test public void getEntriesSortedWithTwoEntries() { - BibEntry entryB = new BibEntry("article"); + BibEntry entryB = new BibEntry(BibtexEntryTypes.ARTICLE); entryB.setId("2"); - BibEntry entryA = new BibEntry("article"); + BibEntry entryA = new BibEntry(BiblatexEntryTypes.ARTICLE); entryB.setId("1"); database.insertEntries(entryB, entryA); assertEquals(Arrays.asList(entryA, entryB), database.getEntriesSorted(Comparator.comparing(BibEntry::getId))); diff --git a/src/test/java/org/jabref/model/entry/BibEntryTests.java b/src/test/java/org/jabref/model/entry/BibEntryTests.java index 2f39ddb131c..872ba189f65 100644 --- a/src/test/java/org/jabref/model/entry/BibEntryTests.java +++ b/src/test/java/org/jabref/model/entry/BibEntryTests.java @@ -49,7 +49,7 @@ public void testDefaultConstructor() { @Test public void allFieldsPresentDefault() { - BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE); e.setField("author", "abc"); e.setField("title", "abc"); e.setField("journal", "abc"); @@ -65,7 +65,7 @@ public void allFieldsPresentDefault() { @Test public void allFieldsPresentOr() { - BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE); e.setField("author", "abc"); e.setField("title", "abc"); e.setField("journal", "abc"); @@ -81,13 +81,13 @@ public void allFieldsPresentOr() { @Test public void isNullCiteKeyThrowsNPE() { - BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE); assertThrows(NullPointerException.class, () -> e.setCiteKey(null)); } @Test public void isEmptyCiteKey() { - BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE); assertFalse(e.hasCiteKey()); e.setCiteKey(""); diff --git a/src/test/java/org/jabref/model/entry/CanonicalBibEntryTest.java b/src/test/java/org/jabref/model/entry/CanonicalBibEntryTest.java index 8a3eb16d7c9..88fa45d2224 100644 --- a/src/test/java/org/jabref/model/entry/CanonicalBibEntryTest.java +++ b/src/test/java/org/jabref/model/entry/CanonicalBibEntryTest.java @@ -8,7 +8,7 @@ public class CanonicalBibEntryTest { @Test public void simpleCanonicalRepresentation() { - BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE); e.setCiteKey("key"); e.setField("author", "abc"); e.setField("title", "def"); @@ -20,7 +20,7 @@ public void simpleCanonicalRepresentation() { @Test public void canonicalRepresentationWithNewlines() { - BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE); e.setCiteKey("key"); e.setField("abstract", "line 1\nline 2"); String canonicalRepresentation = CanonicalBibtexEntry.getCanonicalRepresentation(e); diff --git a/src/test/java/org/jabref/model/search/rules/ContainBasedSearchRuleTest.java b/src/test/java/org/jabref/model/search/rules/ContainBasedSearchRuleTest.java index b60ec5ebc83..20948435422 100644 --- a/src/test/java/org/jabref/model/search/rules/ContainBasedSearchRuleTest.java +++ b/src/test/java/org/jabref/model/search/rules/ContainBasedSearchRuleTest.java @@ -43,7 +43,7 @@ public void testBasicSearchParsing() { } public BibEntry makeBibtexEntry() { - BibEntry e = new BibEntry(BibtexEntryTypes.INCOLLECTION.getName()); + BibEntry e = new BibEntry(BibtexEntryTypes.INCOLLECTION); e.setField("title", "Marine finfish larviculture in Europe"); e.setField("bibtexkey", "shields01"); e.setField("year", "2001");