Skip to content

Commit

Permalink
Trivial doc cleanup and typo fixes; added a test for non-positive sum…
Browse files Browse the repository at this point in the history
…mary argument counts.
  • Loading branch information
Jon Chambers committed Nov 26, 2018
1 parent 89f2ed7 commit 06813d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@ public ApnsPayloadBuilder setThreadId(final String threadId) {
* <p>In iOS 12, the default summary format string in English is "%u more notifications" and does not have a
* placeholder for a summary argument. By default, no summary argument is included in push notification payloads.</p>
*
* @param summaryArgument the summary argument for this notification; if
* {@code null}, the {@code summary-arg} key is omitted from the payload entirely
* @param summaryArgument the summary argument for this notification; if {@code null}, the {@code summary-arg} key
* is omitted from the payload entirely
*
* @return a reference to this payload builder
*
Expand Down Expand Up @@ -579,8 +579,8 @@ public ApnsPayloadBuilder setSummaryArgument(final String summaryArgument) {
* summary argument count is 1 (even if no summary argument count is specified in the notification payload).
* If specified, summary argument count must be positive.</p>
*
* @param summaryArgumentCount the summary argument count for this notification
* {@code null}, the {@code summary-arg-count} key is omitted from the payload entirely
* @param summaryArgumentCount the summary argument count for this notification; if {@code null}, the
* {@code summary-arg-count} key is omitted from the payload entirely
*
* @return a reference to this payload builder
*
Expand All @@ -594,7 +594,9 @@ public ApnsPayloadBuilder setSummaryArgumentCount(final Integer summaryArgumentC
if (summaryArgumentCount != null && summaryArgumentCount < 1) {
throw new IllegalArgumentException("Summary argument count must be positive.");
}

this.summaryArgumentCount = summaryArgumentCount;

return this;
}

Expand All @@ -611,7 +613,7 @@ public ApnsPayloadBuilder setSummaryArgumentCount(final Integer summaryArgumentC
* received.</blockquote>
*
* @param arguments the arguments with which to populate URL placeholders, which may be an empty list; if
* {@code null}, the {@code url-args} key is ommitted from the payload entirely
* {@code null}, the {@code url-args} key is omitted from the payload entirely
*
* @return a reference to this payload builder
*
Expand All @@ -637,7 +639,7 @@ public ApnsPayloadBuilder setUrlArguments(final List<String> arguments) {
* received.</blockquote>
*
* @param arguments the arguments with which to populate URL placeholders, which may be an empty array; if
* {@code null}, the {@code url-args} key is ommitted from the payload entirely
* {@code null}, the {@code url-args} key is omitted from the payload entirely
*
* @return a reference to this payload builder
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ public void testSetSummaryArgumentCount() {
assertEquals(argumentSummaryCount, ((Number) alert.get("summary-arg-count")).intValue());
}

@Test(expected = IllegalArgumentException.class)
public void testSetSummaryArgumentCountNonPositive() {
this.builder.setSummaryArgumentCount(0);
}

@Test
public void testAddCustomProperty() {
final String customKey = "string";
Expand All @@ -486,8 +491,7 @@ public void testAddCustomProperty() {
this.builder.addCustomProperty(customKey, customValue);

@SuppressWarnings("unchecked")
final Map<String, Object> payload = GSON.fromJson(
this.builder.buildWithDefaultMaximumLength(), MAP_OF_STRING_TO_OBJECT);
final Map<String, Object> payload = GSON.fromJson(this.builder.buildWithDefaultMaximumLength(), MAP_OF_STRING_TO_OBJECT);

assertEquals(customValue, payload.get(customKey));
}
Expand Down

0 comments on commit 06813d4

Please sign in to comment.