use of com.googlecode.gentyref.TypeToken in project evosuite by EvoSuite.
the class TestGenericClass method testWildcardWithSuperNumberBoundaryInstantiation.
@Test
public void testWildcardWithSuperNumberBoundaryInstantiation() throws ConstructionFailedException {
GenericClass numberWildcardListClass = new GenericClass(new TypeToken<java.util.List<? super Number>>() {
}.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.assertFalse(numberWildcardListClass.isAssignableFrom(integerListClass));
Assert.assertTrue(numberWildcardListClass.isAssignableFrom(numberListClass));
Assert.assertTrue(numberWildcardListClass.isAssignableFrom(objectListClass));
GenericClass integerWildcardListInstantiation = numberWildcardListClass.getGenericInstantiation();
System.out.println(integerWildcardListInstantiation.toString());
Assert.assertTrue(numberWildcardListClass.isAssignableFrom(integerWildcardListInstantiation));
}
use of com.googlecode.gentyref.TypeToken in project evosuite by EvoSuite.
the class TestGenericClass method testGenericInstantiationIntegerList.
@SuppressWarnings("rawtypes")
@Test
public void testGenericInstantiationIntegerList() throws ConstructionFailedException {
GenericClass listOfInteger = new GenericClass(new TypeToken<List<Integer>>() {
}.getType());
GenericClass linkedlistOfTypeVariable = new GenericClass(new TypeToken<LinkedList>() {
}.getType());
GenericClass instantiatedClass = linkedlistOfTypeVariable.getWithParametersFromSuperclass(listOfInteger);
// GenericClass instantiatedClass = linkedlistOfTypeVariable.getGenericInstantiation(listOfInteger.getTypeVariableMap());
Assert.assertEquals(Integer.class, instantiatedClass.getParameterTypes().get(0));
}
use of com.googlecode.gentyref.TypeToken in project evosuite by EvoSuite.
the class TestGenericClass method testGenericSuperclassConcreteList.
@Test
public void testGenericSuperclassConcreteList() {
GenericClass listOfInteger = new GenericClass(new TypeToken<List<Integer>>() {
}.getType());
GenericClass linkedlistOfInteger = new GenericClass(new TypeToken<LinkedList<Integer>>() {
}.getType());
Assert.assertTrue(linkedlistOfInteger.canBeInstantiatedTo(listOfInteger));
Assert.assertFalse(listOfInteger.canBeInstantiatedTo(linkedlistOfInteger));
}
use of com.googlecode.gentyref.TypeToken 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 com.googlecode.gentyref.TypeToken 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