Skip to content

Instantly share code, notes, and snippets.

//First observer. takes 1 ms to process each element
integerFlux.delayElements(Duration.ofMillis(1)).subscribe(i -> System.out.println("First :: " + i));
//Second observer. takes 2 ms to process each element
integerFlux.delayElements(Duration.ofMillis(2)).subscribe(i -> System.out.println("Second:: " + i));
Flux<Integer> integerFlux = Flux.create((FluxSink<Integer> fluxSink) -> {
IntStream.range(0, 5)
.peek(i -> System.out.println("going to emit - " + i))
.forEach(fluxSink::next);
});
//our movie theatre
//each scene will play for 2 seconds
Flux<String> movieTheatre = Flux.fromStream(() -> getMovie())
.delayElements(Duration.ofSeconds(2))
.share();
// you start watching the movie
movieTheatre.subscribe(scene -> System.out.println("You are watching " + scene));
//I join after sometime
//our NetFlux streamer
//each scene will play for 2 seconds
Flux<String> netFlux = Flux.fromStream(() -> getMovie())
.delayElements(Duration.ofSeconds(2));
// you start watching the movie
netFlux.subscribe(scene -> System.out.println("You are watching " + scene));
//I join after sometime
Thread.sleep(5000);
private Stream<String> getMovie(){
System.out.println("Got the movie streaming request");
return Stream.of(
"scene 1",
"scene 2",
"scene 3",
"scene 4",
"scene 5"
);
}
private int getDataToBePublished(){
System.out.println("getDataToBePublished was called");
return 1;
}
<suite name="TesTautomationGuru">
<test name="Testcase Description 1">
<parameter name="Data" value="data1" />
<classes>
<class name="com.testautomationguru.test.Test1" />
<class name="com.testautomationguru.test.Test2" />
</classes>
</test>
<test name="Testcase Description 2">
<parameter name="Data" value="data2" />
XLSReader suite = new XLSReader("tests.xls");
suite.getTests("select * from TestCase where module='Order'");
public class XLSReader {
private final Fillo fillo;
private final String filePath;
private Connection connection;
public XLSReader(String filePath) {
fillo = new Fillo();
this.filePath = filePath;
@JacksonXmlRootElement(localName = "suite")
public class Suite {
@JacksonXmlProperty(isAttribute = true)
private String name;
@JacksonXmlProperty(localName = "test")
@JacksonXmlElementWrapper(useWrapping = false)
private List < Test > tests;