use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testTypeVariableBoundariesComparable.
@Test
public void testTypeVariableBoundariesComparable() {
TypeVariable<?> comparableTypeVariable = ComparableBoundary.class.getTypeParameters()[0];
GenericClass listOfIntegerClass = new GenericClass(Integer.class);
GenericClass listOfSerializableClass = new GenericClass(Serializable.class);
Assert.assertTrue(listOfIntegerClass.satisfiesBoundaries(comparableTypeVariable));
Assert.assertFalse(listOfSerializableClass.satisfiesBoundaries(comparableTypeVariable));
}
use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testGenericInstantiationMapSubclass.
@SuppressWarnings("rawtypes")
@Test
public void testGenericInstantiationMapSubclass() throws ConstructionFailedException {
GenericClass mapOfStringAndWildcard = new GenericClass(new TypeToken<Map<String, ?>>() {
}.getType());
GenericClass hashMapClass = new GenericClass(new TypeToken<HashMap>() {
}.getType());
GenericClass instantiatedClass = hashMapClass.getWithParametersFromSuperclass(mapOfStringAndWildcard);
// GenericClass instantiatedClass = linkedlistOfTypeVariable.getGenericInstantiation(listOfInteger.getTypeVariableMap());
System.out.println(instantiatedClass.toString());
Assert.assertEquals(String.class, instantiatedClass.getParameterTypes().get(0));
}
use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testGuavaExample.
@Test
public void testGuavaExample() {
Type abstractGuavaExampleString = new TypeToken<AbstractGuavaExample<String>>() {
}.getType();
Type guavaExample5 = new TypeToken<GuavaExample5<String>>() {
}.getType();
GenericClass abstractClass = new GenericClass(abstractGuavaExampleString);
GenericClass concreteClass = new GenericClass(guavaExample5);
Assert.assertTrue(TypeUtils.isAssignable(concreteClass.getType(), abstractClass.getType()));
Assert.assertTrue("Cannot assign " + concreteClass + " to " + abstractClass, abstractClass.isAssignableFrom(concreteClass));
Assert.assertTrue(concreteClass.isAssignableTo(abstractClass));
}
use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testWildcardClassloader.
@Test
public void testWildcardClassloader() {
GenericClass clazz = new GenericClass(Class.class).getWithWildcardTypes();
assertEquals("java.lang.Class<?>", clazz.getTypeName());
clazz.changeClassLoader(TestGenericClass.class.getClassLoader());
assertEquals("java.lang.Class<?>", clazz.getTypeName());
}
use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testGenericSuperclassToTypeVariableList.
@SuppressWarnings("rawtypes")
@Test
public void testGenericSuperclassToTypeVariableList() {
GenericClass listOfTypeVariable = new GenericClass(new TypeToken<List>() {
}.getType());
GenericClass linkedlistOfInteger = new GenericClass(new TypeToken<LinkedList<Integer>>() {
}.getType());
Assert.assertTrue(linkedlistOfInteger.canBeInstantiatedTo(listOfTypeVariable));
Assert.assertFalse(listOfTypeVariable.canBeInstantiatedTo(linkedlistOfInteger));
}
Aggregations