Refactor (#2538)
This commit is contained in:
committed by
GitHub
parent
89927e4620
commit
6d6b24590f
@@ -20,16 +20,16 @@ import java.time.ZonedDateTime;
|
||||
import static com.baeldung.weather.MetaWeatherClient.getDataByPlaceId;
|
||||
import static com.baeldung.weather.MetaWeatherClient.searchByCityName;
|
||||
|
||||
public class VertxWithRxJavaTest {
|
||||
public class VertxWithRxJavaIntegrationTest {
|
||||
|
||||
private Vertx vertx;
|
||||
private HttpClient httpClient;
|
||||
private FileSystem fileSystem;
|
||||
private static Logger log = LoggerFactory.getLogger(VertxWithRxJavaTest.class);
|
||||
private static Logger log = LoggerFactory.getLogger(VertxWithRxJavaIntegrationTest.class);
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
vertx = io.vertx.reactivex.core.Vertx.vertx();
|
||||
vertx = Vertx.vertx();
|
||||
httpClient = vertx.createHttpClient();
|
||||
fileSystem = vertx.fileSystem();
|
||||
}
|
||||
@@ -45,18 +45,18 @@ public class VertxWithRxJavaTest {
|
||||
// read the file that contains one city name per line
|
||||
fileSystem
|
||||
.rxReadFile("cities.txt").toFlowable()
|
||||
.doOnNext(buffer -> log.info("File buffer ---\n{}\n---", buffer))
|
||||
.doOnNext(buffer -> log.info("File buffer ---\n{}\n---", buffer))
|
||||
.flatMap(buffer -> Flowable.fromArray(buffer.toString().split("\\r?\\n")))
|
||||
.doOnNext(city -> log.info("City from file: '{}'", city))
|
||||
.doOnNext(city -> log.info("City from file: '{}'", city))
|
||||
.filter(city -> !city.startsWith("#"))
|
||||
.doOnNext(city -> log.info("City that survived filtering: '{}'", city))
|
||||
.doOnNext(city -> log.info("City that survived filtering: '{}'", city))
|
||||
.flatMap(city -> searchByCityName(httpClient, city))
|
||||
.flatMap(HttpClientResponse::toFlowable)
|
||||
.doOnNext(buffer -> log.info("JSON of city detail: '{}'", buffer))
|
||||
.doOnNext(buffer -> log.info("JSON of city detail: '{}'", buffer))
|
||||
.map(extractingWoeid())
|
||||
.flatMap(cityId -> getDataByPlaceId(httpClient, cityId))
|
||||
.flatMap(toBufferFlowable())
|
||||
.doOnNext(buffer -> log.info("JSON of place detail: '{}'", buffer))
|
||||
.doOnNext(buffer -> log.info("JSON of place detail: '{}'", buffer))
|
||||
.map(Buffer::toJsonObject)
|
||||
.map(toCityAndDayLength())
|
||||
.subscribe(System.out::println, Throwable::printStackTrace);
|
||||
Reference in New Issue
Block a user