2
2
3
3
import com .exceptionless .exceptionlessclient .TestFixtures ;
4
4
import com .exceptionless .exceptionlessclient .configuration .Configuration ;
5
- import com .exceptionless .exceptionlessclient .exceptions .ClientException ;
5
+ import com .exceptionless .exceptionlessclient .exceptions .SubmissionException ;
6
6
import com .exceptionless .exceptionlessclient .models .Event ;
7
7
import com .exceptionless .exceptionlessclient .models .submission .SubmissionResponse ;
8
8
import com .exceptionless .exceptionlessclient .storage .InMemoryStorage ;
@@ -64,10 +64,10 @@ public void itCanProcessABatchSuccessfully() {
64
64
65
65
SubmissionResponse response =
66
66
SubmissionResponse .builder ().message ("test-message" ).statusCode (200 ).build ();
67
- doReturn (response ).when (submissionClient ).postEvents (List .of (event ), false );
67
+ doReturn (response ).when (submissionClient ).postEvents (List .of (event ));
68
68
69
69
queue .onEventsPosted (testHandler );
70
- queue .process (false );
70
+ queue .process ();
71
71
72
72
assertThat (storage .peek ()).isNull ();
73
73
verify (testHandler , times (1 )).accept (List .of (event ), response );
@@ -87,11 +87,11 @@ public void itShouldNotProcessIfCurrentlyProcessingEvents()
87
87
return response ;
88
88
})
89
89
.when (submissionClient )
90
- .postEvents (List .of (event ), false );
90
+ .postEvents (List .of (event ));
91
91
92
92
queue .onEventsPosted (testHandler );
93
- Future <?> future = Executors .newSingleThreadExecutor ().submit (() -> queue .process (false ));
94
- queue .process (false );
93
+ Future <?> future = Executors .newSingleThreadExecutor ().submit (() -> queue .process ());
94
+ queue .process ();
95
95
future .get ();
96
96
97
97
assertThat (storage .get (2 )).hasSize (1 ); // Only one is processed
@@ -101,7 +101,7 @@ public void itShouldNotProcessIfCurrentlyProcessingEvents()
101
101
@ Test
102
102
public void itShouldNotPostEmptyEvents () {
103
103
queue .onEventsPosted (testHandler );
104
- queue .process (false );
104
+ queue .process ();
105
105
106
106
verifyZeroInteractions (submissionClient );
107
107
verifyZeroInteractions (testHandler );
@@ -111,10 +111,10 @@ public void itShouldNotPostEmptyEvents() {
111
111
public void itShouldSuspendProcessingOnClientException () {
112
112
storage .save (event );
113
113
114
- doThrow (new ClientException ("test" )).when (submissionClient ).postEvents (List .of (event ), false );
114
+ doThrow (new SubmissionException ("test" )).when (submissionClient ).postEvents (List .of (event ));
115
115
116
116
queue .onEventsPosted (testHandler );
117
- queue .process (false );
117
+ queue .process ();
118
118
119
119
assertThat (queue .isProcessingCurrentlySuspended ()).isTrue ();
120
120
assertThat (storage .peek ().getValue ()).isEqualTo (event );
@@ -127,10 +127,10 @@ public void itShouldSuspendProcessingIfServiceIsUnavailable() {
127
127
128
128
SubmissionResponse response =
129
129
SubmissionResponse .builder ().message ("test-message" ).statusCode (503 ).build ();
130
- doReturn (response ).when (submissionClient ).postEvents (List .of (event ), false );
130
+ doReturn (response ).when (submissionClient ).postEvents (List .of (event ));
131
131
132
132
queue .onEventsPosted (testHandler );
133
- queue .process (false );
133
+ queue .process ();
134
134
135
135
assertThat (queue .isProcessingCurrentlySuspended ()).isTrue ();
136
136
assertThat (storage .peek ().getValue ()).isEqualTo (event );
@@ -143,10 +143,10 @@ public void itShouldSuspendAndDiscardProcessingAndClearQueueIfNoPayment() {
143
143
144
144
SubmissionResponse response =
145
145
SubmissionResponse .builder ().message ("test-message" ).statusCode (402 ).build ();
146
- doReturn (response ).when (submissionClient ).postEvents (List .of (event ), false );
146
+ doReturn (response ).when (submissionClient ).postEvents (List .of (event ));
147
147
148
148
queue .onEventsPosted (testHandler );
149
- queue .process (false );
149
+ queue .process ();
150
150
151
151
assertThat (queue .isProcessingCurrentlySuspended ()).isTrue ();
152
152
assertThat (storage .peek ()).isNull (); // queue is cleared
@@ -163,10 +163,10 @@ public void itShouldSuspendProcessingAndClearQueueIfUnableToAuthenticate() {
163
163
164
164
SubmissionResponse response =
165
165
SubmissionResponse .builder ().message ("test-message" ).statusCode (401 ).build ();
166
- doReturn (response ).when (submissionClient ).postEvents (List .of (event ), false );
166
+ doReturn (response ).when (submissionClient ).postEvents (List .of (event ));
167
167
168
168
queue .onEventsPosted (testHandler );
169
- queue .process (false );
169
+ queue .process ();
170
170
171
171
assertThat (queue .isProcessingCurrentlySuspended ()).isTrue ();
172
172
assertThat (storage .peek ()).isNull (); // queue is cleared
@@ -179,10 +179,10 @@ public void itShouldSuspendProcessingAndClearQueueForNotFoundResponse() {
179
179
180
180
SubmissionResponse response =
181
181
SubmissionResponse .builder ().message ("test-message" ).statusCode (404 ).build ();
182
- doReturn (response ).when (submissionClient ).postEvents (List .of (event ), false );
182
+ doReturn (response ).when (submissionClient ).postEvents (List .of (event ));
183
183
184
184
queue .onEventsPosted (testHandler );
185
- queue .process (false );
185
+ queue .process ();
186
186
187
187
assertThat (queue .isProcessingCurrentlySuspended ()).isTrue ();
188
188
assertThat (storage .peek ()).isNull (); // queue is cleared
@@ -195,10 +195,10 @@ public void itShouldSuspendProcessingAndClearQueueForBadRequest() {
195
195
196
196
SubmissionResponse response =
197
197
SubmissionResponse .builder ().message ("test-message" ).statusCode (400 ).build ();
198
- doReturn (response ).when (submissionClient ).postEvents (List .of (event ), false );
198
+ doReturn (response ).when (submissionClient ).postEvents (List .of (event ));
199
199
200
200
queue .onEventsPosted (testHandler );
201
- queue .process (false );
201
+ queue .process ();
202
202
203
203
assertThat (queue .isProcessingCurrentlySuspended ()).isTrue ();
204
204
assertThat (storage .peek ()).isNull (); // queue is cleared
@@ -211,10 +211,10 @@ public void itShouldSuspendProcessingByDefault() {
211
211
212
212
SubmissionResponse response =
213
213
SubmissionResponse .builder ().message ("test-message" ).statusCode (-1 ).build ();
214
- doReturn (response ).when (submissionClient ).postEvents (List .of (event ), false );
214
+ doReturn (response ).when (submissionClient ).postEvents (List .of (event ));
215
215
216
216
queue .onEventsPosted (testHandler );
217
- queue .process (false );
217
+ queue .process ();
218
218
219
219
assertThat (queue .isProcessingCurrentlySuspended ()).isTrue ();
220
220
assertThat (storage .peek ().getValue ()).isEqualTo (event );
@@ -239,22 +239,22 @@ public void itShouldReduceSubmissionBatchSizeIfRequestEntitiesAreTooLarge() {
239
239
240
240
SubmissionResponse response =
241
241
SubmissionResponse .builder ().message ("test-message" ).statusCode (413 ).build ();
242
- doReturn (response ).when (submissionClient ).postEvents (anyList (), anyBoolean () );
242
+ doReturn (response ).when (submissionClient ).postEvents (anyList ());
243
243
244
244
queue .onEventsPosted (testHandler );
245
- queue .process (false );
245
+ queue .process ();
246
246
247
247
assertThat (storage .get (10 )).hasSize (10 );
248
248
verify (testHandler , times (1 )).accept (anyList (), eq (response ));
249
249
250
- queue .process (false );
250
+ queue .process ();
251
251
252
252
// One invocation with full batch
253
253
verify (submissionClient , times (1 ))
254
- .postEvents (argThat (argument -> argument .size () == 3 ), anyBoolean () );
254
+ .postEvents (argThat (argument -> argument .size () == 3 ));
255
255
// One invocation with reduced batch
256
256
verify (submissionClient , times (1 ))
257
- .postEvents (argThat (argument -> argument .size () == 2 ), anyBoolean () );
257
+ .postEvents (argThat (argument -> argument .size () == 2 ));
258
258
}
259
259
260
260
@ Test
@@ -265,10 +265,10 @@ public void itShouldDiscardEventsIfItCantReduceSubmissionSizeAndRequestEntitiesA
265
265
266
266
SubmissionResponse response =
267
267
SubmissionResponse .builder ().message ("test-message" ).statusCode (413 ).build ();
268
- doReturn (response ).when (submissionClient ).postEvents (anyList (), anyBoolean () );
268
+ doReturn (response ).when (submissionClient ).postEvents (anyList ());
269
269
270
270
queue .onEventsPosted (testHandler );
271
- queue .process (false );
271
+ queue .process ();
272
272
273
273
assertThat (storage .get (10 )).hasSize (9 );
274
274
verify (testHandler , times (1 )).accept (anyList (), eq (response ));
@@ -292,30 +292,30 @@ public void itShouldResetSubmissionBatchSizeOnNextSuccessfulResponse() {
292
292
293
293
doReturn (SubmissionResponse .builder ().message ("test-message" ).statusCode (413 ).build ())
294
294
.when (submissionClient )
295
- .postEvents (anyList (), anyBoolean () );
296
- queue .process (false );
295
+ .postEvents (anyList ());
296
+ queue .process ();
297
297
298
298
doReturn (SubmissionResponse .builder ().message ("test-message" ).statusCode (200 ).build ())
299
299
.when (submissionClient )
300
- .postEvents (anyList (), anyBoolean () );
301
- queue .process (false );
302
- queue .process (false );
300
+ .postEvents (anyList ());
301
+ queue .process ();
302
+ queue .process ();
303
303
304
304
// Two invocations with full batch; First with the default size and next after a successful
305
305
// response
306
306
verify (submissionClient , times (2 ))
307
- .postEvents (argThat (argument -> argument .size () == 3 ), anyBoolean () );
307
+ .postEvents (argThat (argument -> argument .size () == 3 ));
308
308
// One invocation with reduced batch
309
309
verify (submissionClient , times (1 ))
310
- .postEvents (argThat (argument -> argument .size () == 2 ), anyBoolean () );
310
+ .postEvents (argThat (argument -> argument .size () == 2 ));
311
311
}
312
312
313
313
@ Test
314
314
public void itShouldProcessEventsUsingTimer () throws InterruptedException {
315
315
storage .save (event );
316
316
SubmissionResponse response =
317
317
SubmissionResponse .builder ().message ("test-message" ).statusCode (200 ).build ();
318
- doReturn (response ).when (submissionClient ).postEvents (List .of (event ), false );
318
+ doReturn (response ).when (submissionClient ).postEvents (List .of (event ));
319
319
320
320
Configuration configuration =
321
321
TestFixtures .aDefaultConfiguration ().submissionBatchSize (1 ).build ();
0 commit comments