Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Review field in entry preview to comment #4100

Merged
merged 10 commits into from
Jun 13, 2018

Conversation

Siedlerchr
Copy link
Member

@Siedlerchr Siedlerchr commented Jun 5, 2018

Migrate Review field in entry preview to comment
Replace review with comment in every layout file
Fixes #4098


  • Change in CHANGELOG.md described
  • Tests created for changes
  • Manually tested changed features in running JabRef
  • Screenshots added in PR description (for bigger UI changes)
  • Ensured that the git commit message is a good one
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

@Siedlerchr Siedlerchr changed the title Fixentrypreviewcomments Migrate Review field in entry preview to comment Jun 5, 2018
@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jun 5, 2018
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

LGTM. Can we have a test case for the migration?

@Siedlerchr
Copy link
Member Author

Added a test case

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

LGTM and I've only a few minor remarks.

@@ -366,6 +366,15 @@
// Id Entry Generator Preferences
public static final String ID_ENTRY_GENERATOR = "idEntryGenerator";

// Preview
//public because needed for pref migration
public static final String PREVIEW_STYLE = "previewStyle";
Copy link
Member

Choose a reason for hiding this comment

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

You can simply add a get/setPreviewStyle method which I would prefer.

}

static void upgradePreviewStyleFromReviewToComment() {
JabRefPreferences prefs = Globals.prefs;
Copy link
Member

Choose a reason for hiding this comment

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

You can pass the preferences class as a parameter and then use mock in combination with verify in the tests below (instead of working on the actual preference object).

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried around with this but I currently see no way to do this. When I mock the object, calling the migration method on the object will have no effect as it operates directly on the preferences object. I don't like that operating on the real prefs object but
Sure I can mock returns, but that's not the goal of this test.
However, I could remove the dependency on the actual Globals.prefs object by passing a Preferences object as parametre

"[bibtexkey] - [fulltitle]"};
"[bibtexkey] - [fulltitle]"};

private final String oldPreviewStyle = "<font face=\"sans-serif\">"
Copy link
Member

Choose a reason for hiding this comment

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

Can you please define these as local variables in the test below and try to simplify it a bit by removing unimportant lines.

@Siedlerchr
Copy link
Member Author

I would vote for merging this, I refactored the tests and the migrations so that they no longer call Globals.prefs. _ More mocking is not really possible.

+ "</dd>__NEWLINE__<p></p></font>";

String previousStyle = prefs.getPreviewStyle();
prefs.setPreviewStyle(oldPreviewStyle);
Copy link
Member

@tobiasdiez tobiasdiez Jun 12, 2018

Choose a reason for hiding this comment

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

I don't see a reason why you shouldn't be able to mock the preferences:

preferences = mock(JabRefPreferences);
when(preferences.getPreviewStyle).thenReturn(oldPreviewStyle);;
verify(preferences).setPreviewStyle(newPreviewStyle);

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it now, I didn't know that verify is interpreted as "assert" and makes the test fail/succeed

…mments

* upstream/master:
  Extract v4.x changelog (#4125)
  Saves and reloads window state on close and on open (#4124)
  Fix convert to bibtex moves contents of the file field (#4123)
@tobiasdiez tobiasdiez merged commit 09ceea0 into master Jun 13, 2018
@tobiasdiez tobiasdiez deleted the fixentrypreviewcomments branch June 13, 2018 21:39
Siedlerchr added a commit that referenced this pull request Jun 15, 2018
* upstream/master: (22 commits)
  fix failing architecture test by making test class public again migrate architecture test to junit jupiter
  Fix build... (#4128)
  fix checkstyle after merge
  Migrate Review field in entry preview to comment (#4100)
  [WIP] Split push to applications in logic and gui (#4110)
  Fix checkstyle
  Fix #4115: Don't report journal name as abbreviated when full name = abbreviated name (#4116)
  Use <kbd>in changelog
  Groups right click (#4061)
  Fix open thread prevents shutdown (#4111)
  Extract v4.x changelog (#4125)
  Saves and reloads window state on close and on open (#4124)
  Fix convert to bibtex moves contents of the file field (#4123)
  Opens the directory of the currently edited file when opening a new file (#4106)
  Don't run on Swing thread
  Properly shutdown telemetry client
  Code cleanup
  Remove Swing stuff (L&F, font customization)
  Properly shutdown JabRef (not with System.exit)
  Replace swing clipboard with JavaFX one
  ...

# Conflicts:
#	src/main/java/org/jabref/gui/BasePanel.java
#	src/main/java/org/jabref/gui/JabRefFrame.java
#	src/main/java/org/jabref/gui/maintable/MainTable.java
#	src/main/java/org/jabref/gui/search/SearchResultFrame.java
#	src/main/java/org/jabref/preferences/JabRefPreferences.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants