本文整理汇总了Java中reactor.core.publisher.Flux.just方法的典型用法代码示例。如果您正苦于以下问题:Java Flux.just方法的具体用法?Java Flux.just怎么用?Java Flux.just使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reactor.core.publisher.Flux
的用法示例。
在下文中一共展示了Flux.just方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDeepCrawling
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Test
public void getDeepCrawling() throws Exception {
String url = "http://localhost:8089/example";
WebsiteModel seedWebsite = new WebsiteModel();
seedWebsite.setUrl(url);
Flux<WebsiteModel> flux = Flux.just(seedWebsite);
given(crawlerBatchService.getWebsites(
seedWebsite,
null,
new URI(url),
0
)).willReturn(flux);
given(this.amazonDynamoDBAsync.putItemAsync(this.putItemRequest(url, EStatus.PROCESSING)))
.willReturn(this.putItemResult(url, EStatus.PROCESSING));
given(this.amazonDynamoDBAsync.putItemAsync(this.putItemRequest(url, EStatus.COMPLETED)))
.willReturn(this.putItemResult(url, EStatus.COMPLETED));
crawlerBatchTask.getDeepCrawling(url);
}
示例2: getAllBooks
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@GetMapping("/books")
public Flux<List<Book>> getAllBooks() {
ArrayList<Book> books=new ArrayList<Book>();
books.add(new Book("Spring 5.0",1234l,"Packt Pub Publication",500,"Learn Spring", "T.M.Jog"));
books.add(new Book("Learn Modular Java",1234l,"Packt Pub Publication",500,"Learn java", "Author1"));
return Flux.just(books);
}
示例3: createFailedPublisher
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Publisher<Message> createFailedPublisher() {
ReactorTckGrpc.ReactorTckStub stub = ReactorTckGrpc.newReactorStub(channel);
Flux<Message> request = Flux.just(toMessage(TckService.KABOOM));
Mono<Message> publisher = stub.manyToOne(request);
return publisher.flux();
}
示例4: images
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@GetMapping(API_BASE_PATH + "/images")
Flux<Image> images() {
return Flux.just(
new Image("1", "learning-spring-boot-cover.jpg"),
new Image("2", "learning-spring-boot-2nd-edition-cover.jpg"),
new Image("3", "bazinga.png")
);
}
示例5: getWebsites
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<WebsiteModel> getWebsites(
WebsiteModel seedWebsite,
WebsiteModel parentWebsite,
URI currentUrl,
Integer depth
) {
if (depth == 0) urls = new ConcurrentHashMap<>();
if (depth > MAX_DEPTH) return Flux.just(seedWebsite);
return Flux.merge(
Flux.empty(),
Flux.from(this.getBody(currentUrl))
.flatMap((body) -> getWebsiteModel(seedWebsite, parentWebsite, currentUrl.toString(), body, depth))
.flatMap((website) -> getParsedUrl(website, seedWebsite.getUrl(), depth))
.flatMap((website) -> {
LOG.info(Utils.success.log_recursion, depth, seedWebsite.getUrl(), website.getUrl());
try
{
urls.put(website.getUrl(), website);
return getWebsites(seedWebsite, website.getParent(), new URI(website.getUrl()), depth + 1);
}
catch (URISyntaxException e)
{
LOG.error(e.getMessage());
return Flux.empty();
}
})
);
}
示例6: initData
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Bean
CommandLineRunner initData(ReactiveUserRepository personRepository) {
Flux<Person> people = Flux.just(
new Person("1", "Eric", "Foo", "Zh"),
new Person("2", "Raymond", "Bar", "B"),
new Person("3", "Paul", "Baz", "x")
);
return args -> {
personRepository.deleteAll().thenMany(personRepository.saveAll(people)).blockLast();
};
}
示例7: initData
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Bean
CommandLineRunner initData(ReactiveUserRepository personRepository) {
Flux<Person> people = Flux.just(
new Person("1", "Eric", "Foo","Zh"),
new Person("2", "Raymond", "Bar","B"),
new Person("3", "Paul", "Baz","x")
);
return args -> {
personRepository.deleteAll().thenMany(personRepository.saveAll(people)).blockLast();
};
}
示例8: manyToOne
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Test
public void manyToOne() {
ReactorGreeterGrpc.ReactorGreeterStub stub = ReactorGreeterGrpc.newReactorStub(channel);
Flux<HelloRequest> req = Flux.just(HelloRequest.getDefaultInstance());
Mono<HelloResponse> resp = stub.sayHelloReqStream(req);
StepVerifier.create(resp)
.verifyErrorMatches(t -> t instanceof StatusRuntimeException && ((StatusRuntimeException)t).getStatus().getCode() == Status.Code.CANCELLED);
}
示例9: allMessages
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@GetMapping
Flux<Message> allMessages(){
return Flux.just(
Message.builder().body("hello Spring 5").build(),
Message.builder().body("hello Spring Boot 2").build()
);
}
示例10: manyToOne
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Test
public void manyToOne() {
ReactorGreeterGrpc.ReactorGreeterStub stub = ReactorGreeterGrpc.newReactorStub(channel);
Flux<String> reactorRequest = Flux.just("A", "B", "C");
Mono<String> reactorResponse = stub.sayHelloReqStream(reactorRequest.map(this::toRequest)).map(this::fromResponse);
StepVerifier.create(reactorResponse)
.expectNext("Hello A and B and C")
.verifyComplete();
}
示例11: starters
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@RequestMapping(value = "/starters")
public Flux<BootStarter> starters() {
return Flux.just(new BootStarter("spring-boot-starter-web-reactive", "Spring Boot Web Reactive"),
new BootStarter("spring-boot-starter-web", "Spring Boot Web"),
new BootStarter("spring-boot-starter-websocket", "Spring Boot Websocket"));
}
示例12: extract
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
private Flux<?> extract(Object input) {
if (input instanceof Collection) {
return Flux.fromIterable((Iterable<?>) input);
}
return Flux.just(input);
}
示例13: fluxShouldMapValueToUpperCaseHelloWorld
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Test
public void fluxShouldMapValueToUpperCaseHelloWorld() {
Flux<String> flux = Flux.just("Mike", "Gustavo");
flux = flux.map(String::toUpperCase);
StepVerifier.create(flux).expectNext("MIKE", "GUSTAVO").verifyComplete();
}
示例14: adoptFluxToRxJava2Flowable
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Test
public void adoptFluxToRxJava2Flowable() throws Exception {
Flux<String> people = Flux.just("Jesse", "Hank");
Flowable<String> flowable = Flowable.fromPublisher(people);
flowable.test().await().assertResult("Jesse", "Hank").awaitTerminalEvent();
}