diff --git a/src/main/java/net/sf/jabref/gui/cleanup/CleanupPresetPanel.java b/src/main/java/net/sf/jabref/gui/cleanup/CleanupPresetPanel.java index 290b5207af7..76e46e8ff11 100644 --- a/src/main/java/net/sf/jabref/gui/cleanup/CleanupPresetPanel.java +++ b/src/main/java/net/sf/jabref/gui/cleanup/CleanupPresetPanel.java @@ -44,7 +44,7 @@ public CleanupPresetPanel(BibDatabaseContext databaseContext, CleanupPreset clea private void init() { cleanUpDOI = new JCheckBox( Localization.lang("Move DOIs from note and URL field to DOI field and remove http prefix")); - cleanUpISSN = new JCheckBox(Localization.lang("Add possibly missing dash to ISSN")); + cleanUpISSN = new JCheckBox(Localization.lang("Reformat ISSN")); if (databaseContext.getMetaData().getDefaultFileDirectory().isPresent()) { cleanUpMovePDF = new JCheckBox(Localization.lang("Move linked files to default file directory %0", databaseContext.getMetaData().getDefaultFileDirectory().get())); diff --git a/src/main/resources/l10n/JabRef_da.properties b/src/main/resources/l10n/JabRef_da.properties index bcf5a03187d..c0968fe93ed 100644 --- a/src/main/resources/l10n/JabRef_da.properties +++ b/src/main/resources/l10n/JabRef_da.properties @@ -1707,4 +1707,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_de.properties b/src/main/resources/l10n/JabRef_de.properties index e4a800be83f..20aa90213c0 100644 --- a/src/main/resources/l10n/JabRef_de.properties +++ b/src/main/resources/l10n/JabRef_de.properties @@ -2425,4 +2425,5 @@ Custom= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 9d17de855cf..cf7177aa897 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2273,4 +2273,4 @@ JabRef_is_up-to-date.=JabRef_is_up-to-date. Latest_version=Latest_version Online_help_forum=Online_help_forum Custom=Custom -Add_possibly_missing_dash_to_ISSN=Add_possibly_missing_dash_to_ISSN \ No newline at end of file +Reformat_ISSN=Reformat_ISSN diff --git a/src/main/resources/l10n/JabRef_es.properties b/src/main/resources/l10n/JabRef_es.properties index 9b74eff96b4..102ac32ea15 100644 --- a/src/main/resources/l10n/JabRef_es.properties +++ b/src/main/resources/l10n/JabRef_es.properties @@ -1609,4 +1609,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_fa.properties b/src/main/resources/l10n/JabRef_fa.properties index 1cbe13c01ba..f460c534ca9 100644 --- a/src/main/resources/l10n/JabRef_fa.properties +++ b/src/main/resources/l10n/JabRef_fa.properties @@ -2395,4 +2395,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_fr.properties b/src/main/resources/l10n/JabRef_fr.properties index 3e518a0dc19..ec70947db82 100644 --- a/src/main/resources/l10n/JabRef_fr.properties +++ b/src/main/resources/l10n/JabRef_fr.properties @@ -1653,4 +1653,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_in.properties b/src/main/resources/l10n/JabRef_in.properties index 46b839c841e..dedec654583 100644 --- a/src/main/resources/l10n/JabRef_in.properties +++ b/src/main/resources/l10n/JabRef_in.properties @@ -1628,4 +1628,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_it.properties b/src/main/resources/l10n/JabRef_it.properties index ce5c9d7db19..7c98d4ceede 100644 --- a/src/main/resources/l10n/JabRef_it.properties +++ b/src/main/resources/l10n/JabRef_it.properties @@ -1728,4 +1728,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_ja.properties b/src/main/resources/l10n/JabRef_ja.properties index 676ba98beec..0ad1eb53daa 100644 --- a/src/main/resources/l10n/JabRef_ja.properties +++ b/src/main/resources/l10n/JabRef_ja.properties @@ -2373,4 +2373,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_nl.properties b/src/main/resources/l10n/JabRef_nl.properties index da8c24628a4..943421df58d 100644 --- a/src/main/resources/l10n/JabRef_nl.properties +++ b/src/main/resources/l10n/JabRef_nl.properties @@ -2404,4 +2404,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_no.properties b/src/main/resources/l10n/JabRef_no.properties index 8b174fff776..3480f9222f3 100644 --- a/src/main/resources/l10n/JabRef_no.properties +++ b/src/main/resources/l10n/JabRef_no.properties @@ -2800,4 +2800,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_pt_BR.properties b/src/main/resources/l10n/JabRef_pt_BR.properties index 7edd37f1f41..9c9041365d4 100644 --- a/src/main/resources/l10n/JabRef_pt_BR.properties +++ b/src/main/resources/l10n/JabRef_pt_BR.properties @@ -1622,4 +1622,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_ru.properties b/src/main/resources/l10n/JabRef_ru.properties index 069263e63df..f6ab1363bea 100644 --- a/src/main/resources/l10n/JabRef_ru.properties +++ b/src/main/resources/l10n/JabRef_ru.properties @@ -2372,4 +2372,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_sv.properties b/src/main/resources/l10n/JabRef_sv.properties index 90762cffcef..b3f8ad8f16e 100644 --- a/src/main/resources/l10n/JabRef_sv.properties +++ b/src/main/resources/l10n/JabRef_sv.properties @@ -1565,4 +1565,5 @@ Custom=Egna -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_tr.properties b/src/main/resources/l10n/JabRef_tr.properties index bed0696d4f6..771ad317267 100644 --- a/src/main/resources/l10n/JabRef_tr.properties +++ b/src/main/resources/l10n/JabRef_tr.properties @@ -1641,4 +1641,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_vi.properties b/src/main/resources/l10n/JabRef_vi.properties index acd319dcdfe..aa25259521a 100644 --- a/src/main/resources/l10n/JabRef_vi.properties +++ b/src/main/resources/l10n/JabRef_vi.properties @@ -2396,4 +2396,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/main/resources/l10n/JabRef_zh.properties b/src/main/resources/l10n/JabRef_zh.properties index 6d60ea70c40..1b969baa936 100644 --- a/src/main/resources/l10n/JabRef_zh.properties +++ b/src/main/resources/l10n/JabRef_zh.properties @@ -1635,4 +1635,5 @@ Custom= Converts_HTML_code_to_Unicode.= -Add_possibly_missing_dash_to_ISSN= + +Reformat_ISSN= diff --git a/src/test/java/net/sf/jabref/logic/cleanup/CleanupWorkerTest.java b/src/test/java/net/sf/jabref/logic/cleanup/CleanupWorkerTest.java index 73d33ff2bb7..1cc31a1352e 100644 --- a/src/test/java/net/sf/jabref/logic/cleanup/CleanupWorkerTest.java +++ b/src/test/java/net/sf/jabref/logic/cleanup/CleanupWorkerTest.java @@ -6,8 +6,6 @@ import java.util.Collections; import java.util.EnumSet; import java.util.List; -import java.util.Optional; - import net.sf.jabref.BibDatabaseContext; import net.sf.jabref.Globals; import net.sf.jabref.JabRefPreferences; @@ -167,36 +165,6 @@ public void cleanupDoiReturnsChangeWhenDoiInURLField() { Assert.assertEquals(changeList, changes); } - @Test - public void cleanupISSNReturnsCorrectISSN() { - CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.CLEAN_UP_ISSN); - BibEntry entry = new BibEntry(); - entry.setField("issn", "0123-4567"); - - worker.cleanup(preset, entry); - Assert.assertEquals(Optional.of("0123-4567"), entry.getFieldOptional("issn")); - } - - @Test - public void cleanupISSNAddsMissingDash() { - CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.CLEAN_UP_ISSN); - BibEntry entry = new BibEntry(); - entry.setField("issn", "01234567"); - - worker.cleanup(preset, entry); - Assert.assertEquals(Optional.of("0123-4567"), entry.getFieldOptional("issn")); - } - - @Test - public void cleanupISSNJunkStaysJunk() { - CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.CLEAN_UP_ISSN); - BibEntry entry = new BibEntry(); - entry.setField("issn", "Banana"); - - worker.cleanup(preset, entry); - Assert.assertEquals(Optional.of("Banana"), entry.getFieldOptional("issn")); - } - @Test public void cleanupMonthChangesNumberToBibtex() { CleanupPreset preset = new CleanupPreset(new FieldFormatterCleanups(true, diff --git a/src/test/java/net/sf/jabref/logic/cleanup/ISSNCleanupTest.java b/src/test/java/net/sf/jabref/logic/cleanup/ISSNCleanupTest.java new file mode 100644 index 00000000000..6f0c613641e --- /dev/null +++ b/src/test/java/net/sf/jabref/logic/cleanup/ISSNCleanupTest.java @@ -0,0 +1,55 @@ +package net.sf.jabref.logic.cleanup; + +import java.util.Optional; + +import net.sf.jabref.BibDatabaseContext; +import net.sf.jabref.logic.journals.JournalAbbreviationLoader; +import net.sf.jabref.model.entry.BibEntry; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import static org.mockito.Mockito.mock; + +public class ISSNCleanupTest { + + private CleanupWorker worker; + + + @Before + public void setUp() { + worker = new CleanupWorker(mock(BibDatabaseContext.class), mock(JournalAbbreviationLoader.class)); + } + + @Test + public void cleanupISSNReturnsCorrectISSN() { + CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.CLEAN_UP_ISSN); + BibEntry entry = new BibEntry(); + entry.setField("issn", "0123-4567"); + + worker.cleanup(preset, entry); + Assert.assertEquals(Optional.of("0123-4567"), entry.getFieldOptional("issn")); + } + + @Test + public void cleanupISSNAddsMissingDash() { + CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.CLEAN_UP_ISSN); + BibEntry entry = new BibEntry(); + entry.setField("issn", "01234567"); + + worker.cleanup(preset, entry); + Assert.assertEquals(Optional.of("0123-4567"), entry.getFieldOptional("issn")); + } + + @Test + public void cleanupISSNJunkStaysJunk() { + CleanupPreset preset = new CleanupPreset(CleanupPreset.CleanupStep.CLEAN_UP_ISSN); + BibEntry entry = new BibEntry(); + entry.setField("issn", "Banana"); + + worker.cleanup(preset, entry); + Assert.assertEquals(Optional.of("Banana"), entry.getFieldOptional("issn")); + } + +}