Skip to content

Commit 7395af0

Browse files
committed
Get rid of tryEmit in tests
1 parent b797e40 commit 7395af0

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

services/src/test/java/io/scalecube/services/ServiceLocalTest.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import static org.junit.jupiter.api.Assertions.assertThrows;
55
import static org.junit.jupiter.api.Assertions.assertTrue;
6+
import static reactor.core.publisher.Sinks.EmitFailureHandler.FAIL_FAST;
67

78
import io.scalecube.services.api.ServiceMessage;
89
import io.scalecube.services.sut.GreetingRequest;
@@ -292,8 +293,8 @@ public void test_local_bidi_greeting_expect_NotAuthorized() {
292293

293294
// call the service.
294295

295-
requests.tryEmitNext(new GreetingRequest("joe-1"));
296-
requests.tryEmitComplete();
296+
requests.emitNext(new GreetingRequest("joe-1"), FAIL_FAST);
297+
requests.emitComplete(FAIL_FAST);
297298

298299
StepVerifier.create(responses)
299300
.expectErrorMessage("Not authorized")
@@ -318,7 +319,7 @@ public void test_local_bidi_greeting_message_expect_NotAuthorized() {
318319
.map(ServiceMessage::data);
319320

320321
StepVerifier.create(responses)
321-
.then(() -> requests.tryEmitNext(new GreetingRequest("joe-1")))
322+
.then(() -> requests.emitNext(new GreetingRequest("joe-1"), FAIL_FAST))
322323
.expectErrorMessage("Not authorized")
323324
.verify(Duration.ofSeconds(3));
324325
}
@@ -332,10 +333,10 @@ public void test_local_bidi_greeting_expect_GreetingResponse() {
332333

333334
// call the service.
334335

335-
requests.tryEmitNext(new GreetingRequest("joe-1"));
336-
requests.tryEmitNext(new GreetingRequest("joe-2"));
337-
requests.tryEmitNext(new GreetingRequest("joe-3"));
338-
requests.tryEmitComplete();
336+
requests.emitNext(new GreetingRequest("joe-1"), FAIL_FAST);
337+
requests.emitNext(new GreetingRequest("joe-2"), FAIL_FAST);
338+
requests.emitNext(new GreetingRequest("joe-3"), FAIL_FAST);
339+
requests.emitComplete(FAIL_FAST);
339340

340341
// call the service.
341342
Flux<GreetingResponse> responses =
@@ -366,13 +367,13 @@ public void test_local_bidi_greeting_expect_message_GreetingResponse() {
366367
.map(ServiceMessage::data);
367368

368369
StepVerifier.create(responses)
369-
.then(() -> requests.tryEmitNext(new GreetingRequest("joe-1")))
370+
.then(() -> requests.emitNext(new GreetingRequest("joe-1"), FAIL_FAST))
370371
.expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-1"))
371-
.then(() -> requests.tryEmitNext(new GreetingRequest("joe-2")))
372+
.then(() -> requests.emitNext(new GreetingRequest("joe-2"), FAIL_FAST))
372373
.expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-2"))
373-
.then(() -> requests.tryEmitNext(new GreetingRequest("joe-3")))
374+
.then(() -> requests.emitNext(new GreetingRequest("joe-3"), FAIL_FAST))
374375
.expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-3"))
375-
.then(requests::tryEmitComplete)
376+
.then(() -> requests.emitComplete(FAIL_FAST))
376377
.expectComplete()
377378
.verify(Duration.ofSeconds(3));
378379
}

services/src/test/java/io/scalecube/services/ServiceRemoteTest.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import static org.junit.jupiter.api.Assertions.assertThrows;
55
import static org.junit.jupiter.api.Assertions.assertTrue;
6+
import static reactor.core.publisher.Sinks.EmitFailureHandler.FAIL_FAST;
67

78
import io.scalecube.net.Address;
89
import io.scalecube.services.api.ServiceMessage;
@@ -404,8 +405,8 @@ public void test_remote_bidi_greeting_expect_NotAuthorized() {
404405

405406
// call the service.
406407

407-
requests.tryEmitNext(new GreetingRequest("joe-1"));
408-
requests.tryEmitComplete();
408+
requests.emitNext(new GreetingRequest("joe-1"), FAIL_FAST);
409+
requests.emitComplete(FAIL_FAST);
409410

410411
StepVerifier.create(responses)
411412
.expectErrorMessage("Not authorized")
@@ -431,7 +432,7 @@ public void test_remote_bidi_greeting_message_expect_NotAuthorized() {
431432
.map(ServiceMessage::data);
432433

433434
StepVerifier.create(responses)
434-
.then(() -> requests.tryEmitNext(new GreetingRequest("joe-1")))
435+
.then(() -> requests.emitNext(new GreetingRequest("joe-1"), FAIL_FAST))
435436
.expectErrorMessage("Not authorized")
436437
.verify(Duration.ofSeconds(3));
437438
}
@@ -446,10 +447,10 @@ public void test_remote_bidi_greeting_expect_GreetingResponse() {
446447

447448
// call the service.
448449

449-
requests.tryEmitNext(new GreetingRequest("joe-1"));
450-
requests.tryEmitNext(new GreetingRequest("joe-2"));
451-
requests.tryEmitNext(new GreetingRequest("joe-3"));
452-
requests.tryEmitComplete();
450+
requests.emitNext(new GreetingRequest("joe-1"), FAIL_FAST);
451+
requests.emitNext(new GreetingRequest("joe-2"), FAIL_FAST);
452+
requests.emitNext(new GreetingRequest("joe-3"), FAIL_FAST);
453+
requests.emitComplete(FAIL_FAST);
453454

454455
// call the service.
455456
Flux<GreetingResponse> responses =
@@ -482,13 +483,13 @@ public void test_remote_bidi_greeting_message_expect_GreetingResponse() {
482483
.map(ServiceMessage::data);
483484

484485
StepVerifier.create(responses)
485-
.then(() -> requests.tryEmitNext(new GreetingRequest("joe-1")))
486+
.then(() -> requests.emitNext(new GreetingRequest("joe-1"), FAIL_FAST))
486487
.expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-1"))
487-
.then(() -> requests.tryEmitNext(new GreetingRequest("joe-2")))
488+
.then(() -> requests.emitNext(new GreetingRequest("joe-2"), FAIL_FAST))
488489
.expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-2"))
489-
.then(() -> requests.tryEmitNext(new GreetingRequest("joe-3")))
490+
.then(() -> requests.emitNext(new GreetingRequest("joe-3"), FAIL_FAST))
490491
.expectNextMatches(resp -> resp.getResult().equals(" hello to: joe-3"))
491-
.then(requests::tryEmitComplete)
492+
.then(() -> requests.emitComplete(FAIL_FAST))
492493
.expectComplete()
493494
.verify(Duration.ofSeconds(3));
494495
}

0 commit comments

Comments
 (0)