@Test
  @SuppressWarnings("serial")
  public void testCEPParameterCompletions() {

    final SuggestionCompletionEngine com = new SuggestionCompletionEngine();

    com.setFactTypes(new String[] {"AnEvent"});

    com.setFieldsForTypes(
        new HashMap<String, ModelField[]>() {
          {
            put(
                "AnEvent",
                new ModelField[] {
                  new ModelField(
                      "this", Object.class.getName(), FIELD_CLASS_TYPE.REGULAR_CLASS, "AnEvent")
                });
          }
        });

    // Set-up annotation for Type 'AnEvent'
    Map<String, List<ModelAnnotation>> annotations = new HashMap<String, List<ModelAnnotation>>();
    List<ModelAnnotation> eventAnnotations = new ArrayList<ModelAnnotation>();
    ModelAnnotation ma = new ModelAnnotation();
    ma.setAnnotationName("role");
    Map<String, String> mav = new HashMap<String, String>();
    mav.put("value", "event");
    ma.setAnnotationValues(mav);
    eventAnnotations.add(ma);
    annotations.put("AnEvent", eventAnnotations);
    com.setAnnotationsForTypes(annotations);

    // Check completions
    List<Integer> c = SuggestionCompletionEngine.getCEPOperatorParameterSets("after");
    assertEquals(3, c.size());
    assertEquals(0, c.get(0).intValue());
    assertEquals(1, c.get(1).intValue());
    assertEquals(2, c.get(2).intValue());

    c = SuggestionCompletionEngine.getCEPOperatorParameterSets("before");
    assertEquals(3, c.size());
    assertEquals(0, c.get(0).intValue());
    assertEquals(1, c.get(1).intValue());
    assertEquals(2, c.get(2).intValue());

    c = SuggestionCompletionEngine.getCEPOperatorParameterSets("coincides");
    assertEquals(3, c.size());
    assertEquals(0, c.get(0).intValue());
    assertEquals(1, c.get(1).intValue());
    assertEquals(2, c.get(2).intValue());

    c = SuggestionCompletionEngine.getCEPOperatorParameterSets("during");
    assertEquals(4, c.size());
    assertEquals(0, c.get(0).intValue());
    assertEquals(1, c.get(1).intValue());
    assertEquals(2, c.get(2).intValue());
    assertEquals(4, c.get(3).intValue());

    c = SuggestionCompletionEngine.getCEPOperatorParameterSets("finishes");
    assertEquals(2, c.size());
    assertEquals(0, c.get(0).intValue());
    assertEquals(1, c.get(1).intValue());

    c = SuggestionCompletionEngine.getCEPOperatorParameterSets("finishedby");
    assertEquals(2, c.size());
    assertEquals(0, c.get(0).intValue());
    assertEquals(1, c.get(1).intValue());

    c = SuggestionCompletionEngine.getCEPOperatorParameterSets("includes");
    assertEquals(4, c.size());
    assertEquals(0, c.get(0).intValue());
    assertEquals(1, c.get(1).intValue());
    assertEquals(2, c.get(2).intValue());
    assertEquals(4, c.get(3).intValue());

    c = SuggestionCompletionEngine.getCEPOperatorParameterSets("meets");
    assertEquals(2, c.size());
    assertEquals(0, c.get(0).intValue());
    assertEquals(1, c.get(1).intValue());

    c = SuggestionCompletionEngine.getCEPOperatorParameterSets("metby");
    assertEquals(2, c.size());
    assertEquals(0, c.get(0).intValue());
    assertEquals(1, c.get(1).intValue());

    c = SuggestionCompletionEngine.getCEPOperatorParameterSets("overlaps");
    assertEquals(3, c.size());
    assertEquals(0, c.get(0).intValue());
    assertEquals(1, c.get(1).intValue());
    assertEquals(2, c.get(2).intValue());

    c = SuggestionCompletionEngine.getCEPOperatorParameterSets("overlappedby");
    assertEquals(3, c.size());
    assertEquals(0, c.get(0).intValue());
    assertEquals(1, c.get(1).intValue());
    assertEquals(2, c.get(2).intValue());

    c = SuggestionCompletionEngine.getCEPOperatorParameterSets("starts");
    assertEquals(2, c.size());
    assertEquals(0, c.get(0).intValue());
    assertEquals(1, c.get(1).intValue());

    c = SuggestionCompletionEngine.getCEPOperatorParameterSets("startedby");
    assertEquals(2, c.size());
    assertEquals(0, c.get(0).intValue());
    assertEquals(1, c.get(1).intValue());
  }
  @Test
  @SuppressWarnings("serial")
  public void testCEPCompletions() {

    final SuggestionCompletionEngine com = new SuggestionCompletionEngine();

    com.setFactTypes(new String[] {"NotAnEvent", "AnEvent"});

    com.setFieldsForTypes(
        new HashMap<String, ModelField[]>() {
          {
            put(
                "NotAnEvent",
                new ModelField[] {
                  new ModelField(
                      "dateField",
                      Date.class.getName(),
                      FIELD_CLASS_TYPE.REGULAR_CLASS,
                      SuggestionCompletionEngine.TYPE_DATE)
                });

            put(
                "AnEvent",
                new ModelField[] {
                  new ModelField(
                      "this", Object.class.getName(), FIELD_CLASS_TYPE.REGULAR_CLASS, "AnEvent"),
                  new ModelField(
                      "dateField",
                      Date.class.getName(),
                      FIELD_CLASS_TYPE.REGULAR_CLASS,
                      SuggestionCompletionEngine.TYPE_DATE)
                });
          }
        });

    // Set-up annotation for Type 'AnEvent'
    Map<String, List<ModelAnnotation>> annotations = new HashMap<String, List<ModelAnnotation>>();
    List<ModelAnnotation> eventAnnotations = new ArrayList<ModelAnnotation>();
    ModelAnnotation ma = new ModelAnnotation();
    ma.setAnnotationName("role");
    Map<String, String> mav = new HashMap<String, String>();
    mav.put("value", "event");
    ma.setAnnotationValues(mav);
    eventAnnotations.add(ma);
    annotations.put("AnEvent", eventAnnotations);
    com.setAnnotationsForTypes(annotations);

    // Check completions
    String[] c = com.getFactTypes();
    assertEquals(2, c.length);
    assertContains("NotAnEvent", c);
    assertContains("AnEvent", c);

    c = com.getOperatorCompletions("NotAnEvent", "dateField");
    assertEquals(11, c.length);
    assertEquals(c[0], "==");
    assertEquals(c[1], "!=");
    assertEquals(c[2], "<");
    assertEquals(c[3], ">");
    assertEquals(c[4], "<=");
    assertEquals(c[5], ">=");
    assertEquals(c[6], "== null");
    assertEquals(c[7], "!= null");
    assertEquals(c[8], "after");
    assertEquals(c[9], "before");
    assertEquals(c[10], "coincides");

    c = com.getOperatorCompletions("AnEvent", "this");
    assertEquals(17, c.length);
    assertEquals(c[0], "==");
    assertEquals(c[1], "!=");
    assertEquals(c[2], "== null");
    assertEquals(c[3], "!= null");
    assertEquals(c[4], "after");
    assertEquals(c[5], "before");
    assertEquals(c[6], "coincides");
    assertEquals(c[7], "during");
    assertEquals(c[8], "finishes");
    assertEquals(c[9], "finishedby");
    assertEquals(c[10], "includes");
    assertEquals(c[11], "meets");
    assertEquals(c[12], "metby");
    assertEquals(c[13], "overlaps");
    assertEquals(c[14], "overlappedby");
    assertEquals(c[15], "starts");
    assertEquals(c[16], "startedby");
  }