Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
* <code>2017_Kitsune_123</code> when expanded using the BibTeX entry <code>@Article{ authors = {O. Kitsune}, year = {2017},
* pages={123-6}}</code>.
* <p>
* The embedding in JabRef is explained at <a href="https://docs.jabref.org/setup/citationkeypattern">Customize the citation key generator</a>.
* The embedding in JabRef is explained at <a href="https://docs.jabref.org/setup/citationkeypatterns">Customize the citation key generator</a>.
* </p>
*/
public class BracketedPattern {
Expand Down Expand Up @@ -807,7 +807,8 @@ private static String firstAuthorVonAndLast(AuthorList authorList) {
* @param authorList an {@link AuthorList}
* @return the surname of an author/editor
*/
private static String lastAuthor(AuthorList authorList) {
@VisibleForTesting
static String lastAuthor(AuthorList authorList) {
if (authorList.isEmpty()) {
return "";
}
Expand Down Expand Up @@ -1221,7 +1222,7 @@ protected static List<String> parseFieldAndModifiers(String arg) {

/**
* <p>
* An author or editor may be and institution not a person. In that case the key generator builds very long keys,
* An author or editor may be an institution not a person. In that case the key generator builds very long keys,
* e.g.: for &ldquo;The Attributed Graph Grammar System (AGG)&rdquo; -> &ldquo;TheAttributedGraphGrammarSystemAGG&rdquo;.
* </p>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ static Stream<Arguments> authShort() {

@ParameterizedTest
@MethodSource
void authIni1(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authIniN(list, 1));
void authShort(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authShort(list));
}

static Stream<Arguments> authIni1() {
Expand All @@ -204,8 +204,8 @@ static Stream<Arguments> authIni1() {

@ParameterizedTest
@MethodSource
void authIni2(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authIniN(list, 2));
void authIni1(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authIniN(list, 1));
}

static Stream<Arguments> authIni2() {
Expand All @@ -230,8 +230,8 @@ static Stream<Arguments> authIni2() {

@ParameterizedTest
@MethodSource
void authIni3(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authIniN(list, 3));
void authIni2(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authIniN(list, 2));
}

static Stream<Arguments> authIni3() {
Expand All @@ -256,8 +256,8 @@ static Stream<Arguments> authIni3() {

@ParameterizedTest
@MethodSource
void authIni4(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authIniN(list, 4));
void authIni3(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authIniN(list, 3));
}

static Stream<Arguments> authIni4() {
Expand All @@ -281,8 +281,8 @@ static Stream<Arguments> authIni4() {

@ParameterizedTest
@MethodSource
void authEtAlDotDotEal(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authEtal(list, ".", ".etal"));
void authIni4(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authIniN(list, 4));
}

static Stream<Arguments> authEtAlDotDotEal() {
Expand All @@ -306,8 +306,8 @@ static Stream<Arguments> authEtAlDotDotEal() {

@ParameterizedTest
@MethodSource
void authAuthEa(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authAuthEa(list));
void authEtAlDotDotEal(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authEtal(list, ".", ".etal"));
}

static Stream<Arguments> authAuthEa() {
Expand All @@ -331,8 +331,26 @@ static Stream<Arguments> authAuthEa() {

@ParameterizedTest
@MethodSource
void authShort(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authShort(list));
void authAuthEa(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.authAuthEa(list));
}

@ParameterizedTest
@CsvSource({
"'Newton', 'Isaac Newton'",
"'Maxwell', 'Isaac Newton and James Maxwell'",
"'Einstein', 'Isaac Newton and James Maxwell and Albert Einstein'",
"'Bohr', 'Isaac Newton and James Maxwell and Albert Einstein and N. Bohr'",
"'Aachen', 'Aachen'",
"'Berlin', 'Aachen and Berlin'",
"'Chemnitz', 'Aachen and Berlin and Chemnitz'",
"'Düsseldorf', 'Aachen and Berlin and Chemnitz and Düsseldorf'",
"'Essen', 'Aachen and Berlin and Chemnitz and Düsseldorf and Essen'",
"'Aalst', 'Wil van der Aalst",
"'Lessen', 'Wil van der Aalst and Tammo van Lessen'"
})
void authLast(String expected, AuthorList list) {
assertEquals(expected, BracketedPattern.lastAuthor(list));
}

@ParameterizedTest
Expand Down
Loading