Skip to content

Commit

Permalink
Merge c18d27e into 044a6ad
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Apr 11, 2019
2 parents 044a6ad + c18d27e commit 4e636f3
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 46 deletions.
21 changes: 11 additions & 10 deletions sdk/src/androidTest/java/com/bugsnag/android/BeforeSendTest.java
Expand Up @@ -4,6 +4,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
Expand All @@ -30,13 +31,13 @@ public void setUp() throws Exception {
config = new Configuration("key");
config.setDelivery(new Delivery() {
@Override
public void deliver(SessionTrackingPayload payload,
Configuration config)
public void deliver(@NonNull SessionTrackingPayload payload,
@NonNull Configuration config)
throws DeliveryFailureException {}

@Override
public void deliver(Report report,
Configuration config)
public void deliver(@NonNull Report report,
@NonNull Configuration config)
throws DeliveryFailureException {
lastReport = report;
}
Expand All @@ -53,21 +54,21 @@ public void tearDown() throws Exception {
public void testCallbackOrderPreserved() {
config.beforeSend(new BeforeSend() {
@Override
public boolean run(Report report) {
public boolean run(@NonNull Report report) {
result = result + "a";
return true;
}
});
config.beforeSend(new BeforeSend() {
@Override
public boolean run(Report report) {
public boolean run(@NonNull Report report) {
result = result + "b";
return true;
}
});
config.beforeSend(new BeforeSend() {
@Override
public boolean run(Report report) {
public boolean run(@NonNull Report report) {
result = result + "c";
return true;
}
Expand All @@ -81,14 +82,14 @@ public boolean run(Report report) {
public void testCancelReport() {
config.beforeSend(new BeforeSend() {
@Override
public boolean run(Report report) {
public boolean run(@NonNull Report report) {
result = result + "a";
return true;
}
});
config.beforeSend(new BeforeSend() {
@Override
public boolean run(Report report) {
public boolean run(@NonNull Report report) {
result = result + "b";
return false;
}
Expand All @@ -102,7 +103,7 @@ public boolean run(Report report) {
public void testAlterReport() {
config.beforeSend(new BeforeSend() {
@Override
public boolean run(Report report) {
public boolean run(@NonNull Report report) {
report.getError().setGroupingHash("123");
return true;
}
Expand Down
20 changes: 10 additions & 10 deletions sdk/src/androidTest/java/com/bugsnag/android/BugsnagTestUtils.java
Expand Up @@ -75,9 +75,9 @@ static SessionStore generateSessionStore() {
static SessionTrackingApiClient generateSessionTrackingApiClient() {
return new SessionTrackingApiClient() {
@Override
public void postSessionTrackingPayload(String urlString,
SessionTrackingPayload payload,
Map<String, String> headers)
public void postSessionTrackingPayload(@NonNull String urlString,
@NonNull SessionTrackingPayload payload,
@NonNull Map<String, String> headers)
throws NetworkException, BadResponseException {

}
Expand All @@ -88,9 +88,9 @@ public void postSessionTrackingPayload(String urlString,
static ErrorReportApiClient generateErrorReportApiClient() { // no-op
return new ErrorReportApiClient() {
@Override
public void postReport(String urlString,
Report report,
Map<String, String> headers)
public void postReport(@NonNull String urlString,
@NonNull Report report,
@NonNull Map<String, String> headers)
throws NetworkException, BadResponseException {

}
Expand All @@ -100,13 +100,13 @@ public void postReport(String urlString,
public static Delivery generateDelivery() {
return new Delivery() {
@Override
public void deliver(SessionTrackingPayload payload,
Configuration config)
public void deliver(@NonNull SessionTrackingPayload payload,
@NonNull Configuration config)
throws DeliveryFailureException {}

@Override
public void deliver(Report report,
Configuration config)
public void deliver(@NonNull Report report,
@NonNull Configuration config)
throws DeliveryFailureException {}

};
Expand Down
Expand Up @@ -6,6 +6,7 @@
import static org.junit.Assert.assertTrue;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
Expand Down Expand Up @@ -105,13 +106,13 @@ public void testCustomDeliveryOverride() {
config = BugsnagTestUtils.generateConfiguration();
Delivery customDelivery = new Delivery() {
@Override
public void deliver(SessionTrackingPayload payload,
Configuration config)
public void deliver(@NonNull SessionTrackingPayload payload,
@NonNull Configuration config)
throws DeliveryFailureException {}

@Override
public void deliver(Report report,
Configuration config)
public void deliver(@NonNull Report report,
@NonNull Configuration config)
throws DeliveryFailureException {}

};
Expand Down
Expand Up @@ -2,6 +2,7 @@

import static org.junit.Assert.assertEquals;

import android.support.annotation.NonNull;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;

Expand Down Expand Up @@ -49,7 +50,7 @@ public void testNotifyBlockingDefaultSeverity() {
public void testNotifyBlockingCallback() {
client.notifyBlocking(new RuntimeException("Testing"), new Callback() {
@Override
public void beforeNotify(Report report) {
public void beforeNotify(@NonNull Report report) {
report.getError().setUserName("Foo");
}
});
Expand All @@ -72,7 +73,7 @@ public void testNotifyBlockingCustomStackTrace() {

client.notifyBlocking("Name", "Message", stacktrace, new Callback() {
@Override
public void beforeNotify(Report report) {
public void beforeNotify(@NonNull Report report) {
report.getError().setSeverity(Severity.ERROR);
}
});
Expand All @@ -89,9 +90,9 @@ static class FakeClient implements ErrorReportApiClient {
Report report;

@Override
public void postReport(String urlString,
Report report,
Map<String, String> headers)
public void postReport(@NonNull String urlString,
@NonNull Report report,
@NonNull Map<String, String> headers)
throws NetworkException, BadResponseException {
try {
Thread.sleep(10); // simulate async request
Expand Down
3 changes: 2 additions & 1 deletion sdk/src/androidTest/java/com/bugsnag/android/ClientTest.java
Expand Up @@ -10,6 +10,7 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
Expand Down Expand Up @@ -116,7 +117,7 @@ public void testRestoreUserFromPrefs() {

client.beforeNotify(new BeforeNotify() {
@Override
public boolean run(Error error) {
public boolean run(@NonNull Error error) {
// Pull out the user information
user.setId(error.getUser().getId());
user.setEmail(error.getUser().getEmail());
Expand Down
Expand Up @@ -36,7 +36,7 @@ public void testClientNotifyModification() throws Exception {
final Collection<BeforeNotify> beforeNotifyTasks = client.config.getBeforeNotifyTasks();
client.beforeNotify(new BeforeNotify() {
@Override
public boolean run(Error error) {
public boolean run(@NonNull Error error) {
beforeNotifyTasks.add(new BeforeNotifySkeleton());
// modify the Set, when iterating to the next callback this should not crash
return true;
Expand Down Expand Up @@ -66,7 +66,7 @@ public boolean shouldRecord(@NonNull Breadcrumb breadcrumb) {

static class BeforeNotifySkeleton implements BeforeNotify {
@Override
public boolean run(Error error) {
public boolean run(@NonNull Error error) {
return true;
}
}
Expand Down
Expand Up @@ -5,6 +5,8 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import android.support.annotation.NonNull;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -38,9 +40,9 @@ public void deliverReport() throws Exception {

deliveryCompat.errorReportApiClient = new ErrorReportApiClient() {
@Override
public void postReport(String urlString,
Report report,
Map<String, String> headers)
public void postReport(@NonNull String urlString,
@NonNull Report report,
@NonNull Map<String, String> headers)
throws NetworkException, BadResponseException {
customCount.incrementAndGet();
}
Expand All @@ -58,9 +60,9 @@ public void deliverSession() throws Exception {

deliveryCompat.sessionTrackingApiClient = new SessionTrackingApiClient() {
@Override
public void postSessionTrackingPayload(String urlString,
SessionTrackingPayload payload,
Map<String, String> headers)
public void postSessionTrackingPayload(@NonNull String urlString,
@NonNull SessionTrackingPayload payload,
@NonNull Map<String, String> headers)
throws NetworkException, BadResponseException {
customCount.incrementAndGet();
}
Expand Down
Expand Up @@ -3,6 +3,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
Expand Down Expand Up @@ -53,9 +54,9 @@ private static class FakeApiClient implements ErrorReportApiClient {
private Report report;

@Override
public void postReport(String urlString,
Report report,
Map<String, String> headers)
public void postReport(@NonNull String urlString,
@NonNull Report report,
@NonNull Map<String, String> headers)
throws NetworkException, BadResponseException {
this.report = report;
}
Expand Down
Expand Up @@ -5,6 +5,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;

import org.junit.After;
Expand Down Expand Up @@ -95,7 +96,7 @@ public void testConfigSetNullMetadata() throws Exception {
public void testNotify() throws Exception {
Bugsnag.beforeNotify(new BeforeNotify() {
@Override
public boolean run(Error error) {
public boolean run(@NonNull Error error) {
validateDefaultMetadata(error.getMetaData());
return false;
}
Expand Down
Expand Up @@ -2,6 +2,7 @@

import static org.junit.Assert.assertEquals;

import android.support.annotation.NonNull;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;

Expand All @@ -20,14 +21,14 @@ public class UniqueBeforeNotifyTest {

private BeforeNotify firstCb = new BeforeNotify() {
@Override
public boolean run(Error error) {
public boolean run(@NonNull Error error) {
return handleCallback();
}
};

private BeforeNotify secondCb = new BeforeNotify() {
@Override
public boolean run(Error error) {
public boolean run(@NonNull Error error) {
return handleCallback();
}
};
Expand Down Expand Up @@ -72,15 +73,15 @@ public void testDuplicateCallback() {
public void testCallbackOrder() {
client.beforeNotify(new BeforeNotify() {
@Override
public boolean run(Error error) {
public boolean run(@NonNull Error error) {
assertEquals(0, callbackCount);
callbackCount++;
return false;
}
});
client.beforeNotify(new BeforeNotify() {
@Override
public boolean run(Error error) {
public boolean run(@NonNull Error error) {
assertEquals(1, callbackCount);
return false;
}
Expand Down

0 comments on commit 4e636f3

Please sign in to comment.