use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testIterableAndListBoundaries.
@SuppressWarnings("rawtypes")
@Test
public void testIterableAndListBoundaries() {
Map<TypeVariable<?>, Type> typeMap = new HashMap<TypeVariable<?>, Type>();
final GenericClass iterableIntegerClass = new GenericClass(new TypeToken<java.lang.Iterable<Integer>>() {
}.getType());
TypeVariable<?> var = new TypeVariable() {
public AnnotatedType[] getAnnotatedBounds() {
return null;
}
@Override
public Type[] getBounds() {
return new Type[] { iterableIntegerClass.getType() };
}
@Override
public GenericDeclaration getGenericDeclaration() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getName() {
return "Test";
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Dummy Variable";
}
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
// TODO Auto-generated method stub
return null;
}
public Annotation[] getAnnotations() {
// TODO Auto-generated method stub
return null;
}
public Annotation[] getDeclaredAnnotations() {
// TODO Auto-generated method stub
return null;
}
};
typeMap.put(var, iterableIntegerClass.getType());
GenericClass arrayListClass = new GenericClass(new TypeToken<java.util.ArrayList<String>>() {
}.getType());
Assert.assertFalse(arrayListClass.satisfiesBoundaries(var, typeMap));
arrayListClass = new GenericClass(new TypeToken<java.util.ArrayList<Integer>>() {
}.getType());
Assert.assertTrue(arrayListClass.satisfiesBoundaries(var, typeMap));
}
use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testWildcardWithSuperIntegerBoundaryInstantiation.
@Test
public void testWildcardWithSuperIntegerBoundaryInstantiation() throws ConstructionFailedException {
GenericClass integerWildcardListClass = new GenericClass(new TypeToken<java.util.List<? super Integer>>() {
}.getType());
GenericClass integerListClass = new GenericClass(new TypeToken<java.util.List<Integer>>() {
}.getType());
GenericClass numberListClass = new GenericClass(new TypeToken<java.util.List<Number>>() {
}.getType());
GenericClass objectListClass = new GenericClass(new TypeToken<java.util.List<Object>>() {
}.getType());
Assert.assertTrue(integerWildcardListClass.isAssignableFrom(integerListClass));
Assert.assertTrue(integerWildcardListClass.isAssignableFrom(numberListClass));
Assert.assertTrue(integerWildcardListClass.isAssignableFrom(objectListClass));
GenericClass integerWildcardListInstantiation = integerWildcardListClass.getGenericInstantiation();
Assert.assertTrue(integerWildcardListClass.isAssignableFrom(integerWildcardListInstantiation));
}
use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testWildcardDateBothBoundaries2.
@Test
public void testWildcardDateBothBoundaries2() {
WildcardType objectType = new WildcardTypeImpl(new Type[] { Comparable.class }, new Type[] { java.util.Date.class });
GenericClass integerClass = new GenericClass(Integer.class);
GenericClass comparableClass = new GenericClass(Comparable.class);
GenericClass dateClass = new GenericClass(java.util.Date.class);
GenericClass sqlDateClass = new GenericClass(java.sql.Date.class);
Assert.assertFalse(integerClass.satisfiesBoundaries(objectType));
Assert.assertFalse(comparableClass.satisfiesBoundaries(objectType));
Assert.assertTrue(dateClass.satisfiesBoundaries(objectType));
// Does not satisfy lower boundary
Assert.assertFalse(sqlDateClass.satisfiesBoundaries(objectType));
}
use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testAssignableIntegerObject.
@Test
public void testAssignableIntegerObject() {
GenericClass clazz1 = new GenericClass(Integer.class);
GenericClass clazz2 = new GenericClass(Object.class);
Assert.assertTrue(clazz1.isAssignableTo(clazz2));
Assert.assertFalse(clazz1.isAssignableFrom(clazz2));
}
use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class MethodDescriptorTest method testMatcher.
@Test
public void testMatcher() throws Exception {
Class<?> klass = Graphics2D.class;
Method m = klass.getDeclaredMethod("getRenderingHint", RenderingHints.Key.class);
MethodDescriptor md = new MethodDescriptor(m, new GenericClass(m.getReturnType()));
String res = md.getInputParameterMatchers();
assertTrue(res, res.contains("any("));
assertTrue(res, res.contains("RenderingHints"));
assertTrue(res, res.contains("Key"));
assertFalse(res, res.contains("$"));
}
Aggregations