Search in sources :

Example 1 with Order

use of org.apache.flink.streaming.kinesis.test.model.Order in project flink by apache.

the class KinesisTableApiITCase method testTableApiSourceAndSink.

@Test
public void testTableApiSourceAndSink() throws Exception {
    List<Order> smallOrders = ImmutableList.of(new Order("A", 5), new Order("B", 10));
    // filter-large-orders.sql is supposed to preserve orders with quantity > 10
    List<Order> expected = ImmutableList.of(new Order("C", 15), new Order("D", 20), new Order("E", 25));
    smallOrders.forEach(order -> kinesisClient.sendMessage(ORDERS_STREAM, toJson(order)));
    expected.forEach(order -> kinesisClient.sendMessage(ORDERS_STREAM, toJson(order)));
    executeSqlStatements(readSqlFile("filter-large-orders.sql"));
    // result order is not guaranteed
    List<Order> result = readAllOrdersFromKinesis(kinesisClient);
    assertThat(result, Matchers.containsInAnyOrder(expected.toArray(new Order[0])));
}
Also used : Order(org.apache.flink.streaming.kinesis.test.model.Order) Test(org.junit.Test)

Example 2 with Order

use of org.apache.flink.streaming.kinesis.test.model.Order in project flink by apache.

the class KinesisTableApiITCase method readAllOrdersFromKinesis.

private List<Order> readAllOrdersFromKinesis(final KinesisPubsubClient client) throws Exception {
    Deadline deadline = Deadline.fromNow(Duration.ofSeconds(5));
    List<Order> orders;
    do {
        Thread.sleep(1000);
        orders = client.readAllMessages(LARGE_ORDERS_STREAM).stream().map(order -> fromJson(order, Order.class)).collect(Collectors.toList());
    } while (deadline.hasTimeLeft() && orders.size() < 3);
    return orders;
}
Also used : Order(org.apache.flink.streaming.kinesis.test.model.Order) Deadline(org.apache.flink.api.common.time.Deadline)

Aggregations

Order (org.apache.flink.streaming.kinesis.test.model.Order)2 Deadline (org.apache.flink.api.common.time.Deadline)1 Test (org.junit.Test)1