forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Qute - build the reactive part of the API on top of Mutiny
- add TemplateInstance.createMulti() - get rid of io.quarkus.qute.PublisherFactory - resolves quarkusio#10457
- Loading branch information
Showing
18 changed files
with
89 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
independent-projects/qute/core/src/main/java/io/quarkus/qute/PublisherFactory.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 9 additions & 17 deletions
26
...ouba/qute/mutiny/SimplePublisherTest.java → ...java/io/quarkus/qute/CreateMultiTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,41 @@ | ||
package com.github.mkouba.qute.mutiny; | ||
package io.quarkus.qute; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import io.quarkus.qute.Engine; | ||
import io.quarkus.qute.Template; | ||
import io.smallrye.mutiny.Multi; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.function.Supplier; | ||
import org.junit.jupiter.api.Test; | ||
import org.reactivestreams.Publisher; | ||
|
||
public class SimplePublisherTest { | ||
public class CreateMultiTest { | ||
|
||
@Test | ||
public void test() throws InterruptedException { | ||
Engine engine = Engine.builder().addDefaultSectionHelpers().addDefaultValueResolvers().build(); | ||
Template template = engine.parse("{#each}{it}{/}"); | ||
List<String> data = Arrays.asList("foo", "foo", "alpha"); | ||
Publisher<String> publisher = template.instance().data(data).publisher(); | ||
Multi<String> multi = template.instance().data(data).createMulti(); | ||
|
||
assertPublisher(() -> Multi.createFrom().publisher(publisher), "foofooalpha"); | ||
assertPublisher(() -> Multi.createFrom().publisher(publisher) | ||
.transform().byDroppingDuplicates(), "fooalpha"); | ||
assertPublisher(() -> Multi.createFrom().publisher(publisher) | ||
.transform().byTakingFirstItems(1), "foo"); | ||
assertMulti(multi, "foofooalpha"); | ||
assertMulti(multi.transform().byDroppingDuplicates(), "fooalpha"); | ||
assertMulti(multi.transform().byTakingFirstItems(1), "foo"); | ||
} | ||
|
||
private void assertPublisher(Supplier<Publisher<String>> test, String expected) throws InterruptedException { | ||
private void assertMulti(Multi<String> multi, String expected) throws InterruptedException { | ||
StringBuilder builder = new StringBuilder(); | ||
CountDownLatch latch = new CountDownLatch(1); | ||
|
||
Multi.createFrom().publisher(test.get()) | ||
multi | ||
.subscribe().with( | ||
builder::append, | ||
latch::countDown); | ||
|
||
if (latch.await(2, TimeUnit.SECONDS)) { | ||
assertEquals(expected, builder.toString()); | ||
} else { | ||
fail(); | ||
} | ||
} | ||
|
||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.