Examples of TestMethodMeta


Examples of org.junithelper.core.meta.TestMethodMeta

  @Override
  public TestMethodMeta getTestMethodMeta(MethodMeta targetMethodMeta, ExceptionMeta exception) {
    if (targetClassMeta == null) {
      throw new IllegalStateException("Not initialized");
    }
    TestMethodMeta testMethodMeta = new TestMethodMeta();
    testMethodMeta.classMeta = targetClassMeta;
    testMethodMeta.methodMeta = targetMethodMeta;
    testMethodMeta.testingTargetException = exception;
    return testMethodMeta;
  }
View Full Code Here

Examples of org.junithelper.core.meta.TestMethodMeta

  @Override
  public TestMethodMeta getTestMethodMeta(MethodMeta targetMethodMeta, ExceptionMeta exception) {
    if (targetClassMeta == null) {
      throw new IllegalStateException("Not initialized");
    }
    TestMethodMeta testMethodMeta = new TestMethodMeta();
    testMethodMeta.classMeta = targetClassMeta;
    testMethodMeta.methodMeta = targetMethodMeta;
    testMethodMeta.testingTargetException = exception;
    return testMethodMeta;
  }
View Full Code Here

Examples of org.junithelper.core.meta.TestMethodMeta

    String checkTargetSourceCode = TrimFilterUtil.doAllFilters(currentTestCaseSourceCode);

    // is testing type safe required
    if (!checkTargetSourceCode.matches(RegExp.Anything_ZeroOrMore_Min + "public\\s+void\\s+[^\\s]*type\\("
        + RegExp.Anything_ZeroOrMore_Min)) {
      TestMethodMeta meta = new TestMethodMeta();
      meta.classMeta = targetClassMeta;
      meta.isTypeTest = true;
      addTestMethodMetaToListIfNotExists(dest, meta);
    }
    // is testing instantiation required
    if (!targetClassMeta.isEnum && targetClassMeta.constructors.size() > 0) {
      ConstructorMeta notPrivateConstructor = null;
      for (ConstructorMeta constructor : targetClassMeta.constructors) {
        if (constructor.accessModifier != AccessModifier.Private) {
          notPrivateConstructor = constructor;
          break;
        }
      }
      // instantiation test
      if (notPrivateConstructor != null) {
        if (!checkTargetSourceCode.matches(RegExp.Anything_ZeroOrMore_Min
            + "public\\s+void\\s+[^\\s]*instantiation\\(" + RegExp.Anything_ZeroOrMore_Min)) {
          TestMethodMeta meta = new TestMethodMeta();
          meta.classMeta = targetClassMeta;
          meta.isInstantiationTest = true;
          addTestMethodMetaToListIfNotExists(dest, meta);
        }
      }
    }
    // test methods
    for (MethodMeta methodMeta : targetClassMeta.methods) {

      try {
        // exclude accessors
        if (config.target.isAccessorExcluded && methodMeta.isAccessor) {
          continue;
        }
        // testing target access modifier
        if (!isPublicMethodAndTestingRequired(methodMeta, config.target)
            && !isProtectedMethodAndTestingRequired(methodMeta, config.target)
            && !isPackageLocalMethodAndTestingRequired(methodMeta, config.target)) {
          continue;
        }
        // -----------
        // at least one test method for the target
        // the test method is not already exist
        StringBuilder IS_ALREADY_EXISTS = new StringBuilder();
        IS_ALREADY_EXISTS.append(RegExp.Anything_ZeroOrMore_Min);
        // test method signature prefix
        TestMethodMeta testMethodMeta = new TestMethodMeta();
        testMethodMeta.methodMeta = methodMeta;
        String testMethodNamePrefix = testMethodGenerator.getTestMethodNamePrefix(testMethodMeta);
        IS_ALREADY_EXISTS.append(testMethodNamePrefix);
        IS_ALREADY_EXISTS.append("[");
        IS_ALREADY_EXISTS.append(config.testMethodName.basicDelimiter);
        IS_ALREADY_EXISTS.append("\\(");
        IS_ALREADY_EXISTS.append("]");
        IS_ALREADY_EXISTS.append(RegExp.Anything_ZeroOrMore_Min);
        if (!checkTargetSourceCode.matches(Matcher.quoteReplacement(IS_ALREADY_EXISTS.toString()))) {
          // testing normal pattern
          TestMethodMeta meta = testMethodGenerator.getTestMethodMeta(methodMeta);
          // extension assertions
          meta = appendIfExtensionAssertionsExist(meta, config);
          addTestMethodMetaToListIfNotExists(dest, meta);
          // testing exception patterns
          if (config.target.isExceptionPatternRequired) {
            for (ExceptionMeta exceptionMeta : methodMeta.throwsExceptions) {
              TestMethodMeta metaEx = testMethodGenerator.getTestMethodMeta(methodMeta, exceptionMeta);
              // extension assertions
              metaEx = appendIfExtensionAssertionsExist(metaEx, config);
              addTestMethodMetaToListIfNotExists(dest, metaEx);
            }
          }
        }
        // -----------
        // Extension
        if (config.isExtensionEnabled) {
          // extension arg patterns
          List<ExtArg> extArgs = config.extConfiguration.extArgs;
          for (ExtArg extArg : extArgs) {
            // import and className
            for (ArgTypeMeta argType : methodMeta.argTypes) {
              if (isCanonicalClassNameUsed(extArg.canonicalClassName, argType.name, targetClassMeta)) {
                for (ExtArgPattern pattern : extArg.patterns) {
                  // extension pattern is not matched
                  // e.g.
                  // .*?doSomething_A$String_StringIsNull.*?
                  String IS_ALREADY_EXISTS_FOR_PATTERN = RegExp.Anything_ZeroOrMore_Min
                      + testMethodNamePrefix + config.testMethodName.basicDelimiter
                      + extArg.getCanonicalClassNameInMethodName() + "Is"
                      + pattern.getNameWhichFirstCharIsUpper() + RegExp.Anything_ZeroOrMore_Min;
                  IS_ALREADY_EXISTS_FOR_PATTERN = Matcher
                      .quoteReplacement(IS_ALREADY_EXISTS_FOR_PATTERN);
                  if (!checkTargetSourceCode.matches(IS_ALREADY_EXISTS_FOR_PATTERN)) {
                    // testing target access modifier
                    TestMethodMeta meta = testMethodGenerator.getTestMethodMeta(methodMeta, null);
                    meta.extArgPattern = pattern;
                    // extension assertions
                    meta = appendIfExtensionAssertionsExist(meta, config);
                    addTestMethodMetaToListIfNotExists(dest, meta);
                  }
View Full Code Here

Examples of org.junithelper.core.meta.TestMethodMeta

    // is testing type safe required
    if (!checkTargetSourceCode.matches(RegExp.Anything_ZeroOrMore_Min
        + "public\\s+void\\s+[^\\s]*type\\("
        + RegExp.Anything_ZeroOrMore_Min)) {
      TestMethodMeta meta = new TestMethodMeta();
      meta.classMeta = targetClassMeta;
      meta.isTypeTest = true;
      addTestMethodMetaToListIfNotExists(dest, meta);
    }
    // is testing instantiation required
    if (!targetClassMeta.isEnum && targetClassMeta.constructors.size() > 0) {
      ConstructorMeta notPrivateConstructor = null;
      for (ConstructorMeta constructor : targetClassMeta.constructors) {
        if (constructor.accessModifier != AccessModifier.Private) {
          notPrivateConstructor = constructor;
          break;
        }
      }
      // instantiation test
      if (notPrivateConstructor != null) {
        if (!checkTargetSourceCode
            .matches(RegExp.Anything_ZeroOrMore_Min
                + "public\\s+void\\s+[^\\s]*instantiation\\("
                + RegExp.Anything_ZeroOrMore_Min)) {
          TestMethodMeta meta = new TestMethodMeta();
          meta.classMeta = targetClassMeta;
          meta.isInstantiationTest = true;
          addTestMethodMetaToListIfNotExists(dest, meta);
        }
      }
    }
    // test methods
    for (MethodMeta methodMeta : targetClassMeta.methods) {

      try {
        // exclude accessors
        if (config.target.isAccessorExcluded && methodMeta.isAccessor) {
          continue;
        }
        // testing target access modifier
        if (!isPublicMethodAndTestingRequired(methodMeta, config.target)
            && !isProtectedMethodAndTestingRequired(methodMeta,
                config.target)
            && !isPackageLocalMethodAndTestingRequired(methodMeta,
                config.target)) {
          continue;
        }
        // -----------
        // at least one test method for the target
        // the test method is not already exist
        StringBuilder IS_ALREADY_EXISTS = new StringBuilder();
        IS_ALREADY_EXISTS.append(RegExp.Anything_ZeroOrMore_Min);
        // test method signature prefix
        TestMethodMeta testMethodMeta = new TestMethodMeta();
        testMethodMeta.methodMeta = methodMeta;
        String testMethodNamePrefix = testMethodGenerator
            .getTestMethodNamePrefix(testMethodMeta);
        IS_ALREADY_EXISTS.append(testMethodNamePrefix);
        IS_ALREADY_EXISTS.append("[");
        IS_ALREADY_EXISTS.append(config.testMethodName.basicDelimiter);
        IS_ALREADY_EXISTS.append("\\(");
        IS_ALREADY_EXISTS.append("]");
        IS_ALREADY_EXISTS.append(RegExp.Anything_ZeroOrMore_Min);
        if (!checkTargetSourceCode.matches(Matcher
            .quoteReplacement(IS_ALREADY_EXISTS.toString()))) {
          // testing normal pattern
          TestMethodMeta meta = testMethodGenerator
              .getTestMethodMeta(methodMeta);
          // extension assertions
          meta = appendIfExtensionAssertionsExist(meta, config);
          addTestMethodMetaToListIfNotExists(dest, meta);
          // testing exception patterns
          if (config.target.isExceptionPatternRequired) {
            for (ExceptionMeta exceptionMeta : methodMeta.throwsExceptions) {
              TestMethodMeta metaEx = testMethodGenerator
                  .getTestMethodMeta(methodMeta,
                      exceptionMeta);
              // extension assertions
              metaEx = appendIfExtensionAssertionsExist(metaEx,
                  config);
              addTestMethodMetaToListIfNotExists(dest, metaEx);
            }
          }
        }
        // -----------
        // Extension
        if (config.isExtensionEnabled) {
          // extension arg patterns
          List<ExtArg> extArgs = config.extConfiguration.extArgs;
          for (ExtArg extArg : extArgs) {
            // import and className
            for (ArgTypeMeta argType : methodMeta.argTypes) {
              if (isCanonicalClassNameUsed(
                  extArg.canonicalClassName, argType.name,
                  targetClassMeta)) {
                for (ExtArgPattern pattern : extArg.patterns) {
                  // extension pattern is not matched
                  // e.g.
                  // .*?doSomething_A$String_StringIsNull.*?
                  String IS_ALREADY_EXISTS_FOR_PATTERN = RegExp.Anything_ZeroOrMore_Min
                      + testMethodNamePrefix
                      + config.testMethodName.basicDelimiter
                      + extArg.getCanonicalClassNameInMethodName()
                      + "Is"
                      + pattern
                          .getNameWhichFirstCharIsUpper()
                      + RegExp.Anything_ZeroOrMore_Min;
                  IS_ALREADY_EXISTS_FOR_PATTERN = Matcher
                      .quoteReplacement(IS_ALREADY_EXISTS_FOR_PATTERN);
                  if (!checkTargetSourceCode
                      .matches(IS_ALREADY_EXISTS_FOR_PATTERN)) {
                    // testing target access modifier
                    TestMethodMeta meta = testMethodGenerator
                        .getTestMethodMeta(methodMeta,
                            null);
                    meta.extArgPattern = pattern;
                    // extension assertions
                    meta = appendIfExtensionAssertionsExist(
View Full Code Here

Examples of org.junithelper.core.meta.TestMethodMeta

    String checkTargetSourceCode = TrimFilterUtil.doAllFilters(currentTestCaseSourceCode);

    // is testing type safe required
    if (!checkTargetSourceCode.matches(RegExp.Anything_ZeroOrMore_Min + "public\\s+void\\s+[^\\s]*type\\("
        + RegExp.Anything_ZeroOrMore_Min)) {
      TestMethodMeta testMethod = new TestMethodMeta();
      testMethod.classMeta = targetClassMeta;
      testMethod.isTypeTest = true;
      dest.add(testMethod);
    }
    // is testing instantiation required
    if (!targetClassMeta.isEnum && targetClassMeta.constructors.size() > 0) {
      ConstructorMeta notPrivateConstructor = null;
      for (ConstructorMeta constructor : targetClassMeta.constructors) {
        if (constructor.accessModifier != AccessModifier.Private) {
          notPrivateConstructor = constructor;
          break;
        }
      }
      // instantiation test
      if (notPrivateConstructor != null) {
        if (!checkTargetSourceCode.matches(RegExp.Anything_ZeroOrMore_Min
            + "public\\s+void\\s+[^\\s]*instantiation\\(" + RegExp.Anything_ZeroOrMore_Min)) {
          TestMethodMeta testMethod = new TestMethodMeta();
          testMethod.classMeta = targetClassMeta;
          testMethod.isInstantiationTest = true;
          dest.add(testMethod);
        }
      }
    }
    // test methods
    for (MethodMeta methodMeta : targetClassMeta.methods) {
      TestMethodMeta testMethodMeta = new TestMethodMeta();
      testMethodMeta.methodMeta = methodMeta;
      String testMethodNamePrefix = testMethodGenerator.getTestMethodNamePrefix(testMethodMeta);
      // the test method is not already exist
      String regExpForDiscriminateOverloadMethods = "";
      if (!config.testMethodName.isReturnRequired) {
        String argDelimiter = Matcher.quoteReplacement(config.testMethodName.argsAreaDelimiter);
        regExpForDiscriminateOverloadMethods = "[^" + argDelimiter + "]";
      }
      String regExpForCheckAlreadyExists = RegExp.Anything_ZeroOrMore_Min + testMethodNamePrefix
          + regExpForDiscriminateOverloadMethods + RegExp.Anything_ZeroOrMore_Min;
      regExpForCheckAlreadyExists = Matcher.quoteReplacement(regExpForCheckAlreadyExists);
      try {
        if (!checkTargetSourceCode.matches(regExpForCheckAlreadyExists)) {
          // exclude accessors
          if (config.target.isAccessorExcluded && methodMeta.isAccessor) {
            continue;
          }
          // testing target access modifier
          if (isPublicMethodAndTestingRequired(methodMeta, config.target)
              || isProtectedMethodAndTestingRequired(methodMeta, config.target)
              || isPackageLocalMethodAndTestingRequired(methodMeta, config.target)) {
            dest.add(testMethodGenerator.getTestMethodMeta(methodMeta));
            if (config.target.isExceptionPatternRequired) {
              // testing exception patterns
              for (ExceptionMeta exceptionMeta : methodMeta.throwsExceptions) {
                TestMethodMeta newOne = testMethodGenerator
                    .getTestMethodMeta(methodMeta, exceptionMeta);
                dest.add(newOne);
              }
            }
          }
View Full Code Here

Examples of org.junithelper.core.meta.TestMethodMeta

  @Override
  public TestMethodMeta getTestMethodMeta(MethodMeta targetMethodMeta, ExceptionMeta exception) {
    if (targetClassMeta == null) {
      throw new IllegalStateException("Not initialized");
    }
    TestMethodMeta testMethodMeta = new TestMethodMeta();
    testMethodMeta.classMeta = targetClassMeta;
    testMethodMeta.methodMeta = targetMethodMeta;
    testMethodMeta.testingTargetException = exception;
    return testMethodMeta;
  }
View Full Code Here

Examples of org.junithelper.core.meta.TestMethodMeta

    @Override
    public TestMethodMeta getTestMethodMeta(MethodMeta targetMethodMeta, ExceptionMeta exception) {
        if (targetClassMeta == null) {
            throw new IllegalStateException("Not initialized");
        }
        TestMethodMeta testMethodMeta = new TestMethodMeta();
        testMethodMeta.classMeta = targetClassMeta;
        testMethodMeta.methodMeta = targetMethodMeta;
        testMethodMeta.testingTargetException = exception;
        return testMethodMeta;
    }
View Full Code Here

Examples of org.junithelper.core.meta.TestMethodMeta

        String checkTargetSourceCode = TrimFilterUtil.doAllFilters(currentTestCaseSourceCode);

        // is testing type safe required
        if (!checkTargetSourceCode.matches(RegExp.Anything_ZeroOrMore_Min + "public\\s+void\\s+[^\\s]*type\\("
                + RegExp.Anything_ZeroOrMore_Min)) {
            TestMethodMeta meta = new TestMethodMeta();
            meta.classMeta = targetClassMeta;
            meta.isTypeTest = true;
            addTestMethodMetaToListIfNotExists(dest, meta);
        }
        // is testing instantiation required
        if (!targetClassMeta.isEnum && targetClassMeta.constructors.size() > 0) {
            ConstructorMeta notPrivateConstructor = null;
            for (ConstructorMeta constructor : targetClassMeta.constructors) {
                if (constructor.accessModifier != AccessModifier.Private) {
                    notPrivateConstructor = constructor;
                    break;
                }
            }
            // instantiation test
            if (notPrivateConstructor != null) {
                if (!checkTargetSourceCode.matches(RegExp.Anything_ZeroOrMore_Min
                        + "public\\s+void\\s+[^\\s]*instantiation\\(" + RegExp.Anything_ZeroOrMore_Min)) {
                    TestMethodMeta meta = new TestMethodMeta();
                    meta.classMeta = targetClassMeta;
                    meta.isInstantiationTest = true;
                    addTestMethodMetaToListIfNotExists(dest, meta);
                }
            }
        }
        // test methods
        for (MethodMeta methodMeta : targetClassMeta.methods) {

            try {
                // exclude accessors
                if (config.target.isAccessorExcluded && methodMeta.isAccessor) {
                    continue;
                }
                // testing target access modifier
                if (!isPublicMethodAndTestingRequired(methodMeta, config.target)
                        && !isProtectedMethodAndTestingRequired(methodMeta, config.target)
                        && !isPackageLocalMethodAndTestingRequired(methodMeta, config.target)) {
                    continue;
                }
                // -----------
                // at least one test method for the target
                // the test method is not already exist
                StringBuilder IS_ALREADY_EXISTS = new StringBuilder();
                IS_ALREADY_EXISTS.append(RegExp.Anything_ZeroOrMore_Min);
                // test method signature prefix
                TestMethodMeta testMethodMeta = new TestMethodMeta();
                testMethodMeta.methodMeta = methodMeta;
                String testMethodNamePrefix = testMethodGenerator.getTestMethodNamePrefix(testMethodMeta);
                IS_ALREADY_EXISTS.append(testMethodNamePrefix);
                IS_ALREADY_EXISTS.append("[");
                IS_ALREADY_EXISTS.append(config.testMethodName.basicDelimiter);
                IS_ALREADY_EXISTS.append("\\(");
                IS_ALREADY_EXISTS.append("]");
                IS_ALREADY_EXISTS.append(RegExp.Anything_ZeroOrMore_Min);
                if (!checkTargetSourceCode.matches(Matcher.quoteReplacement(IS_ALREADY_EXISTS.toString()))) {
                    // testing normal pattern
                    TestMethodMeta meta = testMethodGenerator.getTestMethodMeta(methodMeta);
                    // extension assertions
                    meta = appendIfExtensionAssertionsExist(meta, config);
                    addTestMethodMetaToListIfNotExists(dest, meta);
                    // testing exception patterns
                    if (config.target.isExceptionPatternRequired) {
                        for (ExceptionMeta exceptionMeta : methodMeta.throwsExceptions) {
                            TestMethodMeta metaEx = testMethodGenerator.getTestMethodMeta(methodMeta, exceptionMeta);
                            // extension assertions
                            metaEx = appendIfExtensionAssertionsExist(metaEx, config);
                            addTestMethodMetaToListIfNotExists(dest, metaEx);
                        }
                    }
                }
                // -----------
                // Extension
                if (config.isExtensionEnabled) {
                    // extension arg patterns
                    List<ExtArg> extArgs = config.extConfiguration.extArgs;
                    for (ExtArg extArg : extArgs) {
                        // import and className
                        for (ArgTypeMeta argType : methodMeta.argTypes) {
                            if (isCanonicalClassNameUsed(extArg.canonicalClassName, argType.name, targetClassMeta)) {
                                for (ExtArgPattern pattern : extArg.patterns) {
                                    // extension pattern is not matched
                                    // e.g.
                                    // .*?doSomething_A$String_StringIsNull.*?
                                    String IS_ALREADY_EXISTS_FOR_PATTERN = RegExp.Anything_ZeroOrMore_Min
                                            + testMethodNamePrefix + config.testMethodName.basicDelimiter
                                            + extArg.getCanonicalClassNameInMethodName() + "Is"
                                            + pattern.getNameWhichFirstCharIsUpper() + RegExp.Anything_ZeroOrMore_Min;
                                    IS_ALREADY_EXISTS_FOR_PATTERN = Matcher
                                            .quoteReplacement(IS_ALREADY_EXISTS_FOR_PATTERN);
                                    if (!checkTargetSourceCode.matches(IS_ALREADY_EXISTS_FOR_PATTERN)) {
                                        // testing target access modifier
                                        TestMethodMeta meta = testMethodGenerator.getTestMethodMeta(methodMeta, null);
                                        meta.extArgPattern = pattern;
                                        // extension assertions
                                        meta = appendIfExtensionAssertionsExist(meta, config);
                                        addTestMethodMetaToListIfNotExists(dest, meta);
                                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.