use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testWildcardNumberBoundaries.
@Test
public void testWildcardNumberBoundaries() {
WildcardType objectType = new WildcardTypeImpl(new Type[] { Number.class }, new Type[] {});
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.assertTrue(integerClass.satisfiesBoundaries(objectType));
Assert.assertFalse(comparableClass.satisfiesBoundaries(objectType));
Assert.assertFalse(dateClass.satisfiesBoundaries(objectType));
Assert.assertFalse(sqlDateClass.satisfiesBoundaries(objectType));
}
use of org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testWildcardInvalidBoundaries.
@Test
public void testWildcardInvalidBoundaries() {
WildcardType objectType = new WildcardTypeImpl(new Type[] { Number.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.assertFalse(dateClass.satisfiesBoundaries(objectType));
Assert.assertFalse(sqlDateClass.satisfiesBoundaries(objectType));
}
use of org.evosuite.utils.generic.GenericClass 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 org.evosuite.utils.generic.GenericClass 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 org.evosuite.utils.generic.GenericClass in project evosuite by EvoSuite.
the class TestGenericClass method testAssignableIntInteger.
@Test
public void testAssignableIntInteger() {
GenericClass clazz1 = new GenericClass(Integer.class);
GenericClass clazz2 = new GenericClass(int.class);
Assert.assertTrue(clazz1.isAssignableTo(clazz2));
Assert.assertTrue(clazz1.isAssignableFrom(clazz2));
}
Aggregations