Search in sources :

Example 11 with GenericClass

use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.

the class TestClusterGenerator method addDependencies.

private void addDependencies(GenericConstructor constructor, int recursionLevel) {
    if (recursionLevel > Properties.CLUSTER_RECURSION) {
        logger.debug("Maximum recursion level reached, not adding dependencies of {}", constructor);
        return;
    }
    if (dependencyCache.contains(constructor)) {
        return;
    }
    logger.debug("Analyzing dependencies of " + constructor);
    dependencyCache.add(constructor);
    for (java.lang.reflect.Type parameterClass : constructor.getRawParameterTypes()) {
        logger.debug("Adding dependency " + parameterClass);
        addDependency(new GenericClass(parameterClass), recursionLevel);
    }
}
Also used : GenericClass(org.evosuite.utils.generic.GenericClass)

Example 12 with GenericClass

use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.

the class TestClusterGenerator method getAssignableTypes.

// private Set<Class<?>> getConcreteClassesEnum() {
// Set<Class<?>> enumClasses = new LinkedHashSet<Class<?>>();
// for (String className : inheritanceTree.getSubclasses("java.lang.Enum"))
// {
// logger.warn("Enum candidate: " + className);
// }
// 
// return enumClasses;
// }
private List<List<GenericClass>> getAssignableTypes(GenericClass clazz) {
    List<List<GenericClass>> tuples = new ArrayList<>();
    // logger.info("Parameters of " + clazz.getSimpleName() + ": "
    // + clazz.getNumParameters());
    boolean first = true;
    for (java.lang.reflect.Type parameterType : clazz.getParameterTypes()) {
        // logger.info("Current parameter: " + parameterType);
        List<GenericClass> assignableClasses = getAssignableTypes(parameterType);
        List<List<GenericClass>> newTuples = new ArrayList<>();
        for (GenericClass concreteClass : assignableClasses) {
            if (first) {
                List<GenericClass> tuple = new ArrayList<>();
                tuple.add(concreteClass);
                newTuples.add(tuple);
            } else {
                for (List<GenericClass> t : tuples) {
                    List<GenericClass> tuple = new ArrayList<>(t);
                    tuple.add(concreteClass);
                    newTuples.add(tuple);
                }
            }
        }
        tuples = newTuples;
        first = false;
    }
    return tuples;
}
Also used : GenericClass(org.evosuite.utils.generic.GenericClass) ArrayList(java.util.ArrayList) MockList(org.evosuite.runtime.mock.MockList) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ResourceList(org.evosuite.classpath.ResourceList)

Example 13 with GenericClass

use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.

the class TestClusterGenerator method getAssignableTypes.

private List<GenericClass> getAssignableTypes(java.lang.reflect.Type type) {
    List<GenericClass> types = new ArrayList<>();
    for (GenericClass clazz : genericCastClasses) {
        if (clazz.isAssignableTo(type)) {
            logger.debug(clazz + " is assignable to " + type);
            types.add(clazz);
        }
    }
    return types;
}
Also used : GenericClass(org.evosuite.utils.generic.GenericClass) ArrayList(java.util.ArrayList)

Example 14 with GenericClass

use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.

the class TestClusterGenerator method addDependencies.

private void addDependencies(GenericField field, int recursionLevel) {
    if (recursionLevel > Properties.CLUSTER_RECURSION) {
        logger.debug("Maximum recursion level reached, not adding dependencies of {}", field);
        return;
    }
    if (dependencyCache.contains(field)) {
        return;
    }
    if (field.getField().getType().isPrimitive() || field.getField().getType().equals(String.class))
        return;
    logger.debug("Analyzing dependencies of " + field);
    dependencyCache.add(field);
    logger.debug("Adding dependency " + field.getName());
    addDependency(new GenericClass(field.getGenericFieldType()), recursionLevel);
}
Also used : GenericClass(org.evosuite.utils.generic.GenericClass)

Example 15 with GenericClass

use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.

the class CastClassManager method addCastClass.

public void addCastClass(Type type, int depth) {
    GenericClass castClazz = new GenericClass(type);
    addCastClass(castClazz.getWithWildcardTypes(), depth);
}
Also used : GenericClass(org.evosuite.utils.generic.GenericClass)

Aggregations

GenericClass (org.evosuite.utils.generic.GenericClass)144 Test (org.junit.Test)64 GenericMethod (org.evosuite.utils.generic.GenericMethod)40 Method (java.lang.reflect.Method)36 VariableReference (org.evosuite.testcase.variable.VariableReference)25 GenericConstructor (org.evosuite.utils.generic.GenericConstructor)24 WildcardType (java.lang.reflect.WildcardType)22 TypeToken (com.googlecode.gentyref.TypeToken)20 ConstructionFailedException (org.evosuite.ga.ConstructionFailedException)17 Type (java.lang.reflect.Type)16 ArrayList (java.util.ArrayList)16 GenericAccessibleObject (org.evosuite.utils.generic.GenericAccessibleObject)16 MethodStatement (org.evosuite.testcase.statements.MethodStatement)15 IntPrimitiveStatement (org.evosuite.testcase.statements.numeric.IntPrimitiveStatement)15 ParameterizedType (java.lang.reflect.ParameterizedType)14 WildcardTypeImpl (org.evosuite.utils.generic.WildcardTypeImpl)10 ConstructorStatement (org.evosuite.testcase.statements.ConstructorStatement)9 AnnotatedType (java.lang.reflect.AnnotatedType)8 LinkedList (java.util.LinkedList)8 List (java.util.List)7