public class TestClass {
public class GenericClass<T> {
private T field;
public T getField() { return this.field; }
public void setField(T field) { this.field = field; }
}
public class NonGenericClass extends GenericClass<String> { }
public static void main(String[] args) {
new JFixture().create(NonGenericClass.class);
}
}
This example throws NPE because it can't figure out the actual type for T when attempting to fixture field
Exception in thread "main" java.lang.NullPointerException
at com.flextrade.jfixture.utility.SpecimenType.<init>(SpecimenType.java:37)
at com.flextrade.jfixture.utility.SpecimenType.<init>(SpecimenType.java:12)
at com.flextrade.jfixture.utility.SpecimenType$3.<init>(SpecimenType.java:55)
at com.flextrade.jfixture.utility.SpecimenType.withGenericContext(SpecimenType.java:55)
at com.flextrade.jfixture.utility.ParameterUtils.convertPossibleGenericTypeToSpecimenType(ParameterUtils.java:50)
at com.flextrade.jfixture.builders.GenericMethodBuilder.getMethodReturnType(GenericMethodBuilder.java:36)
at com.flextrade.jfixture.builders.GenericMethodBuilder.create(GenericMethodBuilder.java:27)
at com.flextrade.jfixture.builders.CompositeBuilder.create(CompositeBuilder.java:26)
at com.flextrade.jfixture.behaviours.autoproperty.AutoPropertyBuilder.create(AutoPropertyBuilder.java:22)
at com.flextrade.jfixture.behaviours.recursion.RecursionGuard.create(RecursionGuard.java:33)
at com.flextrade.jfixture.behaviours.noresolution.NoResolutionGuard.create(NoResolutionGuard.java:27)
at com.flextrade.jfixture.behaviours.specimentype.SpecimenTypeInjector.create(SpecimenTypeInjector.java:26)
at com.flextrade.jfixture.SpecimenBuilderContext.resolve(SpecimenBuilderContext.java:13)
at com.flextrade.jfixture.behaviours.autoproperty.AutoPropertyPopulater.populateSetters(AutoPropertyPopulater.java:34)
at com.flextrade.jfixture.behaviours.autoproperty.AutoPropertyPopulater.execute(AutoPropertyPopulater.java:23)
at com.flextrade.jfixture.behaviours.autoproperty.AutoPropertyBuilder.create(AutoPropertyBuilder.java:25)
at com.flextrade.jfixture.behaviours.recursion.RecursionGuard.create(RecursionGuard.java:33)
at com.flextrade.jfixture.behaviours.noresolution.NoResolutionGuard.create(NoResolutionGuard.java:27)
at com.flextrade.jfixture.behaviours.specimentype.SpecimenTypeInjector.create(SpecimenTypeInjector.java:26)
at com.flextrade.jfixture.JFixture.create(JFixture.java:82)
at com.flextrade.jfixture.JFixture.create(JFixture.java:78)
This example throws NPE because it can't figure out the actual type for
T
when attempting to fixturefield