Skip to content

Commit 72d9c1d

Browse files
Issue676 author last (#13625)
* Add test of [authList] * Consistently order argument providers and tests * Move remaining lastAuthor tests * Incorporate reviewer feedback --------- Co-authored-by: espertusnu <[email protected]> Co-authored-by: Christoph <[email protected]>
1 parent d0b7203 commit 72d9c1d

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

jablib/src/main/java/org/jabref/logic/citationkeypattern/BracketedPattern.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* <code>2017_Kitsune_123</code> when expanded using the BibTeX entry <code>@Article{ authors = {O. Kitsune}, year = {2017},
4747
* pages={123-6}}</code>.
4848
* <p>
49-
* The embedding in JabRef is explained at <a href="https://docs.jabref.org/setup/citationkeypattern">Customize the citation key generator</a>.
49+
* The embedding in JabRef is explained at <a href="https://docs.jabref.org/setup/citationkeypatterns">Customize the citation key generator</a>.
5050
* </p>
5151
*/
5252
public class BracketedPattern {
@@ -807,7 +807,8 @@ private static String firstAuthorVonAndLast(AuthorList authorList) {
807807
* @param authorList an {@link AuthorList}
808808
* @return the surname of an author/editor
809809
*/
810-
private static String lastAuthor(AuthorList authorList) {
810+
@VisibleForTesting
811+
static String lastAuthor(AuthorList authorList) {
811812
if (authorList.isEmpty()) {
812813
return "";
813814
}
@@ -1221,7 +1222,7 @@ protected static List<String> parseFieldAndModifiers(String arg) {
12211222

12221223
/**
12231224
* <p>
1224-
* An author or editor may be and institution not a person. In that case the key generator builds very long keys,
1225+
* An author or editor may be an institution not a person. In that case the key generator builds very long keys,
12251226
* e.g.: for &ldquo;The Attributed Graph Grammar System (AGG)&rdquo; -> &ldquo;TheAttributedGraphGrammarSystemAGG&rdquo;.
12261227
* </p>
12271228
*

jablib/src/test/java/org/jabref/logic/citationkeypattern/BracketedPatternTest.java

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ static Stream<Arguments> authShort() {
179179

180180
@ParameterizedTest
181181
@MethodSource
182-
void authIni1(String expected, AuthorList list) {
183-
assertEquals(expected, BracketedPattern.authIniN(list, 1));
182+
void authShort(String expected, AuthorList list) {
183+
assertEquals(expected, BracketedPattern.authShort(list));
184184
}
185185

186186
static Stream<Arguments> authIni1() {
@@ -204,8 +204,8 @@ static Stream<Arguments> authIni1() {
204204

205205
@ParameterizedTest
206206
@MethodSource
207-
void authIni2(String expected, AuthorList list) {
208-
assertEquals(expected, BracketedPattern.authIniN(list, 2));
207+
void authIni1(String expected, AuthorList list) {
208+
assertEquals(expected, BracketedPattern.authIniN(list, 1));
209209
}
210210

211211
static Stream<Arguments> authIni2() {
@@ -230,8 +230,8 @@ static Stream<Arguments> authIni2() {
230230

231231
@ParameterizedTest
232232
@MethodSource
233-
void authIni3(String expected, AuthorList list) {
234-
assertEquals(expected, BracketedPattern.authIniN(list, 3));
233+
void authIni2(String expected, AuthorList list) {
234+
assertEquals(expected, BracketedPattern.authIniN(list, 2));
235235
}
236236

237237
static Stream<Arguments> authIni3() {
@@ -256,8 +256,8 @@ static Stream<Arguments> authIni3() {
256256

257257
@ParameterizedTest
258258
@MethodSource
259-
void authIni4(String expected, AuthorList list) {
260-
assertEquals(expected, BracketedPattern.authIniN(list, 4));
259+
void authIni3(String expected, AuthorList list) {
260+
assertEquals(expected, BracketedPattern.authIniN(list, 3));
261261
}
262262

263263
static Stream<Arguments> authIni4() {
@@ -281,8 +281,8 @@ static Stream<Arguments> authIni4() {
281281

282282
@ParameterizedTest
283283
@MethodSource
284-
void authEtAlDotDotEal(String expected, AuthorList list) {
285-
assertEquals(expected, BracketedPattern.authEtal(list, ".", ".etal"));
284+
void authIni4(String expected, AuthorList list) {
285+
assertEquals(expected, BracketedPattern.authIniN(list, 4));
286286
}
287287

288288
static Stream<Arguments> authEtAlDotDotEal() {
@@ -306,8 +306,8 @@ static Stream<Arguments> authEtAlDotDotEal() {
306306

307307
@ParameterizedTest
308308
@MethodSource
309-
void authAuthEa(String expected, AuthorList list) {
310-
assertEquals(expected, BracketedPattern.authAuthEa(list));
309+
void authEtAlDotDotEal(String expected, AuthorList list) {
310+
assertEquals(expected, BracketedPattern.authEtal(list, ".", ".etal"));
311311
}
312312

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

332332
@ParameterizedTest
333333
@MethodSource
334-
void authShort(String expected, AuthorList list) {
335-
assertEquals(expected, BracketedPattern.authShort(list));
334+
void authAuthEa(String expected, AuthorList list) {
335+
assertEquals(expected, BracketedPattern.authAuthEa(list));
336+
}
337+
338+
@ParameterizedTest
339+
@CsvSource({
340+
"'Newton', 'Isaac Newton'",
341+
"'Maxwell', 'Isaac Newton and James Maxwell'",
342+
"'Einstein', 'Isaac Newton and James Maxwell and Albert Einstein'",
343+
"'Bohr', 'Isaac Newton and James Maxwell and Albert Einstein and N. Bohr'",
344+
"'Aachen', 'Aachen'",
345+
"'Berlin', 'Aachen and Berlin'",
346+
"'Chemnitz', 'Aachen and Berlin and Chemnitz'",
347+
"'Düsseldorf', 'Aachen and Berlin and Chemnitz and Düsseldorf'",
348+
"'Essen', 'Aachen and Berlin and Chemnitz and Düsseldorf and Essen'",
349+
"'Aalst', 'Wil van der Aalst",
350+
"'Lessen', 'Wil van der Aalst and Tammo van Lessen'"
351+
})
352+
void authLast(String expected, AuthorList list) {
353+
assertEquals(expected, BracketedPattern.lastAuthor(list));
336354
}
337355

338356
@ParameterizedTest

0 commit comments

Comments
 (0)