Skip to content

Commit 1b5a5d9

Browse files
committed
test(e2e): updated end-to-end tests to handle SDK renames
1 parent 6ab6567 commit 1b5a5d9

11 files changed

Lines changed: 58 additions & 106 deletions

File tree

features/fixtures/logback/threads_config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<endpoint>http://localhost:9339/notify</endpoint>
1111

12-
<sendThreads>true</sendThreads>
12+
<sendThreads>ALWAYS</sendThreads>
1313
</appender>
1414

1515
<root level="INFO">

features/fixtures/mazerunnerspringboot3/src/main/java/com/bugsnag/mazerunner/scenarios/ScheduledTaskExecutorScenario.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package com.bugsnag.mazerunner.scenarios;
22

33
import com.bugsnag.Bugsnag;
4-
import com.bugsnag.Report;
5-
import com.bugsnag.callbacks.Callback;
64
import com.bugsnag.mazerunnerspringboot.ScheduledTaskExecutorService;
5+
76
import java.util.Collection;
87

98
public class ScheduledTaskExecutorScenario extends Scenario {
@@ -25,13 +24,10 @@ public void run() {
2524
}
2625

2726
final Collection<String> threadnames = ScheduledTaskExecutorService.getThreadNames();
28-
bugsnag.notify(new RuntimeException("Whoops"), new Callback() {
29-
@Override
30-
public boolean onError(Report report) {
31-
report.addMetadata("executor", "multiThreaded", threadnames.size() > 1);
32-
report.addMetadata("executor", "names", threadnames);
33-
return true;
34-
}
27+
bugsnag.notify(new RuntimeException("Whoops"), (event) -> {
28+
event.addMetadata("executor", "multiThreaded", threadnames.size() > 1);
29+
event.addMetadata("executor", "names", threadnames);
30+
return true;
3531
});
3632
}
3733
}
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.bugsnag.mazerunner.scenarios;
22

33
import com.bugsnag.Bugsnag;
4-
import com.bugsnag.Report;
5-
import com.bugsnag.callbacks.Callback;
4+
import com.bugsnag.BugsnagEvent;
5+
import com.bugsnag.callbacks.OnErrorCallback;
66

77
/**
88
* Sends a handled exception to Bugsnag, which contains metadata that should be redacted
@@ -15,14 +15,11 @@ public AutoRedactScenario(Bugsnag bugsnag) {
1515

1616
@Override
1717
public void run() {
18-
bugsnag.notify(generateException(), new Callback() {
19-
@Override
20-
public boolean onError(Report report) {
21-
report.addMetadata("user", "password", "hunter2");
22-
report.addMetadata("custom", "password", "hunter2");
23-
report.addMetadata("custom", "foo", "hunter2");
24-
return true;
25-
}
18+
bugsnag.notify(generateException(), event -> {
19+
event.addMetadata("user", "password", "hunter2");
20+
event.addMetadata("custom", "password", "hunter2");
21+
event.addMetadata("custom", "foo", "hunter2");
22+
return true;
2623
});
2724
}
2825
}
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package com.bugsnag.mazerunner.scenarios;
22

33
import com.bugsnag.Bugsnag;
4-
import com.bugsnag.Report;
5-
import com.bugsnag.callbacks.Callback;
64
import com.bugsnag.logback.BugsnagMarker;
7-
85
import org.slf4j.Logger;
96
import org.slf4j.LoggerFactory;
107

@@ -21,14 +18,11 @@ public LogbackMetadataScenario(Bugsnag bugsnag) {
2118

2219
@Override
2320
public void run() {
24-
LOGGER.warn(new BugsnagMarker(new Callback() {
25-
@Override
26-
public boolean onError(Report report) {
27-
report.addMetadata("user", "foo", "hunter2");
28-
report.addMetadata("custom", "foo", "hunter2");
29-
report.addMetadata("custom", "bar", "hunter2");
30-
return true;
31-
}
21+
LOGGER.warn(new BugsnagMarker(event -> {
22+
event.addMetadata("user", "foo", "hunter2");
23+
event.addMetadata("custom", "foo", "hunter2");
24+
event.addMetadata("custom", "bar", "hunter2");
25+
return true;
3226
}), "Error sent to Bugsnag using the logback appender", generateException());
3327
}
3428
}
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.bugsnag.mazerunner.scenarios;
22

33
import com.bugsnag.Bugsnag;
4-
import com.bugsnag.Report;
5-
import com.bugsnag.callbacks.Callback;
64

75
/**
86
* Sends a handled exception to Bugsnag, which includes manual context.
@@ -15,12 +13,9 @@ public ManualContextScenario(Bugsnag bugsnag) {
1513

1614
@Override
1715
public void run() {
18-
bugsnag.notify(generateException(), new Callback() {
19-
@Override
20-
public boolean onError(Report report) {
21-
report.setContext("FooContext");
22-
return true;
23-
}
16+
bugsnag.notify(generateException(), event -> {
17+
event.setContext("FooContext");
18+
return true;
2419
});
2520
}
2621
}
Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.bugsnag.mazerunner.scenarios;
22

33
import com.bugsnag.Bugsnag;
4-
import com.bugsnag.Report;
5-
import com.bugsnag.callbacks.Callback;
64

75
/**
86
* Sends a handled exception to Bugsnag, which contains metadata that should be redacted
@@ -18,14 +16,11 @@ public void run() {
1816

1917
bugsnag.setRedactedKeys("foo");
2018

21-
bugsnag.notify(generateException(), new Callback() {
22-
@Override
23-
public boolean onError(Report report) {
24-
report.addMetadata("user", "foo", "hunter2");
25-
report.addMetadata("custom", "foo", "hunter2");
26-
report.addMetadata("custom", "bar", "hunter2");
27-
return true;
28-
}
19+
bugsnag.notify(generateException(), event -> {
20+
event.addMetadata("user", "foo", "hunter2");
21+
event.addMetadata("custom", "foo", "hunter2");
22+
event.addMetadata("custom", "bar", "hunter2");
23+
return true;
2924
});
3025
}
3126
}
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.bugsnag.mazerunner.scenarios;
22

33
import com.bugsnag.Bugsnag;
4-
import com.bugsnag.Report;
5-
import com.bugsnag.callbacks.Callback;
64

75
/**
86
* Sends a handled exception to Bugsnag, which includes custom metadata
@@ -15,12 +13,9 @@ public MetadataScenario(Bugsnag bugsnag) {
1513

1614
@Override
1715
public void run() {
18-
bugsnag.notify(generateException(), new Callback() {
19-
@Override
20-
public boolean onError(Report report) {
21-
report.addMetadata("Custom", "foo", "Hello World!");
22-
return true;
23-
}
16+
bugsnag.notify(generateException(), event -> {
17+
event.addMetadata("Custom", "foo", "Hello World!");
18+
return true;
2419
});
2520
}
2621
}

features/fixtures/scenarios/src/main/java/com/bugsnag/mazerunner/scenarios/ThreadMetadataScenario.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.bugsnag.mazerunner.scenarios;
22

33
import com.bugsnag.Bugsnag;
4-
import com.bugsnag.callbacks.Callback;
5-
import com.bugsnag.Report;
64

75
/**
86
* Sends an exception to Bugsnag with custom metadata on the thread
@@ -16,13 +14,10 @@ public ThreadMetadataScenario(Bugsnag bugsnag) {
1614
@Override
1715
public void run() {
1816
// Global callback metadata has lowest precedence
19-
bugsnag.addCallback(new Callback() {
20-
@Override
21-
public boolean onError(Report report) {
22-
report.addMetadata("Custom", "test", "Global value");
23-
report.addMetadata("Custom", "foo", "Global value to be overwritten");
24-
return true;
25-
}
17+
bugsnag.addOnError((event) -> {
18+
event.addMetadata("Custom", "test", "Global value");
19+
event.addMetadata("Custom", "foo", "Global value to be overwritten");
20+
return true;
2621
});
2722

2823
// Thread metadata should merge with global metadata and overwrite when duplicate key
@@ -46,12 +41,9 @@ public void run() {
4641
}
4742

4843
// Report-specific metadata should merge with global + thread metadata and overwrite when duplicate key
49-
bugsnag.notify(generateException(), new Callback() {
50-
@Override
51-
public boolean onError(Report report) {
52-
report.addMetadata("Custom", "bar", "Hello World!");
53-
return true;
54-
}
44+
bugsnag.notify(generateException(), (event) -> {
45+
event.addMetadata("Custom", "bar", "Hello World!");
46+
return true;
5547
});
5648
}
5749
}

features/fixtures/scenarios/src/main/java/com/bugsnag/mazerunner/scenarios/ThreadsScenario.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.bugsnag.mazerunner.scenarios;
22

33
import com.bugsnag.Bugsnag;
4-
import com.bugsnag.Report;
5-
import com.bugsnag.callbacks.Callback;
4+
import com.bugsnag.ThreadSendPolicy;
65

76
/**
87
* Sends a handled exception to Bugsnag, which overrides the default user via a callback
@@ -11,7 +10,7 @@ public class ThreadsScenario extends Scenario {
1110

1211
public ThreadsScenario(Bugsnag bugsnag) {
1312
super(bugsnag);
14-
bugsnag.setSendThreads(true);
13+
bugsnag.setSendThreads(ThreadSendPolicy.ALWAYS);
1514
}
1615

1716
@Override

features/fixtures/scenarios/src/main/java/com/bugsnag/mazerunner/scenarios/UnhandledThreadMetadataScenario.java

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.bugsnag.mazerunner.scenarios;
22

33
import com.bugsnag.Bugsnag;
4-
import com.bugsnag.callbacks.Callback;
5-
import com.bugsnag.Report;
64

75
/**
86
* Sends an unhandled exception to Bugsnag with custom metadata on the thread
@@ -16,22 +14,21 @@ public UnhandledThreadMetadataScenario(Bugsnag bugsnag) {
1614
@Override
1715
public void run() {
1816
// Global callback metadata has lowest precedence
19-
bugsnag.addCallback(new Callback() {
20-
@Override
21-
public boolean onError(Report report) {
22-
report.addMetadata("Custom", "test", "Global value");
23-
report.addMetadata("Custom", "foo", "Global value to be overwritten");
24-
return true;
25-
}
17+
bugsnag.addOnError((event) -> {
18+
event.addMetadata("Custom", "test", "Global value");
19+
event.addMetadata("Custom", "foo", "Global value to be overwritten");
20+
return true;
2621
});
2722

2823
// Thread metadata on a different thread should not get added
29-
Thread t1 = new Thread(new Runnable() {
30-
@Override
31-
public void run() {
32-
Bugsnag.addThreadMetadata("Custom", "something", "This should not be on the report");
33-
}
34-
});
24+
Thread t1 = new Thread(() ->
25+
Bugsnag.addThreadMetadata(
26+
"Custom",
27+
"something",
28+
"This should not be on the report"
29+
)
30+
);
31+
3532
t1.start();
3633

3734
try {
@@ -40,14 +37,11 @@ public void run() {
4037
// ignore
4138
}
4239

43-
Thread t2 = new Thread(new Runnable() {
44-
@Override
45-
public void run() {
46-
// Thread metadata should merge with global metadata and overwrite when duplicate key
47-
Bugsnag.addThreadMetadata("Custom", "foo", "Thread value 1");
48-
Bugsnag.addThreadMetadata("Custom", "bar", "Thread value 2");
49-
throw new RuntimeException("UnhandledThreadMetadataScenario");
50-
}
40+
Thread t2 = new Thread(() -> {
41+
// Thread metadata should merge with global metadata and overwrite when duplicate key
42+
Bugsnag.addThreadMetadata("Custom", "foo", "Thread value 1");
43+
Bugsnag.addThreadMetadata("Custom", "bar", "Thread value 2");
44+
throw new RuntimeException("UnhandledThreadMetadataScenario");
5145
});
5246
t2.start();
5347

0 commit comments

Comments
 (0)