Giter Club home page Giter Club logo

lite-rx-api-hands-on's Introduction

Lite Rx API Hands-on

This Hands-on is designed to help you to learn easily the lite Rx API provided by Reactor Core 3.x.

You will mostly need these 3 classes Javadoc:

To do this Hands-on, you just have to:

  • Have Java 8 and a Java IDE (IntelliJ IDEA for example) installed with Maven support
  • Clone this repository (or your fork)
  • Import the project as a Maven one in your IDE
  • Make sure that the language level is set to Java 8 in your IDE project settings
  • Fix the TODO one by one in Part01 to Part11 main classes in io.pivotal.literx package to make unit tests green (you can have a look at the unit tests too if you want)

The solution is available in the solution branch to compare, when you have finished, with what you have done.

A Kotlin version that takes advantage of reactor-kotlin-extensions is available here.

More information available on Reactor website.

lite-rx-api-hands-on's People

Contributors

aclement avatar aneveu avatar bclozel avatar chrosciu avatar dependabot[bot] avatar dmedinag avatar izeye avatar mohamedibrahim54 avatar paweusz avatar pyvesb avatar rohanmukesh avatar sdeleuze avatar simonbasle avatar smaldini avatar snicoll avatar thenanox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lite-rx-api-hands-on's Issues

In part03, expectElementsWithThenComplete

In my test code, I checked User with expectNext.
Like the following:

void expectSkylerJesseComplete(Flux<User> flux) {
		StepVerifier.create(flux).expectNext(new User("swhite", null, null),
				new User("jpinkman", null, null))
				.expectComplete().verify();
		//fail();
	}

But I got an error:

java.lang.AssertionError: expectation failed (failed running expectation on signal [onNext(Person{username='swhite', firstname='null', lastname='null'})] with [java.lang.NullPointerException]:
)

	at reactor.test.DefaultStepVerifierBuilder.failPrefix(DefaultStepVerifierBuilder.java:1679)
	at reactor.test.DefaultStepVerifierBuilder.fail(DefaultStepVerifierBuilder.java:1675)
	at reactor.test.DefaultStepVerifierBuilder$DefaultVerifySubscriber.onExpectation(DefaultStepVerifierBuilder.java:1017)
	at reactor.test.DefaultStepVerifierBuilder$DefaultVerifySubscriber.onNext(DefaultStepVerifierBuilder.java:764)
	at reactor.core.publisher.FluxArray$ArraySubscription.fastPath(FluxArray.java:164)
	at reactor.core.publisher.FluxArray$ArraySubscription.request(FluxArray.java:90)
	at reactor.test.DefaultStepVerifierBuilder$DefaultVerifySubscriber.onSubscribe(DefaultStepVerifierBuilder.java:781)
	at reactor.core.publisher.FluxArray.subscribe(FluxArray.java:55)
	at reactor.core.publisher.FluxArray.subscribe(FluxArray.java:61)
	at reactor.test.DefaultStepVerifierBuilder$DefaultStepVerifier.verify(DefaultStepVerifierBuilder.java:532)
	at reactor.test.DefaultStepVerifierBuilder$DefaultStepVerifier.verify(DefaultStepVerifierBuilder.java:508)
	at io.pivotal.literx.Part03StepVerifier.expectSkylerJesseComplete(Part03StepVerifier.java:74)
	at io.pivotal.literx.Part03StepVerifier.expectElementsWithThenComplete(Part03StepVerifier.java:66)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

why expectNext("foo", "bar") in expect2ElementsThenError is alright?

Reactor 3.0.6 update

An update to Reactor 3.0.6 apparently breaks Part 11.

It seems the choice of the parallel scheduler is not the right one, since it's designed for CPU-bound tasks. In that case , an elastic Scheduler (for blocking) operations is a better choice.

Could not find the artifact `reactor-bom:pom:Bismuth-BUILD-SNAPSHOT`

Hi,

With the change in pom.xml on f8f68da, build fails since it can not find the artifact io.projectreactor:reactor-bom:pom:Bismuth-BUILD-SNAPSHOT.

Builds successfully when I revert the previous version of pom.xml.

[INFO] Scanning for projects...
Downloading: https://repo.spring.io/milestone/io/projectreactor/reactor-bom/Bismuth-BUILD-SNAPSHOT/maven-metadata.xml
Downloading: https://repo.spring.io/milestone/io/projectreactor/reactor-bom/Bismuth-BUILD-SNAPSHOT/reactor-bom-Bismuth-BUILD-SNAPSHOT.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Non-resolvable import POM: Could not find artifact io.projectreactor:reactor-bom:pom:Bismuth-BUILD-SNAPSHOT in spring-milestones (https://repo.spring.io/milestone) @ line 92, column 16
[ERROR] 'dependencies.dependency.version' for io.projectreactor:reactor-core:jar is missing. @ line 35, column 15
[ERROR] 'dependencies.dependency.version' for io.projectreactor:reactor-test:jar is missing. @ line 39, column 15
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project io.pivotal:lite-rx-api-hands-on:1.1.0-SNAPSHOT (/home/sedat/Desktop/code/lite-rx-api-hands-on/pom.xml) has 3 errors
[ERROR] Non-resolvable import POM: Could not find artifact io.projectreactor:reactor-bom:pom:Bismuth-BUILD-SNAPSHOT in spring-milestones (https://repo.spring.io/milestone) @ line 92, column 16 -> [Help 2]
[ERROR] 'dependencies.dependency.version' for io.projectreactor:reactor-core:jar is missing. @ line 35, column 15
[ERROR] 'dependencies.dependency.version' for io.projectreactor:reactor-test:jar is missing. @ line 39, column 15
[ERROR]

Cannot build: Malformed POM .../pom.xml: expected START_TAG or END_TAG not TEXT (position: TEXT seen ...<snapshots>true</...

When I try to build this project using the provided ./mvnw script, I receive the following error:

$ ./mvnw package
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Malformed POM <blah>/lite-rx-api-hands-on/pom.xml: expected START_TAG or END_TAG not TEXT (position: TEXT seen ...<snapshots>true</... @66:21)  @ <blah>/lite-rx-api-hands-on/pom.xml, line 66, column 21
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project io.pivotal:lite-rx-api-hands-on:1.0.0-SNAPSHOT (<blah>/lite-rx-api-hands-on/pom.xml) has 1 error
[ERROR]     Malformed POM <blah>/lite-rx-api-hands-on/pom.xml: expected START_TAG or END_TAG not TEXT (position: TEXT seen ...<snapshots>true</... @66:21)  @ <blah>/lite-rx-api-hands-on/pom.xml, line 66, column 21 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException

Any idea what could be causing this?

Add `Flux.collect...()` method exercise

Motivation

As currently there's no exercise for Flux.collect...() methods I thought that at least one case could be helpful.

Desired solution

I'd like to add method testing Flux.collectList():

	// TODO Convert the input Flux<User> to a Mono<List<User>> containing list of collected flux values
	Mono<List<User>> fluxCollection(Flux<User> flux) {
		return flux.collectList(); // TO BE REMOVED
	}

to Part08OtherOperations class.

Considered alternatives

Adding entire family of Flux.collect...() methods would be probably overkill.
One should be enough to signal existence of those.

Part06Request fluxWithDoOnPrintln failing due to logger

Expected Behavior

Below fluxWithDoOnPrintln implementation is failing due to a logger statement. The logger is appending the below line to the console.

DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework

Flux<User> fluxWithDoOnPrintln() {
	return repository.findAll().doOnSubscribe(a -> System.out.println("Starring:"))
			.doOnNext(user -> System.out.println(String.format("%s %s", user.getFirstname(), user.getLastname())))
			.doOnComplete(() -> System.out.println("The end!")); //TODO: Disable logger
}

Logs:

org.opentest4j.AssertionFailedError: 
Expecting:
 <"21:18:16.820 [main] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
Starring:
Skyler White
Jesse Pinkman
Walter White
Saul Goodman
The end!
">
to be equal to:
 <"Starring:
Skyler White
Jesse Pinkman
Walter White
Saul Goodman
The end!
">

NCDFE: org/junit/runner/notification/RunListener on https://tech.io/playgrounds/929/reactive-programming-with-reactor-3

Exception in thread "main" java.lang.NoClassDefFoundError: org/junit/runner/notification/RunListener
while using https://tech.io/playgrounds/929/reactive-programming-with-reactor-3/Flux

Expected Behavior

I would like to be able to play with https://tech.io/playgrounds/929/reactive-programming-with-reactor-3/

Actual Behavior

while submitting "Run" on any button of https://tech.io/playgrounds/929/reactive-programming-with-reactor-3/Flux a NCDFE "org/junit/runner/notification/RunListener " this make the tutorial almost unusable.

Steps to Reproduce

https://tech.io/playgrounds/929/reactive-programming-with-reactor-3/Flux and click on any "Run" button

Possible Solution

I suspect the runner https://github.com/TechDotIO/java-maven3-junit4-runner is used for this project but junit 4 class doesn't exists anymore on https://github.com/reactor/lite-rx-api-hands-on/tree/techio_course this lead to the NCDFE

I suspect this is due to #71

Possible solutions :

  • add junit4 jar as a dependency of the project
  • revert the PR on the "techio_course" branch.
  • provide a java-maven3-junit4-runner to https://github.com/TechDotIO

Is there a place to discuss solutions?

First of all thanks for this small project.
Nice idea to let people play with the api.

So for me in Part01 I implemented the simple tests ('empty', 'fromList', 'error', ... ). But 'countEachSecond' and 'neverTerminates' don't work with my implementation. Maybe I did not understand what I really have to implement, but in the end the Tests did not end with any result ('neverTerminates' become true in this case ;-), but I don't think that's what you had in mind). I would expect a 'fail' here.

Is there a place to discuss the solutions? Or do you plan more blog-posts for doing that?

Regards
Jörg

Part07 Error#betterCallSaulForBogusMono() better with onErrorReturn

Hi, I am learning reactor on tech.io. In the first test case, it prompts me to use onErrorReturn(), but solution branch uses onErrorResume(). Both methods are correct, i think it is better to use onErrorReturn() in this case.

In solution branch

Mono<User> betterCallSaulForBogusMono(Mono<User> mono) {
    return mono.onErrorResume(e -> Mono.just(User.SAUL)); // TO BE REMOVED
}

My solution

Mono<User> betterCallSaulForBogusMono(Mono<User> mono) {
    return mono.onErrorReturn(User.SAUL);
}

Great exercises!

This is not an issue, just a "thank you" for making these exercises available.

I came across them when trying to familiarise myself with reactor-kafka, and I must say I thoroughly enjoyed doing these foundation exercises. I love the Breaking Bad theme, by the way :)

Thanks again, and keep up the good work!

Add open source license

Documentation Issue

This repository does not have any open source license attached

Improvement Suggestion

Add a LICENSE file with an appropriate license, e.g. Apache-2.0 since that is used in the reactor-core project

Add Part00TestSubscriber

Should be nice to have some exercise to learn how to use TestSubscriberwith some provided Flux and Mono.

many unit test fails on jdk 11

for example, io.pivotal.literx.Part01FluxTest#fromValues

C:\j\bin\java.exe -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\lib\idea_rt.jar=49217:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\yang.lei.m2\repository\org\junit\platform\junit-platform-launcher\1.6.1\junit-platform-launcher-1.6.1.jar;C:\Users\yang.lei.m2\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;C:\Users\yang.lei.m2\repository\org\junit\platform\junit-platform-engine\1.6.1\junit-platform-engine-1.6.1.jar;C:\Users\yang.lei.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\yang.lei.m2\repository\org\junit\platform\junit-platform-commons\1.6.1\junit-platform-commons-1.6.1.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\lib\idea_rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\plugins\junit\lib\junit5-rt.jar;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.3\plugins\junit\lib\junit-rt.jar;C:\G\lite-rx-api-hands-on\target\test-classes;C:\G\lite-rx-api-hands-on\target\classes;C:\M\repository\io\projectreactor\reactor-core\3.3.4.RELEASE\reactor-core-3.3.4.RELEASE.jar;C:\M\repository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;C:\M\repository\io\projectreactor\reactor-test\3.3.4.RELEASE\reactor-test-3.3.4.RELEASE.jar;C:\M\repository\ch\qos\logback\logback-classic\1.1.3\logback-classic-1.1.3.jar;C:\M\repository\ch\qos\logback\logback-core\1.1.3\logback-core-1.1.3.jar;C:\M\repository\org\slf4j\slf4j-api\1.7.7\slf4j-api-1.7.7.jar;C:\M\repository\org\junit\jupiter\junit-jupiter\5.6.1\junit-jupiter-5.6.1.jar;C:\M\repository\org\junit\jupiter\junit-jupiter-api\5.6.1\junit-jupiter-api-5.6.1.jar;C:\M\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;C:\M\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\M\repository\org\junit\platform\junit-platform-commons\1.6.1\junit-platform-commons-1.6.1.jar;C:\M\repository\org\junit\jupiter\junit-jupiter-params\5.6.1\junit-jupiter-params-5.6.1.jar;C:\M\repository\org\junit\jupiter\junit-jupiter-engine\5.6.1\junit-jupiter-engine-5.6.1.jar;C:\M\repository\org\junit\platform\junit-platform-engine\1.6.1\junit-platform-engine-1.6.1.jar;C:\M\repository\io\reactivex\rxjava3\rxjava\3.0.1\rxjava-3.0.1.jar;C:\M\repository\org\assertj\assertj-core\3.15.0\assertj-core-3.15.0.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 io.pivotal.literx.Part01FluxTest,fromValues

java.lang.NullPointerException
at reactor.test.DefaultStepVerifierBuilder$DefaultStepVerifier.toVerifierAndSubscribe(DefaultStepVerifierBuilder.java:867)
at reactor.test.DefaultStepVerifierBuilder$DefaultStepVerifier.verify(DefaultStepVerifierBuilder.java:823)
at reactor.test.DefaultStepVerifierBuilder$DefaultStepVerifier.verify(DefaultStepVerifierBuilder.java:815)
at reactor.test.DefaultStepVerifierBuilder.verifyComplete(DefaultStepVerifierBuilder.java:682)
at io.pivotal.literx.Part01FluxTest.fromValues(Part01FluxTest.java:34)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:212)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:208)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)
at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)
at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

Process finished with exit code -1

Test for Mono.never() is ineffective

lite-rx-api-hands-on/src/test/java/io/pivotal/literx/Part02MonoTest.java
includes the test method below which passes even with my change so is ineffective.
Should the test be changed to register a doOnNext(fail())? Should StepVerifier have a better way of checking nothing produced from the Flux/Mono for a period?

@Test
	public void noSignal() {
		//Mono<String> mono = workshop.monoWithNoSignal();
                 Mono<String> mono = Mono.just("ShouldFail");
		StepVerifier
				.create(mono)
				.expectSubscription()
				.expectNoEvent(Duration.ofSeconds(1))
				.thenCancel()
				.verify();
	}  

Avoid platform-dependent line separator in part 06 assertions

In Part06Request there are two tests that assert multiple lines of logs as a single String.
The expected String in these assertions thus includes line separators, which happen to be platform dependent (explicit "\n" included).

The tests should be rewritten to avoid that, and the best way of doing so is to assert the logs as a List<String> (one per line) instead of a multi-line single String.

In the case of experimentWithLog():

  • split the stream's input on System.lineSeparator() rather than \n
  • don't join the filtered stream but collect to Collectors.toList(), thus turning the log variable into a List<String>
  • assert the list containsExactly each line of log (multiple strings without a \n)

In the case of experimentWithDoOn():

  • assert a splitted logConsole.toString(), on System.lineSeparator(), rather than a single unsplitted String`
  • assert it containsExactly 6 strings (one per line, without referring to the \n)

This change can be made on master and will be easily forward-merged to solution and techio_course, although it should be tested on solution locally.

Fast publisher slow subscriber solution isn't parallel

The solution for Part11-Blocking to Reactive solution does not really process the users in parallel. If the intent of the problem is to do the save operations in parallel, I believe this is what the code should look like:

Mono<Void> fluxToBlockingRepository(Flux<User> flux, BlockingRepository<User> repository) {
  return flux
    .parallel(8)
    .runOn(Schedulers.parallel())
    .doOnNext(repository::save)
    .sequential().then();
}

Or is the intent of the problem to just save users to the repository in a different thread from the main thread, without making it parallel? If so, why is Schedulers.parallel recommended over Schedulers.elastic?

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.