Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/braincident/jabref into r…
Browse files Browse the repository at this point in the history
…isimporter

* 'master' of https://github.com/braincident/jabref:
  Update RisImporterTest.java
  Update RisImporterTest.java
  Create RisImporterTest.java
  Update CHANGELOG.md
  Update RisImporter.java
  Update EditAction.java
  Update CHANGELOG.md
  Update EditAction.java
  • Loading branch information
Siedlerchr committed Jun 6, 2020
2 parents 7cc5747 + 953e028 commit 9faf500
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Added

- We added support for importing ris file and load DOI [#6530](https://github.com/JabRef/jabref/issues/6530)
- We added the Library properties to a context menu on the library tabs [#6485](https://github.com/JabRef/jabref/issues/6485)
- We added a new field in the preferences in 'BibTeX key generator' for unwanted characters that can be user-specified. [#6295](https://github.com/JabRef/jabref/issues/6295)
- We added support for searching ShortScience for an entry through the user's browser. [#6018](https://github.com/JabRef/jabref/pull/6018)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,13 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
return new ParserResult(bibitems);
}

private void addDoi(Map<Field, String> hm, String val) {
String doi = val.toLowerCase(Locale.ENGLISH);
if (doi.startsWith("doi:")) {
doi = doi.replaceAll("(?i)doi:", "").trim();
hm.put(StandardField.DOI, doi);
}
private void addDoi(Map<Field, String> hm, String val) {
String doi = val.toLowerCase(Locale.ENGLISH);
if (doi.startsWith("doi:")) {
doi = doi.replaceAll("(?i)doi:", "").trim();
hm.put(StandardField.DOI, doi);
} else {
hm.put(StandardField.DOI, doi);
}
}
}
51 changes: 51 additions & 0 deletions src/test/java/org/jabref/logic/importer/RisImporterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.jabref.logic.importer;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import org.jabref.logic.importer.fileformat.RisImporter;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.StandardField;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class RisImporterTest {
RisImporter ri = null;

@BeforeEach
public void setUp() throws Exception {
ri = new RisImporter();
}

@Test
public void testAddDoi1() throws Exception {
String testDoi = "10.1589/jpts.28.186";
String doi = testDoi.toLowerCase(Locale.ENGLISH);
Map<Field, String> fields = new HashMap<>();
Method testAddDoiMethod = ri.getClass().getDeclaredMethod("addDoi", Map.class, String.class);
testAddDoiMethod.setAccessible(true);

testAddDoiMethod.invoke(ri, fields, doi);
assertNotNull(fields.get(StandardField.DOI));
assertEquals("10.1589/jpts.28.186", fields.get(StandardField.DOI));
}

@Test
public void testAddDoi2() throws Exception {
String testDoi = "doi:10.1589/jpts.28.186";
String doi = testDoi.toLowerCase(Locale.ENGLISH);
Map<Field, String> fields = new HashMap<>();
Method testAddDoiMethod = ri.getClass().getDeclaredMethod("addDoi", Map.class, String.class);
testAddDoiMethod.setAccessible(true);

testAddDoiMethod.invoke(ri, fields, doi);
assertNotNull(fields.get(StandardField.DOI));
assertEquals("10.1589/jpts.28.186", fields.get(StandardField.DOI));
}
}

0 comments on commit 9faf500

Please sign in to comment.