Skip to content

Commit

Permalink
JabRef#8491 : Fix Test Failures
Browse files Browse the repository at this point in the history
  • Loading branch information
addak committed Feb 27, 2022
1 parent 204c557 commit 2494509
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import java.util.function.Consumer;
import java.util.function.Predicate;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.xmpbox.schema.DublinCoreSchema;
import org.apache.xmpbox.type.BadFieldValueException;

import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.entry.Author;
import org.jabref.model.entry.AuthorList;
Expand All @@ -26,8 +28,6 @@
import org.jabref.model.strings.StringUtil;
import org.jabref.logic.TypedBibEntry;

import org.apache.xmpbox.schema.DublinCoreSchema;
import org.apache.xmpbox.type.BadFieldValueException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -240,7 +240,7 @@ private void extractType() {
*/
private void extractCoverage() {
String coverage = dcSchema.getCoverage();
if (!StringUtils.isEmpty(coverage)) {
if (!StringUtil.isNullOrEmpty(coverage)) {
bibEntry.setField(FieldFactory.parseField(DC_COVERAGE), coverage);
}
}
Expand Down
25 changes: 13 additions & 12 deletions src/main/java/org/jabref/model/entry/Date.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ public class Date {
private static final DateTimeFormatter SIMPLE_DATE_FORMATS;
static {
List<String> formatStrings = Arrays.asList(
"uuuu-M-d", // covers 2009-1-15
"uuuu-M", // covers 2009-11
"d-M-uuuu", // covers 15-1-2012
"M-uuuu", // covers 1-2012
"M/uuuu", // covers 9/2015 and 09/2015
"M/uu", // covers 9/15
"MMMM d, uuuu", // covers September 1, 2015
"MMMM, uuuu", // covers September, 2015
"d.M.uuuu", // covers 15.1.2015
"uuuu.M.d", // covers 2015.1.15
"uuuu", // covers 2015
"MMM, uuuu"); // covers Jan, 2020
"uuuu-MM-dd'T'HH:mm:ss[xxx][xx][X]", // covers 2018-10-03T07:24:14+03:00
"uuuu-M-d", // covers 2009-1-15
"uuuu-M", // covers 2009-11
"d-M-uuuu", // covers 15-1-2012
"M-uuuu", // covers 1-2012
"M/uuuu", // covers 9/2015 and 09/2015
"M/uu", // covers 9/15
"MMMM d, uuuu", // covers September 1, 2015
"MMMM, uuuu", // covers September, 2015
"d.M.uuuu", // covers 15.1.2015
"uuuu.M.d", // covers 2015.1.15
"uuuu", // covers 2015
"MMM, uuuu"); // covers Jan, 2020

SIMPLE_DATE_FORMATS = formatStrings.stream()
.map(DateTimeFormatter::ofPattern)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public DublinCoreSchemaCustom(XMPMetadata metadata) {

public static DublinCoreSchemaCustom copyDublinCoreSchema(DublinCoreSchema dcSchema) {

if (Objects.isNull(dcSchema))
if (Objects.isNull(dcSchema)) {
return null;
}

DublinCoreSchemaCustom dublinCoreSchemaCustom = new DublinCoreSchemaCustom(dcSchema.getMetadata());

Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/jabref/logic/xmp/XmpUtilReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.jabref.logic.importer.fileformat.BibtexParser;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.schema.DublinCoreSchemaCustom;
import org.jabref.model.util.DummyFileUpdateMonitor;

import org.apache.xmpbox.XMPMetadata;
Expand Down Expand Up @@ -57,7 +58,7 @@ void testReadArticleDublinCoreReadRawXmp() throws IOException, URISyntaxExceptio
Path path = Path.of(XmpUtilShared.class.getResource("article_dublinCore.pdf").toURI());
List<XMPMetadata> meta = XmpUtilReader.readRawXmp(path);

DublinCoreSchema dcSchema = meta.get(0).getDublinCoreSchema();
DublinCoreSchema dcSchema = DublinCoreSchemaCustom.copyDublinCoreSchema(meta.get(0).getDublinCoreSchema());
DublinCoreExtractor dcExtractor = new DublinCoreExtractor(dcSchema, xmpPreferences, new BibEntry());
Optional<BibEntry> entry = dcExtractor.extractBibtexEntry();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ @Article{Olly2018
number = {1},
pages = {1-2},
month = mar,
day = {1},
issn = {978-123-123},
note = {That's a note},
abstract = {That's an abstract},
Expand Down

0 comments on commit 2494509

Please sign in to comment.