Skip to content

Commit

Permalink
DOIStripTest -> convert into ParametrizedTest
Browse files Browse the repository at this point in the history
  • Loading branch information
nasdas-dev committed May 3, 2021
1 parent add694a commit d39e9e4
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions src/test/java/org/jabref/logic/layout/format/DOIStripTest.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
package org.jabref.logic.layout.format;

import java.util.stream.Stream;

import org.jabref.logic.layout.LayoutFormatter;

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 static org.junit.jupiter.api.Assertions.assertEquals;

public class DOIStripTest {

@Test
public void testFormat() {
LayoutFormatter lf = new DOIStrip();

assertEquals("", lf.format(""));
assertEquals(null, lf.format(null));

assertEquals("10.1000/ISBN1-900512-44-0", lf.format("10.1000/ISBN1-900512-44-0"));
assertEquals("10.1000/ISBN1-900512-44-0",
lf.format("http://dx.doi.org/10.1000/ISBN1-900512-44-0"));

assertEquals("10.1000/ISBN1-900512-44-0",
lf.format("http://doi.acm.org/10.1000/ISBN1-900512-44-0"));
}
LayoutFormatter layoutFormatter = new DOIStrip();

@ParameterizedTest
@MethodSource("provideDOI")
public void testFormatDOIStrip(String formattedDOI, String originalDOI) {
assertEquals(formattedDOI, layoutFormatter.format(originalDOI));
}

private static Stream<Arguments> provideDOI() {
return Stream.of(
Arguments.of("", ""),
Arguments.of(null, null),
Arguments.of("10.1000/ISBN1-900512-44-0", "10.1000/ISBN1-900512-44-0"),
Arguments.of("10.1000/ISBN1-900512-44-0", "http://dx.doi.org/10.1000/ISBN1-900512-44-0"),
Arguments.of("10.1000/ISBN1-900512-44-0", "http://doi.acm.org/10.1000/ISBN1-900512-44-0"),
Arguments.of("10.1145/354401.354407", "http://doi.acm.org/10.1145/354401.354407"),
Arguments.of("10", "10"),
Arguments.of("1", "1")
);
}
}

0 comments on commit d39e9e4

Please sign in to comment.