Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
252 changes: 87 additions & 165 deletions src/main/java/io/getstream/client/NotificationFeed.java

Large diffs are not rendered by default.

252 changes: 87 additions & 165 deletions src/main/java/io/getstream/cloud/CloudNotificationFeed.java

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/main/java/io/getstream/core/http/OKHTTPClientAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public void onFailure(Call call, IOException e) {

@Override
public void onResponse(Call call, okhttp3.Response response) {
io.getstream.core.http.Response httpResponse = buildResponse(response);
try (InputStream ignored = httpResponse.getBody()) {
try {
io.getstream.core.http.Response httpResponse = buildResponse(response);
result.complete(httpResponse);
} catch (Exception e) {
result.completeExceptionally(e);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/getstream/core/models/Paginated.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public String getDuration() {
}

@JsonCreator
private Paginated(
public Paginated(
@JsonProperty("next") String next,
@JsonProperty("results") List<T> results,
@JsonProperty("duration") String duration) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.getstream.core.models;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class PaginatedNotificationGroup<T> extends Paginated<NotificationGroup<T>> {
private final int unread;
private final int unseen;

@JsonCreator
public PaginatedNotificationGroup(
@JsonProperty("next") String next,
@JsonProperty("results") List<NotificationGroup<T>> results,
@JsonProperty("duration") String duration,
@JsonProperty("unread") int unread,
@JsonProperty("unseen") int unseen) {
super(next, results, duration);

this.unread = unread;
this.unseen = unseen;
}

public int getUnread() {
return this.unread;
}

public int getUnseen() {
return this.unseen;
}
}
13 changes: 9 additions & 4 deletions src/test/java/io/getstream/client/NotificationFeedTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.getstream.client;

import static org.junit.Assert.*;

import io.getstream.core.http.OKHTTPClientAdapter;
import io.getstream.core.models.Activity;
import io.getstream.core.models.EnrichedActivity;
import io.getstream.core.models.NotificationGroup;
import java.util.List;
import io.getstream.core.models.PaginatedNotificationGroup;
import okhttp3.OkHttpClient;
import org.junit.Test;

Expand All @@ -26,7 +27,9 @@ public void getActivityGroups() throws Exception {
.build();

NotificationFeed feed = client.notificationFeed("notification", "1");
List<NotificationGroup<Activity>> result = feed.getActivities().join();
PaginatedNotificationGroup<Activity> result = feed.getActivities().join();
assertFalse(result.getResults().isEmpty());
assertNotNull(result.getResults().get(0).getID());
}

@Test
Expand All @@ -37,6 +40,8 @@ public void getEnrichedActivityGroups() throws Exception {
.build();

NotificationFeed feed = client.notificationFeed("notification", "1");
List<NotificationGroup<EnrichedActivity>> result = feed.getEnrichedActivities().join();
PaginatedNotificationGroup<EnrichedActivity> result = feed.getEnrichedActivities().join();
assertFalse(result.getResults().isEmpty());
assertNotNull(result.getResults().get(0).getID());
}
}
11 changes: 7 additions & 4 deletions src/test/java/io/getstream/cloud/CloudNotificationFeedTest.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package io.getstream.cloud;

import static org.junit.Assert.*;

import io.getstream.client.Client;
import io.getstream.core.http.Token;
import io.getstream.core.models.Activity;
import io.getstream.core.models.EnrichedActivity;
import io.getstream.core.models.NotificationGroup;
import io.getstream.core.models.PaginatedNotificationGroup;
import io.getstream.core.utils.Enrichment;
import java.net.MalformedURLException;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;

Expand Down Expand Up @@ -53,14 +54,16 @@ public void getActivityGroups() throws Exception {
CloudClient client = CloudClient.builder(apiKey, token, userID).build();

CloudNotificationFeed feed = client.notificationFeed("notification", userID);
List<NotificationGroup<Activity>> result = feed.getActivities().join();
PaginatedNotificationGroup<Activity> result = feed.getActivities().join();
assertFalse(result.getResults().isEmpty());
assertNotNull(result.getResults().get(0).getID());
}

@Test
public void getEnrichedActivityGroups() throws Exception {
CloudClient client = CloudClient.builder(apiKey, token, userID).build();

CloudNotificationFeed feed = client.notificationFeed("rich_notification", userID);
List<NotificationGroup<EnrichedActivity>> result = feed.getEnrichedActivities().join();
PaginatedNotificationGroup<EnrichedActivity> result = feed.getEnrichedActivities().join();
}
}