Skip to content

Commit

Permalink
Make API to get change log nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
cketti committed Nov 4, 2016
1 parent ac3b4cb commit 5b90cf4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,20 @@ public void writeCurrentVersion() {
}

/**
* Returns the change log.
* Returns the full change log.
*
* @param full
* If this is {@code true} the full change log is returned. Otherwise only changes for
* versions newer than the last version are returned.
* @return A sorted {@code List} containing {@link ReleaseItem}s representing the full change log.
*/
public List<ReleaseItem> getChangeLog() {
return changeLogProvider.getChangeLog();
}

/**
* Returns the list of changes for versions newer than the last version ("What's New").
*
* @return A sorted {@code List} containing {@link ReleaseItem}s representing the (partial)
* change log.
* @return A sorted {@code List} containing {@link ReleaseItem}s representing the recent changes.
*/
public List<ReleaseItem> getChangeLog(boolean full) {
return full ?
changeLogProvider.getChangeLog() :
changeLogProvider.getChangeLogSince(lastVersionCode);
public List<ReleaseItem> getRecentChanges() {
return changeLogProvider.getChangeLogSince(lastVersionCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,24 @@ public void writeCurrentVersion() throws Exception {
}

@Test
public void getChangeLog_withTrueArgument_shouldReturnDataFromChangeLogProvider() throws Exception {
public void getChangeLog_shouldReturnDataFromChangeLogProvider() throws Exception {
ChangeLog changeLog = ChangeLog.newInstance(context, preferences, changeLogProvider);
List<ReleaseItem> releaseItemsToReturn = new ArrayList<>();
when(changeLogProvider.getChangeLog()).thenReturn(releaseItemsToReturn);

List<ReleaseItem> releaseItems = changeLog.getChangeLog(true);
List<ReleaseItem> releaseItems = changeLog.getChangeLog();

assertSame(releaseItemsToReturn, releaseItems);
}

@Test
public void getChangeLog_withFalseArgument_shouldReturnDataFromChangeLogProvider() throws Exception {
public void getRecentChanges_shouldReturnDataFromChangeLogProvider() throws Exception {
setLastVersionCode(2);
ChangeLog changeLog = ChangeLog.newInstance(context, preferences, changeLogProvider);
List<ReleaseItem> releaseItemsToReturn = new ArrayList<>();
when(changeLogProvider.getChangeLogSince(2)).thenReturn(releaseItemsToReturn);

List<ReleaseItem> releaseItems = changeLog.getChangeLog(false);
List<ReleaseItem> releaseItems = changeLog.getRecentChanges();

assertSame(releaseItemsToReturn, releaseItems);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ private String getLog(boolean full) {

String versionFormat = context.getResources().getString(R.string.changelog_version_format);

List<ReleaseItem> changelog = changeLog.getChangeLog(full);
List<ReleaseItem> changelog = full ?
changeLog.getChangeLog() :
changeLog.getRecentChanges();

for (ReleaseItem release : changelog) {
sb.append("<h1>");
Expand Down

2 comments on commit 5b90cf4

@johnjohndoe
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 Ah, you are on it again. Nice. Do you need feedback, ...?

@cketti
Copy link
Owner Author

@cketti cketti commented on 5b90cf4 Jan 13, 2017

Choose a reason for hiding this comment

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

Sure. I created PR #39 to make it easier to provide feedback.

Please sign in to comment.