Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
50e89ff
Resolved Test Smell "Assertion Roulette"
BShaq Mar 24, 2021
0ec8a52
Reduced Test Code Duplication (Test Smell)
BShaq Mar 24, 2021
9a3ec82
Reduced Test Code Duplication (Test Smell) for EditionCheckerTest.java
BShaq Mar 24, 2021
c01c3c3
Refactor of BibDatabaseTest.java (resolved Test Smell: Eager Tests)
BShaq Mar 24, 2021
14f149e
Update BibDatabaseTest.java
BShaq Mar 24, 2021
8add785
Refactoring of FileAnnotationViewModelTest.java (resolved Test Smell:…
BShaq Mar 25, 2021
e4b183d
Refactored MainTableColumnModelTest.java (resolved Test Smell: Eager …
BShaq Mar 25, 2021
5c64b84
Refactored TooltipTextUtil.java (resolved Test Smells: Eager Test, Se…
BShaq Mar 26, 2021
edab481
Refactored ImportDataTest.java (resolved Test Smell: Assertion Roulette
BShaq Mar 26, 2021
74f826b
Refactored JabRefCLITest.java (resolved Test Smell: Eager Tests)
BShaq Mar 26, 2021
0315466
Small fix to JabRefCLITest.java
BShaq Mar 26, 2021
7b4117c
Merge remote-tracking branch 'upstream/master' into a2-bs
BShaq Mar 26, 2021
6be0110
Additional unit tests for EntryComparator.java
BShaq Mar 27, 2021
0c7467c
additional unit tests for UpdateFieldTest.java
BShaq Mar 27, 2021
4053acd
removed comments and duplicated code for EntryComparatorTest.java
BShaq Mar 27, 2021
c772b09
additional unit tests for BibDatabaseDiffTest.java
BShaq Mar 28, 2021
b47441c
Merge remote-tracking branch 'upstream/master' into a2-bs
BShaq Mar 28, 2021
a0bc8f9
small fix on TooltipTextUtilTest.java
BShaq Mar 29, 2021
80f48e2
removed test code duplication in BibDatabaseTest.java
BShaq Mar 29, 2021
2e1e956
Merge remote-tracking branch 'upstream/main' into a2-bs
BShaq Apr 9, 2021
8622db6
Merge remote-tracking branch 'upstream/main' into a2-bs
BShaq Apr 26, 2021
aebae90
added export preferences tests again
BShaq Apr 26, 2021
5a142bf
exchanged assertTrue() with assertEquals() in FileAnnotationViewModel…
BShaq Apr 26, 2021
ecdc372
used assertEquals() in TooltipTextUtilTest
BShaq Apr 26, 2021
3549ac7
minor fixes in EntryComparatorTest
BShaq Apr 26, 2021
9d9725e
minor fixes in EditionCheckerTest
BShaq Apr 26, 2021
6bfa64c
further fixes in UpdateFieldTest
BShaq Apr 26, 2021
58232ff
Merge remote-tracking branch 'upstream/main' into a2-bs
BShaq May 2, 2021
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
79 changes: 66 additions & 13 deletions src/test/java/org/jabref/cli/JabRefCLITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,103 @@

class JabRefCLITest {

private final String bibtex = "@article{test, title=\"test title\"}";

@Test
void parsingLongOptions() throws Exception {
void emptyCLILeftOversLongOptions() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"--nogui", "--import=some/file", "--output=some/export/file"});

assertEquals(Collections.emptyList(), cli.getLeftOver());
assertEquals("some/file", cli.getFileImport());
}

@Test
void guiIsDisabledLongOptions() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"--nogui", "--import=some/file", "--output=some/export/file"});

assertTrue(cli.isDisableGui());
}

@Test
void successfulParsingOfFileImportCLILongOptions() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"--nogui", "--import=some/file", "--output=some/export/file"});

assertEquals("some/file", cli.getFileImport());
}

@Test
void successfulParsingOfFileExportCLILongOptions() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"--nogui", "--import=some/file", "--output=some/export/file"});

assertEquals("some/export/file", cli.getFileExport());
}

@Test
void parsingShortOptions() throws Exception {
void emptyCLILeftOversShortOptions() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"-n", "-i=some/file", "-o=some/export/file"});

assertEquals(Collections.emptyList(), cli.getLeftOver());
assertEquals("some/file", cli.getFileImport());
}

@Test
void guiIsDisabledShortOptions() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"-n", "-i=some/file", "-o=some/export/file"});

assertTrue(cli.isDisableGui());
}

@Test
void successfulParsingOfFileImportShortOptions() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"-n", "-i=some/file", "-o=some/export/file"});

assertEquals("some/file", cli.getFileImport());
}

@Test
void successfulParsingOfFileExportShortOptions() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"-n", "-i=some/file", "-o=some/export/file"});

assertEquals("some/export/file", cli.getFileExport());
}

@Test
void preferencesExport() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"-n", "-x=some/file"});
void emptyLeftOversCLIShortImportingBibtex() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"-ib", bibtex});

assertEquals(Collections.emptyList(), cli.getLeftOver());
assertEquals("some/file", cli.getPreferencesExport());
assertTrue(cli.isDisableGui());
}

@Test
void recognizesImportBibtex() throws Exception {
String bibtex = "@article{test, title=\"test title\"}";
void recognizesImportBibtexShort() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"-ib", bibtex});
assertEquals(Collections.emptyList(), cli.getLeftOver());

assertTrue(cli.isBibtexImport());
}

@Test
void successfulParsingOfBibtexImportShort() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"-ib", bibtex});

assertEquals(bibtex, cli.getBibtexImport());
}

@Test
void recognizesImportBibtexLong() throws Exception {
String bibtex = "@article{test, title=\"test title\"}";
void emptyLeftOversCLILongImportingBibtex() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"-importBibtex", bibtex});

assertEquals(Collections.emptyList(), cli.getLeftOver());
}

@Test
void recognizesImportBibtexLong() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"-importBibtex", bibtex});

assertTrue(cli.isBibtexImport());
}

@Test
void successfulParsingOfBibtexImportLong() throws Exception {
JabRefCLI cli = new JabRefCLI(new String[]{"-importBibtex", bibtex});

assertEquals(bibtex, cli.getBibtexImport());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
import org.jabref.model.pdf.FileAnnotation;
import org.jabref.model.pdf.FileAnnotationType;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class FileAnnotationViewModelTest {

@Test
public void removeOnlyLineBreaksNotPrecededByPeriodOrColon() {
private FileAnnotationViewModel annotationViewModel;

@BeforeEach
void setup() {
String content = "This is content";
String marking = String.format("This is paragraph 1.%n" +
"This is paragr-%naph 2, and it crosses%nseveral lines,%nnow you can see next paragraph:%n"
Expand All @@ -22,16 +25,39 @@ public void removeOnlyLineBreaksNotPrecededByPeriodOrColon() {
FileAnnotation linkedFileAnnotation = new FileAnnotation("John", LocalDateTime.now(), 3, content, FileAnnotationType.FREETEXT, Optional.empty());
FileAnnotation annotation = new FileAnnotation("Jaroslav Kucha ˇr", LocalDateTime.parse("2017-07-20T10:11:30"), 1, marking, FileAnnotationType.HIGHLIGHT, Optional.of(linkedFileAnnotation));

FileAnnotationViewModel annotationViewModel = new FileAnnotationViewModel(annotation);
annotationViewModel = new FileAnnotationViewModel(annotation);
}

@Test
public void sameAuthor() {
String expectedAuthor = "Jaroslav Kucha ˇr";
assertTrue(annotationViewModel.getAuthor().equals(expectedAuthor));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not assertEquals? This is the usual way to check .equals.

}

@Test
public void retrieveCorrectPageNumberAsString() {
String expectedPage = "1";
assertTrue(annotationViewModel.getPage().equals(expectedPage));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String expectedPage = "1";
assertTrue(annotationViewModel.getPage().equals(expectedPage));
assertEquals("1", annotationViewModel.getPage());

}

@Test
public void retrieveCorrectDateAsString() {
String expectedDate = "2017-07-20 10:11:30";
assertTrue(annotationViewModel.getDate().equals(expectedDate));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a one-liner like shown above.

}

assertEquals("Jaroslav Kucha ˇr", annotationViewModel.getAuthor());
assertEquals(1, annotation.getPage());
assertEquals("2017-07-20 10:11:30", annotationViewModel.getDate());
assertEquals("This is content", annotationViewModel.getContent());
@Test
public void retrieveCorrectContent() {
String expectedContent = "This is content";
assertTrue(annotationViewModel.getContent().equals(expectedContent));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a one-liner like shown above.

}

@Test
public void removeOnlyLineBreaksNotPrecededByPeriodOrColon() {
String expectedMarking = String.format("This is paragraph 1.%n" +
"This is paragraph 2, and it crosses several lines, now you can see next paragraph:%n"
+ "This is paragraph 3.");

assertEquals(String.format("This is paragraph 1.%n" +
"This is paragraph 2, and it crosses several lines, now you can see next paragraph:%n"
+ "This is paragraph 3."),
annotationViewModel.getMarking());
assertTrue(annotationViewModel.getMarking().equals(expectedMarking));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use assertEquals.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,44 @@ public class MainTableColumnModelTest {
private static MainTableColumnModel.Type testTypeOnlyType = MainTableColumnModel.Type.LINKED_IDENTIFIER;

@Test
public void testMainTableColumnModelParser() {
public void mainTableColumnModelParserRetrievesCorrectType() {
MainTableColumnModel testColumnModel = MainTableColumnModel.parse(testQualifier);

assertEquals(testColumnModel.getType(), testType);
}

@Test
public void mainTableColumnModelParserRetrievesCorrectQualifier() {
MainTableColumnModel testColumnModel = MainTableColumnModel.parse(testQualifier);

assertEquals(testColumnModel.getQualifier(), testQualifier);
}

@Test
public void testMainTableColumnModelParserFull() {
public void fullMainTableColumnModelParserRetrievesCorrectType() {
MainTableColumnModel testColumnModel = MainTableColumnModel.parse(testName);

assertEquals(testColumnModel.getType(), testType);
}

@Test
public void fullMainTableColumnModelParserRetrievesCorrectQualifier() {
MainTableColumnModel testColumnModel = MainTableColumnModel.parse(testName);

assertEquals(testColumnModel.getQualifier(), testQualifier);
}

@Test
public void testMainTableColumnModelParserTypeOnly() {
public void typeOnlyMainTableColumnModelParserRetrievesCorrectType() {
MainTableColumnModel testColumnModel = MainTableColumnModel.parse(testTypeOnlyName);

assertEquals(testColumnModel.getType(), testTypeOnlyType);
}

@Test
public void typeOnlyMainTableColumnModelParserRetrievesCorrectQualifier() {
MainTableColumnModel testColumnModel = MainTableColumnModel.parse(testTypeOnlyName);

assertEquals(testColumnModel.getQualifier(), "");
}
}
Loading