Example #1
0
        public void StreamStreamJoinSpecificSerdes()
        {
            var stringSerdes = new StringSerDes();
            var config       = new StreamConfig
            {
                ApplicationId = "test-stream-stream-join"
            };

            StreamBuilder builder = new StreamBuilder();

            var stream = builder.Stream("topic1", stringSerdes, stringSerdes);

            builder
            .Stream("topic2", stringSerdes, stringSerdes)
            .Join(
                stream,
                (s, v) => $"{s}-{v}",
                JoinWindowOptions.Of(TimeSpan.FromSeconds(10)),
                StreamJoinProps.With(
                    keySerde: stringSerdes,
                    valueSerde: stringSerdes,
                    otherValueSerde: stringSerdes))
            .To("output-join");

            Topology t = builder.Build();

            using (var driver = new TopologyTestDriver(t, config))
            {
                var inputTopic  = driver.CreateInputTopic <string, string, StringSerDes, StringSerDes>("topic1");
                var outputTopic = driver.CreateOuputTopic <string, string, StringSerDes, StringSerDes>("output-join");
                inputTopic.PipeInput("test", "test");
                var record = outputTopic.ReadKeyValue();
                Assert.IsNull(record);
            }
        }
        public void TestJoinPropsSupplier()
        {
            var props = StreamJoinProps.With(new TestSupplier(), new TestSupplier());

            Assert.IsNotNull(props);
            Assert.IsAssignableFrom <TestSupplier>(props.LeftStoreSupplier);
            Assert.IsAssignableFrom <TestSupplier>(props.RightStoreSupplier);
            Assert.IsNull(props.Name);
            Assert.IsNull(props.StoreName);
        }
        public void TestJoinPropsSupplier2()
        {
            var props = StreamJoinProps.With <string, string, string>(new TestSupplier(), new TestSupplier());

            Assert.IsNotNull(props);
            Assert.IsAssignableFrom <TestSupplier>(props.LeftStoreSupplier);
            Assert.IsAssignableFrom <TestSupplier>(props.RightStoreSupplier);
            Assert.IsNull(props.Name);
            Assert.IsNull(props.StoreName);
            Assert.IsNull(props.KeySerdes);
            Assert.IsNull(props.LeftValueSerdes);
            Assert.IsNull(props.RightValueSerdes);
        }
        public void TestJoinPropsWithSerdes()
        {
            var props = StreamJoinProps.With <string, int, long>(new StringSerDes(), new Int32SerDes(), new Int64SerDes());

            Assert.IsNotNull(props);
            Assert.IsNull(props.LeftStoreSupplier);
            Assert.IsNull(props.RightStoreSupplier);
            Assert.IsNull(props.Name);
            Assert.IsNull(props.StoreName);
            Assert.IsAssignableFrom <StringSerDes>(props.KeySerdes);
            Assert.IsAssignableFrom <Int32SerDes>(props.LeftValueSerdes);
            Assert.IsAssignableFrom <Int64SerDes>(props.RightValueSerdes);
        }
Example #5
0
        public void StreamSameStoreName()
        {
            var config = new StreamConfig <StringSerDes, StringSerDes>
            {
                ApplicationId = "test-stream-stream-left-join"
            };

            StreamBuilder builder = new StreamBuilder();

            var stream = builder.Stream <string, string>("topic1");

            var joinProps = StreamJoinProps.From <string, string, string>(StreamJoinProps.With(
                                                                              State.Stores.InMemoryWindowStore("test", TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10)),
                                                                              State.Stores.InMemoryWindowStore("test", TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10))));

            Assert.Throws <StreamsException>(() => builder
                                             .Stream <string, string>("topic2")
                                             .LeftJoin(stream, new MyJoinerMapper(), JoinWindowOptions.Of(TimeSpan.FromSeconds(10)), joinProps));
        }
Example #6
0
        public void StreamInvalidTimeSettings()
        {
            var config = new StreamConfig <StringSerDes, StringSerDes>
            {
                ApplicationId = "test-stream-stream-left-join"
            };

            StreamBuilder builder = new StreamBuilder();

            var stream = builder.Stream <string, string>("topic1");

            var joinProps = StreamJoinProps.From <string, string, string>(StreamJoinProps.With(
                                                                              State.Stores.InMemoryWindowStore("test1", TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10)),
                                                                              State.Stores.InMemoryWindowStore("test2", TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10))));

            // JoinWindowOptions.Of => use default retention => One Day
            // joinProps use supplier with retention 10 secondes => BAD THING !!
            Assert.Throws <StreamsException>(() => builder
                                             .Stream <string, string>("topic2")
                                             .LeftJoin(stream, new MyJoinerMapper(), JoinWindowOptions.Of(TimeSpan.FromSeconds(10)), joinProps));
        }