From 20d8859023ce93a4cbc7d27050a8c379999490d4 Mon Sep 17 00:00:00 2001 From: Bruno Nunes Date: Tue, 5 Oct 2021 13:23:51 -0300 Subject: [PATCH 01/10] Add test DoiCleanup --- .../jabref/logic/cleanup/DoiCleanupTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java diff --git a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java new file mode 100644 index 00000000000..f350af76f66 --- /dev/null +++ b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java @@ -0,0 +1,34 @@ +package org.jabref.logic.cleanup; + +import org.jabref.model.entry.BibEntry; +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; + +public class DoiCleanupTest { + + private BibEntry expected; + + @BeforeEach + public void setUp() { + expected = new BibEntry() + .withField(StandardField.DOI, "10.1145/2594455"); + } + + @Test + void cleanupDoiEntryJustDoi() { + + BibEntry input = new BibEntry() + .withField(StandardField.DOI, "10.1145/2594455"); + + + DoiCleanup cleanup = new DoiCleanup(); + cleanup.cleanup(input); + + assertEquals(expected, input); + } + +} From 5b51e5c1971a15798ee33131a80e7e82d11d9d39 Mon Sep 17 00:00:00 2001 From: Bruno Nunes Date: Tue, 5 Oct 2021 13:26:38 -0300 Subject: [PATCH 02/10] Add test for all Doi related field entries --- .../jabref/logic/cleanup/DoiCleanupTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java index f350af76f66..01f53ed2dec 100644 --- a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java @@ -3,6 +3,7 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; +import org.jabref.model.entry.field.UnknownField; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -31,4 +32,22 @@ void cleanupDoiEntryJustDoi() { assertEquals(expected, input); } + @Test + void cleanupDoiEntryJustDoiAllEntries() { + + UnknownField unknownField = new UnknownField("ee"); + + BibEntry input = new BibEntry() + .withField(StandardField.DOI, "10.1145/2594455") + .withField(StandardField.URL, "https://doi.org/10.1145/2594455") + .withField(StandardField.NOTE, "https://doi.org/10.1145/2594455") + .withField(unknownField, "https://doi.org/10.1145/2594455"); + + + DoiCleanup cleanup = new DoiCleanup(); + cleanup.cleanup(input); + + assertEquals(expected, input); + } + } From b48044e3b30c9d5f19e9a411a80a12e0dfe15f3a Mon Sep 17 00:00:00 2001 From: Bruno Nunes Date: Tue, 5 Oct 2021 13:28:31 -0300 Subject: [PATCH 03/10] Add test for Doi fields without Http --- .../jabref/logic/cleanup/DoiCleanupTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java index 01f53ed2dec..45997f89920 100644 --- a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java @@ -50,4 +50,26 @@ void cleanupDoiEntryJustDoiAllEntries() { assertEquals(expected, input); } + @Test + void cleanupDoiEntryDoiFieldsWithoutHttp() { + + UnknownField unknownField = new UnknownField("ee"); + + BibEntry input = new BibEntry() + .withField(StandardField.DOI, "10.1145/2594455") + .withField(StandardField.NOTE, "This is a random note to this Doi") + .withField(unknownField, "This is a random ee field for this Doi"); + + BibEntry output = new BibEntry() + .withField(StandardField.DOI, "10.1145/2594455") + .withField(StandardField.NOTE, "This is a random note to this Doi") + .withField(unknownField, "This is a random ee field for this Doi"); + + DoiCleanup cleanup = new DoiCleanup(); + cleanup.cleanup(input); + + assertEquals(output, input); + } + + } From 921581812282ae62a6dad47142c7784dafc5be79 Mon Sep 17 00:00:00 2001 From: Bruno Nunes Date: Tue, 5 Oct 2021 13:30:07 -0300 Subject: [PATCH 04/10] Add test for Doi entry with spaces --- .../org/jabref/logic/cleanup/DoiCleanupTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java index 45997f89920..efa180d415b 100644 --- a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java @@ -71,5 +71,17 @@ void cleanupDoiEntryDoiFieldsWithoutHttp() { assertEquals(output, input); } + @Test + void cleanupDoiEntryDoiWithSpaces() { + + BibEntry input = new BibEntry() + .withField(StandardField.DOI, "10.1145 / 2594455"); + + DoiCleanup cleanup = new DoiCleanup(); + cleanup.cleanup(input); + + assertEquals(expected, input); + } + } From 58a9bd8db24226e571801f07c875b9361dbc64b0 Mon Sep 17 00:00:00 2001 From: Bruno Nunes Date: Tue, 5 Oct 2021 13:31:01 -0300 Subject: [PATCH 05/10] Add test for Doi entry with url only --- .../java/org/jabref/logic/cleanup/DoiCleanupTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java index efa180d415b..6c94a20f6c6 100644 --- a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java @@ -83,5 +83,16 @@ void cleanupDoiEntryDoiWithSpaces() { assertEquals(expected, input); } + @Test + void cleanupDoiJustUrl() { + + BibEntry input = new BibEntry() + .withField(StandardField.URL, "https://doi.org/10.1145/2594455"); + + DoiCleanup cleanup = new DoiCleanup(); + cleanup.cleanup(input); + + assertEquals(expected, input); + } } From ae2ec3c0f12926ea96144733ba50404939842ebc Mon Sep 17 00:00:00 2001 From: Bruno Nunes Date: Tue, 5 Oct 2021 13:31:58 -0300 Subject: [PATCH 06/10] Add test for Doi url only at Note entry --- .../org/jabref/logic/cleanup/DoiCleanupTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java index 6c94a20f6c6..88dcbdf68dc 100644 --- a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java @@ -95,4 +95,17 @@ void cleanupDoiJustUrl() { assertEquals(expected, input); } + @Test + void cleanupDoiJustNote() { + + BibEntry input = new BibEntry() + .withField(StandardField.NOTE, "https://doi.org/10.1145/2594455"); + + DoiCleanup cleanup = new DoiCleanup(); + cleanup.cleanup(input); + + assertEquals(expected, input); + } + + } From 8c7ea2dda94652250bd14409494259601be48703 Mon Sep 17 00:00:00 2001 From: Bruno Nunes Date: Tue, 5 Oct 2021 13:33:12 -0300 Subject: [PATCH 07/10] Add test for Doi url only at ee entry --- .../org/jabref/logic/cleanup/DoiCleanupTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java index 88dcbdf68dc..9cd92964e1b 100644 --- a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java @@ -107,5 +107,19 @@ void cleanupDoiJustNote() { assertEquals(expected, input); } + @Test + void cleanupDoiJustEe() { + + UnknownField unknownField = new UnknownField("ee"); + + BibEntry input = new BibEntry() + .withField(unknownField, "https://doi.org/10.1145/2594455"); + + + DoiCleanup cleanup = new DoiCleanup(); + cleanup.cleanup(input); + + assertEquals(expected, input); + } } From a4f98f8584d716bbf3329c21f5047b3b21bca803 Mon Sep 17 00:00:00 2001 From: Bruno Nunes Date: Tue, 5 Oct 2021 14:42:42 -0300 Subject: [PATCH 08/10] Fix checkstyle at file --- src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java index 9cd92964e1b..7a4734f5d3a 100644 --- a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java @@ -2,8 +2,8 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; - import org.jabref.model.entry.field.UnknownField; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -25,7 +25,6 @@ void cleanupDoiEntryJustDoi() { BibEntry input = new BibEntry() .withField(StandardField.DOI, "10.1145/2594455"); - DoiCleanup cleanup = new DoiCleanup(); cleanup.cleanup(input); @@ -43,7 +42,6 @@ void cleanupDoiEntryJustDoiAllEntries() { .withField(StandardField.NOTE, "https://doi.org/10.1145/2594455") .withField(unknownField, "https://doi.org/10.1145/2594455"); - DoiCleanup cleanup = new DoiCleanup(); cleanup.cleanup(input); @@ -115,7 +113,6 @@ void cleanupDoiJustEe() { BibEntry input = new BibEntry() .withField(unknownField, "https://doi.org/10.1145/2594455"); - DoiCleanup cleanup = new DoiCleanup(); cleanup.cleanup(input); From 589638961dacd5183d4d7e651c29884763257996 Mon Sep 17 00:00:00 2001 From: Bruno Nunes Date: Thu, 7 Oct 2021 00:10:13 -0300 Subject: [PATCH 09/10] Change tests to ParameterizedTest --- .../jabref/logic/cleanup/DoiCleanupTest.java | 153 ++++++------------ 1 file changed, 49 insertions(+), 104 deletions(-) diff --git a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java index 7a4734f5d3a..25baad15123 100644 --- a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java @@ -4,119 +4,64 @@ import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.field.UnknownField; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.assertEquals; public class DoiCleanupTest { - private BibEntry expected; - - @BeforeEach - public void setUp() { - expected = new BibEntry() - .withField(StandardField.DOI, "10.1145/2594455"); - } - - @Test - void cleanupDoiEntryJustDoi() { - - BibEntry input = new BibEntry() - .withField(StandardField.DOI, "10.1145/2594455"); - - DoiCleanup cleanup = new DoiCleanup(); - cleanup.cleanup(input); - - assertEquals(expected, input); - } - - @Test - void cleanupDoiEntryJustDoiAllEntries() { - - UnknownField unknownField = new UnknownField("ee"); - - BibEntry input = new BibEntry() - .withField(StandardField.DOI, "10.1145/2594455") - .withField(StandardField.URL, "https://doi.org/10.1145/2594455") - .withField(StandardField.NOTE, "https://doi.org/10.1145/2594455") - .withField(unknownField, "https://doi.org/10.1145/2594455"); - - DoiCleanup cleanup = new DoiCleanup(); - cleanup.cleanup(input); - - assertEquals(expected, input); - } - - @Test - void cleanupDoiEntryDoiFieldsWithoutHttp() { - - UnknownField unknownField = new UnknownField("ee"); - - BibEntry input = new BibEntry() - .withField(StandardField.DOI, "10.1145/2594455") - .withField(StandardField.NOTE, "This is a random note to this Doi") - .withField(unknownField, "This is a random ee field for this Doi"); - - BibEntry output = new BibEntry() - .withField(StandardField.DOI, "10.1145/2594455") - .withField(StandardField.NOTE, "This is a random note to this Doi") - .withField(unknownField, "This is a random ee field for this Doi"); + @ParameterizedTest + @MethodSource("provideDoiForAllLowers") + public void testChangeDoi(BibEntry expected, BibEntry doiInfoField ) { + DoiCleanup cleanUp = new DoiCleanup(); + cleanUp.cleanup(doiInfoField); - DoiCleanup cleanup = new DoiCleanup(); - cleanup.cleanup(input); - - assertEquals(output, input); - } - - @Test - void cleanupDoiEntryDoiWithSpaces() { - - BibEntry input = new BibEntry() - .withField(StandardField.DOI, "10.1145 / 2594455"); - - DoiCleanup cleanup = new DoiCleanup(); - cleanup.cleanup(input); - - assertEquals(expected, input); - } - - @Test - void cleanupDoiJustUrl() { - - BibEntry input = new BibEntry() - .withField(StandardField.URL, "https://doi.org/10.1145/2594455"); - - DoiCleanup cleanup = new DoiCleanup(); - cleanup.cleanup(input); - - assertEquals(expected, input); - } - - @Test - void cleanupDoiJustNote() { - - BibEntry input = new BibEntry() - .withField(StandardField.NOTE, "https://doi.org/10.1145/2594455"); - - DoiCleanup cleanup = new DoiCleanup(); - cleanup.cleanup(input); - - assertEquals(expected, input); + assertEquals(expected, doiInfoField); } - @Test - void cleanupDoiJustEe() { - + private static Stream provideDoiForAllLowers() { UnknownField unknownField = new UnknownField("ee"); - - BibEntry input = new BibEntry() - .withField(unknownField, "https://doi.org/10.1145/2594455"); - - DoiCleanup cleanup = new DoiCleanup(); - cleanup.cleanup(input); - - assertEquals(expected, input); + BibEntry doiResult = new BibEntry().withField(StandardField.DOI, "10.1145/2594455"); + + return Stream.of( + // cleanup for Doi field only + Arguments.of( doiResult, new BibEntry().withField( + StandardField.URL, "https://doi.org/10.1145/2594455")), + + // cleanup with Doi and URL to all entries + Arguments.of( doiResult, new BibEntry() + .withField(StandardField.DOI, "10.1145/2594455") + .withField(StandardField.URL, "https://doi.org/10.1145/2594455") + .withField(StandardField.NOTE, "https://doi.org/10.1145/2594455") + .withField(unknownField, "https://doi.org/10.1145/2594455")), + + // cleanup with Doi and no URL to entries + Arguments.of( + new BibEntry() + .withField(StandardField.DOI, "10.1145/2594455") + .withField(StandardField.NOTE, "This is a random note to this Doi") + .withField(unknownField, "This is a random ee field for this Doi"), + new BibEntry() + .withField(StandardField.DOI, "10.1145/2594455") + .withField(StandardField.NOTE, "This is a random note to this Doi") + .withField(unknownField, "This is a random ee field for this Doi")), + + // cleanup with spaced Doi + Arguments.of( doiResult, new BibEntry() + .withField(StandardField.DOI, "10.1145 / 2594455")), + + // cleanup just Note field with URL + Arguments.of( doiResult, new BibEntry() + .withField(StandardField.NOTE, "https://doi.org/10.1145/2594455")), + + // cleanup just ee field with URL + Arguments.of( doiResult, new BibEntry() + .withField(unknownField, "https://doi.org/10.1145/2594455")) + ); } } From 06656784de0991a5f19135ad11a5c36b485a855b Mon Sep 17 00:00:00 2001 From: Bruno Nunes Date: Thu, 7 Oct 2021 00:24:06 -0300 Subject: [PATCH 10/10] Fix checkstyle warnings at file --- .../org/jabref/logic/cleanup/DoiCleanupTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java index 25baad15123..66d9d4219ee 100644 --- a/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/DoiCleanupTest.java @@ -1,5 +1,7 @@ package org.jabref.logic.cleanup; +import java.util.stream.Stream; + import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.field.UnknownField; @@ -8,15 +10,13 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import java.util.stream.Stream; - import static org.junit.jupiter.api.Assertions.assertEquals; public class DoiCleanupTest { @ParameterizedTest @MethodSource("provideDoiForAllLowers") - public void testChangeDoi(BibEntry expected, BibEntry doiInfoField ) { + public void testChangeDoi(BibEntry expected, BibEntry doiInfoField) { DoiCleanup cleanUp = new DoiCleanup(); cleanUp.cleanup(doiInfoField); @@ -29,11 +29,11 @@ private static Stream provideDoiForAllLowers() { return Stream.of( // cleanup for Doi field only - Arguments.of( doiResult, new BibEntry().withField( + Arguments.of(doiResult, new BibEntry().withField( StandardField.URL, "https://doi.org/10.1145/2594455")), // cleanup with Doi and URL to all entries - Arguments.of( doiResult, new BibEntry() + Arguments.of(doiResult, new BibEntry() .withField(StandardField.DOI, "10.1145/2594455") .withField(StandardField.URL, "https://doi.org/10.1145/2594455") .withField(StandardField.NOTE, "https://doi.org/10.1145/2594455") @@ -51,15 +51,15 @@ private static Stream provideDoiForAllLowers() { .withField(unknownField, "This is a random ee field for this Doi")), // cleanup with spaced Doi - Arguments.of( doiResult, new BibEntry() + Arguments.of(doiResult, new BibEntry() .withField(StandardField.DOI, "10.1145 / 2594455")), // cleanup just Note field with URL - Arguments.of( doiResult, new BibEntry() + Arguments.of(doiResult, new BibEntry() .withField(StandardField.NOTE, "https://doi.org/10.1145/2594455")), // cleanup just ee field with URL - Arguments.of( doiResult, new BibEntry() + Arguments.of(doiResult, new BibEntry() .withField(unknownField, "https://doi.org/10.1145/2594455")) ); }