<commit_before>/* This class is part of the XP framework's EAS connectivity
 *
 * $Id$
 */

package net.xp_framework.unittest;

import org.junit.Test;
import net.xp_framework.unittest.Person;
import java.lang.reflect.Method;

import static net.xp_framework.easc.util.MethodMatcher.methodFor;
import static org.junit.Assert.*;

/**
 * Test method matching functionality. 
 *
 * Note: This is a JUnit 4 testcase!
 *
 * @see   net.xp_framework.easc.util.MethodMatcher
 */
public class MethodMatcherTest {

    /**
     * Returns a string representation of a method
     *
     * Format:
     *   [returnType] [methodName]:[numArguments]([optArgumentList])
     *
     * Notes:
     * - returnType is the return type's class name
     * - optArgumentList is a comma-separated list of argument class names
     *
     * Returns the string "(null)" if the specified argument is NULL
     *
     * @see     java.lang.reflect.Method#toString
     * @access  protected
     * @param   java.lang.reflect.Method m
     * @return  java.lang.String
     */
    protected String methodString(Method m) {
        if (m == null) return "(null)";   // Catch border-case, prevent NPE

        Class[] parameters= m.getParameterTypes();
        StringBuffer buf= new StringBuffer()
            .append(m.getReturnType().getName())
            .append(' ')
            .append(m.getName())
            .append(':')
            .append(parameters.length)
            .append("(");
        
        // Append parameter types
        for (Class c: parameters) {
            buf.append(c.getName()).append(", ");
        }
        if (parameters.length > 0) {  
            buf.delete(buf.length() - 2, buf.length());
        }
        
        return buf.append(')').toString();
    }

    /**
     * Ensures getId() will be found when search for no-arg version
     *
     * @access  public
     * @throws  java.lang.Exception<commit_msg>- QA: Performance optimization in methodString()<commit_after>/* This class is part of the XP framework's EAS connectivity
 *
 * $Id$
 */

package net.xp_framework.unittest;

import org.junit.Test;
import net.xp_framework.unittest.Person;
import java.lang.reflect.Method;

import static net.xp_framework.easc.util.MethodMatcher.methodFor;
import static org.junit.Assert.*;

/**
 * Test method matching functionality. 
 *
 * Note: This is a JUnit 4 testcase!
 *
 * @see   net.xp_framework.easc.util.MethodMatcher
 */
public class MethodMatcherTest {

    /**
     * Returns a string representation of a method
     *
     * Format:
     *   [returnType] [methodName]:[numArguments]([optArgumentList])
     *
     * Notes:
     * - returnType is the return type's class name
     * - optArgumentList is a comma-separated list of argument class names
     *
     * Returns the string "(null)" if the specified argument is NULL
     *
     * @see     java.lang.reflect.Method#toString
     * @access  protected
     * @param   java.lang.reflect.Method m
     * @return  java.lang.String
     */
    protected String methodString(Method m) {
        if (m == null) return "(null)";   // Catch border-case, prevent NPE

        Class[] parameters= m.getParameterTypes();
        StringBuffer buf= new StringBuffer()
            .append(m.getReturnType().getName())
            .append(' ')
            .append(m.getName())
            .append(':')
            .append(parameters.length)
            .append("(");
        
        // Append parameter types
        if (parameters.length > 0) {  
            for (Class c: parameters) {
                buf.append(c.getName()).append(", ");
            }
            buf.delete(buf.length() - 2, buf.length());
        }
        
        return buf.append(')').toString();
    }

    /**
     * Ensures getId() will be found when search for no-arg version
     *
     * @access  public
     * @throws  java.lang.Exception
{'fraction_non_alphanumeric': 0.12271203918535704, 'fraction_numerical': 0.0015467904098994587, 'mean_word_length': 2.1934156378600824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3959894', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1094, 'n_words': 292}