private Object[] getTestDataTwo() {
    Map<String, Object> levelThree =
        makeMap(
            new Object[][] {
              {"simpleThree", 4000L},
              {"objectThree", new SupportBean_B("B1")},
            });

    Map<String, Object> levelTwo =
        makeMap(
            new Object[][] {
              {"simpleTwo", 300},
              {"objectTwo", SupportBeanCombinedProps.makeDefaultBean()},
              {"nodefmapTwo", makeMap(new Object[][] {{"key3", "val3"}})},
              {"mapTwo", levelThree},
            });

    Map<String, Object> levelOne =
        makeMap(
            new Object[][] {
              {"simpleOne", 10},
              {"objectOne", SupportBeanComplexProps.makeDefaultBean()},
              {"nodefmapOne", makeMap(new Object[][] {{"key2", "val2"}})},
              {"mapOne", levelTwo}
            });

    Object[] levelZero = {
      "abc", new SupportBean_A("A1"), makeMap(new Object[][] {{"key1", "val1"}}), levelOne
    };
    return levelZero;
  }
예제 #2
0
  public void setUp() {
    beanEventTypeFactory =
        new BeanEventAdapter(
            new ConcurrentHashMap<Class, BeanEventType>(),
            SupportEventAdapterService.getService(),
            new EventTypeIdGeneratorImpl());

    nested = new NestedProperty[2];
    nested[0] = makeProperty(new String[] {"nested", "nestedValue"});
    nested[1] = makeProperty(new String[] {"nested", "nestedNested", "nestedNestedValue"});

    event = SupportEventBeanFactory.createObject(SupportBeanComplexProps.makeDefaultBean());
  }
  public void testMappedProperty() {
    EPServiceProvider epService = getEngineInitialized(null, null, null);

    // test map containing first-level property that is an array of primitive or Class
    Map<String, Object> mappedDef = makeMap(new Object[][] {{"p0", Map.class}});
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("MyMappedPropertyMap", mappedDef);

    EPStatement stmt =
        epService.getEPAdministrator().createEPL("select p0('k1') as a from MyMappedPropertyMap");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    Map<String, Object> eventVal = new HashMap<String, Object>();
    eventVal.put("k1", "v1");
    Map<String, Object> theEvent = makeMap(new Object[][] {{"p0", eventVal}});
    epService.getEPRuntime().sendEvent(theEvent, "MyMappedPropertyMap");

    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), "a".split(","), new Object[] {"v1"});
    assertEquals(Object.class, stmt.getEventType().getPropertyType("a"));
    stmt.destroy();

    // test map at the second level of a nested map that is an array of primitive or Class
    Map<String, Object> mappedDefOuter = makeMap(new Object[][] {{"outer", mappedDef}});
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("MyMappedPropertyMapOuter", mappedDefOuter);

    stmt =
        epService
            .getEPAdministrator()
            .createEPL("select outer.p0('k1') as a from MyMappedPropertyMapOuter");
    stmt.addListener(listener);

    Map<String, Object> eventOuter = makeMap(new Object[][] {{"outer", theEvent}});
    epService.getEPRuntime().sendEvent(eventOuter, "MyMappedPropertyMapOuter");

    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), "a".split(","), new Object[] {"v1"});
    assertEquals(Object.class, stmt.getEventType().getPropertyType("a"));

    // test map that contains a bean which has a map property
    Map<String, Object> mappedDefOuterTwo =
        makeMap(new Object[][] {{"outerTwo", SupportBeanComplexProps.class}});
    epService
        .getEPAdministrator()
        .getConfiguration()
        .addEventType("MyMappedPropertyMapOuterTwo", mappedDefOuterTwo);

    stmt =
        epService
            .getEPAdministrator()
            .createEPL("select outerTwo.mapProperty('xOne') as a from MyMappedPropertyMapOuterTwo");
    stmt.addListener(listener);

    Map<String, Object> eventOuterTwo =
        makeMap(new Object[][] {{"outerTwo", SupportBeanComplexProps.makeDefaultBean()}});
    epService.getEPRuntime().sendEvent(eventOuterTwo, "MyMappedPropertyMapOuterTwo");

    EPAssertionUtil.assertProps(
        listener.assertOneGetNewAndReset(), "a".split(","), new Object[] {"yOne"});
    assertEquals(String.class, stmt.getEventType().getPropertyType("a"));
  }