@Test
 public void testGetFeature() {
   NamedFunction result1 =
       (NamedFunction)
           BackendFacade.invoke(
               _ctx,
               new QualifiedName("testGetFeature"),
               Arrays.asList(_person, "call", Arrays.asList(StringType.INSTANCE)));
   assertEquals("call", result1.getName().getSimpleName());
   Object result2 =
       BackendFacade.invoke(
           _ctx,
           new QualifiedName("testGetFeature"),
           Arrays.asList(_person, "name", Arrays.asList()));
   if (result2 instanceof NamedFunction) {
     assertEquals("name", ((NamedFunction) result2).getName().getSimpleName());
   } else if (result2 instanceof Property) {
     assertEquals("name", ((Property) result2).getName());
   }
   StaticProperty result3 =
       (StaticProperty)
           BackendFacade.invoke(
               _ctx,
               new QualifiedName("testGetFeature"),
               Arrays.asList(_person, "A_STATIC_PROPERTY", Arrays.asList()));
   assertEquals("A_STATIC_PROPERTY", result3.getName());
 }
  @SuppressWarnings("unchecked")
  private AroundAdvice createAdvice(NamedFunction f, Method mtd) {
    Function inner = f.getFunction();
    if (inner instanceof JavaDefinedFunction) {
      final M2tAroundAdvice adviceAnn = mtd.getAnnotation(M2tAroundAdvice.class);
      final M2tPointcut pointcutAnn = adviceAnn.pointcut();

      List<NamedFunction> adviceBodyJavaFunctions = null;
      if ((adviceBodyJavaFunctions =
              (List<NamedFunction>)
                  _middleEnd
                      .getExecutionContext()
                      .getContributionStateContext()
                      .retrieveState("AdviceBodyJavaDefinedFunctions"))
          == null) {
        adviceBodyJavaFunctions = new ArrayList<NamedFunction>();
        _middleEnd
            .getExecutionContext()
            .getContributionStateContext()
            .storeState("AdviceBodyJavaDefinedFunctions", adviceBodyJavaFunctions);
      }
      adviceBodyJavaFunctions.add(f);
      String[] paramTypeNames = pointcutAnn.paramTypeNames();
      List<Pair<String, AdviceParamType>> paramTypes =
          new ArrayList<Pair<String, AdviceParamType>>();
      for (int i = 0; i < paramTypeNames.length; i++) {
        String paramTypeName = paramTypeNames[i];
        // TODO make subtype inclusion configurable
        if (!paramTypeName.equals("*")) {
          final AdviceParamType paramType =
              new AdviceParamType(_middleEnd.getTypesystem().findType(paramTypeName), true);
          final Pair<String, AdviceParamType> paramTypePair =
              new Pair<String, AdviceParamType>("o" + i + 1, paramType);
          paramTypes.add(paramTypePair);
        }
      }
      AdviceParamType varArgsAdvParamType =
          new AdviceParamType(
              _middleEnd.getTypesystem().findType(ObjectType.INSTANCE.getUniqueRepresentation()),
              true);

      final ExecutionPointcut pointcut =
          new ExecutionPointcut(
              pointcutAnn.namePattern(), paramTypes, pointcutAnn.hasVarArgs(), null);
      ExpressionBase body =
          new MethodInvocationExpression(
              mtd,
              Arrays.asList(new LocalVarEvalExpression(SyntaxConstants.THIS_JOINPOINT, null)),
              false,
              null);

      final AroundAdvice adv = new AroundAdvice(body, pointcut, true);

      return adv;
    } else {
      throw new IllegalArgumentException(
          "Advice definition " + f.getName() + " is not a JavaDefinedFunction");
    }
  }
 @SuppressWarnings("unchecked")
 @Test
 public void testAllOperations() {
   Set<NamedFunction> result =
       (Set<NamedFunction>)
           BackendFacade.invoke(
               _ctx, new QualifiedName("testAllOperations"), Arrays.asList(_person));
   assertTrue(result.size() >= 14);
   for (NamedFunction namedFunction : result) {
     if (namedFunction.getName().getFullQualifiedName().equals(XtendLibNames.OPERATION_NAME))
       fail("There should be no operation " + XtendLibNames.OPERATION_NAME);
   }
 }
 @Test
 public void testGetOperation() {
   Person p = new Person();
   p.setName("Arnold");
   p.setFirstName("André");
   NamedFunction result1 =
       (NamedFunction)
           BackendFacade.invoke(
               _ctx, new QualifiedName("testGetOperation"), Arrays.asList(_person));
   assertEquals(
       "called:call",
       _ctx.getFunctionInvoker()
           .invoke(_ctx, result1.getFunction(), Arrays.asList(_person, "call")));
   Boolean result2 =
       (Boolean)
           BackendFacade.invoke(
               _ctx, new QualifiedName("testGetOperationLess"), Arrays.asList(p, _person));
   assertTrue(result2);
 }