private void TryAssertionInsertWhereOMStaggered(
                RegressionEnvironment env,
                EventRepresentationChoice eventRepresentationEnum)
            {
                var path = new RegressionPath();
                var stmtTextCreateOne = eventRepresentationEnum.GetAnnotationTextWJsonProvided<MyLocalJsonProvidedMyWindowIWOM>() +
                                        " @Name('window') create window MyWindowIWOM#keepall as select a, b from MyMapAB";
                env.CompileDeploy(stmtTextCreateOne, path);
                Assert.IsTrue(eventRepresentationEnum.MatchesClass(env.Statement("window").EventType.UnderlyingType));
                env.AddListener("window");

                // create insert into
                var stmtTextInsertOne = "insert into MyWindowIWOM select a, b from MyMapAB";
                env.CompileDeploy(stmtTextInsertOne, path);

                // populate some data
                env.SendEventMap(BuildMap(new[] {new object[] {"a", "E1"}, new object[] {"b", 2}}), "MyMapAB");
                env.SendEventMap(BuildMap(new[] {new object[] {"a", "E2"}, new object[] {"b", 10}}), "MyMapAB");
                env.SendEventMap(BuildMap(new[] {new object[] {"a", "E3"}, new object[] {"b", 10}}), "MyMapAB");

                // create window with keep-all using OM
                var model = new EPStatementObjectModel();
                eventRepresentationEnum.AddAnnotationForNonMap(model);
                Expression where = Expressions.Eq("b", 10);
                model.CreateWindow =
                    CreateWindowClause.Create("MyWindowIWOMTwo", View.Create("keepall"))
                        .WithInsert(true)
                        .WithInsertWhereClause(where)
                        .WithAsEventTypeName("MyWindowIWOM");
                model.SelectClause = SelectClause.CreateWildcard();
                var text = eventRepresentationEnum.GetAnnotationTextForNonMap() +
                           " create window MyWindowIWOMTwo#keepall as select * from MyWindowIWOM insert where b=10";
                Assert.AreEqual(text.Trim(), model.ToEPL());

                var modelTwo = env.EplToModel(text);
                Assert.AreEqual(text.Trim(), modelTwo.ToEPL());
                modelTwo.Annotations = Collections.SingletonList(AnnotationPart.NameAnnotation("windowTwo"));
                env.CompileDeploy(modelTwo, path).AddListener("windowTwo");

                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("windowTwo"),
                    new[] {"a", "b"},
                    new[] {new object[] {"E2", 10}, new object[] {"E3", 10}});

                // test select individual fields and from an insert-from named window
                env.CompileDeploy(
                    eventRepresentationEnum.GetAnnotationTextWJsonProvided<MyLocalJsonProvidedMyWindowIWOMThree>() +
                    " @Name('windowThree') create window MyWindowIWOMThree#keepall as select a from MyWindowIWOMTwo insert where a = 'E2'",
                    path);
                EPAssertionUtil.AssertPropsPerRow(
                    env.GetEnumerator("windowThree"),
                    new[] {"a"},
                    new[] {new object[] {"E2"}});

                env.UndeployAll();
            }
        private void TryAssertionInsertWhereOMStaggered(EPServiceProvider epService, EventRepresentationChoice eventRepresentationEnum)
        {
            IDictionary <string, object> dataType = MakeMap(new[] { new object[] { "a", typeof(string) }, new object[] { "b", typeof(int) } });

            epService.EPAdministrator.Configuration.AddEventType("MyMap", dataType);

            string      stmtTextCreateOne = eventRepresentationEnum.GetAnnotationText() + " create window MyWindowIWOM#keepall as select a, b from MyMap";
            EPStatement stmtCreateOne     = epService.EPAdministrator.CreateEPL(stmtTextCreateOne);

            Assert.IsTrue(eventRepresentationEnum.MatchesClass(stmtCreateOne.EventType.UnderlyingType));
            var listener = new SupportUpdateListener();

            stmtCreateOne.Events += listener.Update;

            // create insert into
            string stmtTextInsertOne = "insert into MyWindowIWOM select a, b from MyMap";

            epService.EPAdministrator.CreateEPL(stmtTextInsertOne);

            // populate some data
            epService.EPRuntime.SendEvent(MakeMap(new[] { new object[] { "a", "E1" }, new object[] { "b", 2 } }), "MyMap");
            epService.EPRuntime.SendEvent(MakeMap(new[] { new object[] { "a", "E2" }, new object[] { "b", 10 } }), "MyMap");
            epService.EPRuntime.SendEvent(MakeMap(new[] { new object[] { "a", "E3" }, new object[] { "b", 10 } }), "MyMap");

            // create window with keep-all using OM
            var model = new EPStatementObjectModel();

            eventRepresentationEnum.AddAnnotationForNonMap(model);
            Expression where   = Expressions.Eq("b", 10);
            model.CreateWindow = CreateWindowClause.Create("MyWindowIWOMTwo", View.Create("keepall"))
                                 .SetIsInsert(true)
                                 .SetInsertWhereClause(where);
            model.SelectClause = SelectClause.CreateWildcard();
            model.FromClause   = FromClause.Create(FilterStream.Create("MyWindowIWOM"));
            string text = eventRepresentationEnum.GetAnnotationTextForNonMap() + " create window MyWindowIWOMTwo#keepall as select * from MyWindowIWOM insert where b=10";

            Assert.AreEqual(text.Trim(), model.ToEPL());

            EPStatementObjectModel modelTwo = epService.EPAdministrator.CompileEPL(text);

            Assert.AreEqual(text.Trim(), modelTwo.ToEPL());

            EPStatement stmt = epService.EPAdministrator.Create(modelTwo);

            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), "a,b".Split(','), new[] { new object[] { "E2", 10 }, new object[] { "E3", 10 } });

            // test select individual fields and from an insert-from named window
            stmt = epService.EPAdministrator.CreateEPL(eventRepresentationEnum.GetAnnotationText() + " create window MyWindowIWOMThree#keepall as select a from MyWindowIWOMTwo insert where a = 'E2'");
            EPAssertionUtil.AssertPropsPerRow(stmt.GetEnumerator(), "a".Split(','), new[] { new object[] { "E2" } });

            epService.EPAdministrator.DestroyAllStatements();
            epService.EPAdministrator.Configuration.RemoveEventType("MyWindowIWOM", true);
            epService.EPAdministrator.Configuration.RemoveEventType("MyWindowIWOMTwo", true);
            epService.EPAdministrator.Configuration.RemoveEventType("MyWindowIWOMThree", true);
        }