@Test public void ignores_factory_methods_where_a_singleton_generic_parameter_is_assignable_from_return_type() { this.query = new DefaultFactoryMethodQuery(); List<Method> factoryMethods = this.query.getFactoryMethodsForType(new SpecimenType<GenericTypeWithCopyFactoryMethod<String>>() {}); assertEquals(1, factoryMethods.size()); }
@Override public List<Method> getFactoryMethodsForType(SpecimenType type) { List<Method> factoryMethods = new ArrayList<Method>(); Method[] allMethods = type.getRawType().getMethods(); for (Method method : allMethods) { if (isStatic(method) && returnTypeIsAssignable(method, type) && !isCopyConstructorMethod(type, method)) factoryMethods.add(method); } if (this.comparator != null) { Collections.sort(factoryMethods, this.comparator); } return factoryMethods; }
DefaultFactoryMethodQuery implements FactoryMethodQuery { @Override public List<Method> getFactoryMethodsForType(SpecimenType type) { List<Method> factoryMethods = new ArrayList<Method>(); Method[] allMethods = type.getRawType().getMethods(); for (Method method : allMethods) { if (isStatic(method) && returnTypeIsAssignable(method, type) && !isCopyConstructorMethod(type, method)) factoryMethods.add(method); } if (this.comparator != null) { Collections.sort(factoryMethods, this.comparator); } return factoryMethods; } }
DefaultFactoryMethodQuery implements FactoryMethodQuery { @Override public List<Method> getFactoryMethodsForType(SpecimenType type) { List<Method> factoryMethods = new ArrayList<Method>(); Method[] allMethods = type.getRawType().getMethods(); for (Method method : allMethods) { if (isStatic(method) && returnTypeIsAssignable(method, type) && !isCopyConstructorMethod(type, method)) factoryMethods.add(method); } if (this.comparator != null) { Collections.sort(factoryMethods, this.comparator); } return factoryMethods; } DefaultFactoryMethodQuery();  DefaultFactoryMethodQuery(Comparator<Method> comparator); }
DefaultFactoryMethodQuery implements FactoryMethodQuery { @Override public List<Method> getFactoryMethodsForType(SpecimenType type) { List<Method> factoryMethods = new ArrayList<Method>(); Method[] allMethods = type.getRawType().getMethods(); for (Method method : allMethods) { if (isStatic(method) && returnTypeIsAssignable(method, type) && !isCopyConstructorMethod(type, method)) factoryMethods.add(method); } if (this.comparator != null) { Collections.sort(factoryMethods, this.comparator); } return factoryMethods; } DefaultFactoryMethodQuery();  DefaultFactoryMethodQuery(Comparator<Method> comparator); @Override List<Method> getFactoryMethodsForType(SpecimenType type); }
DefaultFactoryMethodQuery implements FactoryMethodQuery { @Override public List<Method> getFactoryMethodsForType(SpecimenType type) { List<Method> factoryMethods = new ArrayList<Method>(); Method[] allMethods = type.getRawType().getMethods(); for (Method method : allMethods) { if (isStatic(method) && returnTypeIsAssignable(method, type) && !isCopyConstructorMethod(type, method)) factoryMethods.add(method); } if (this.comparator != null) { Collections.sort(factoryMethods, this.comparator); } return factoryMethods; } DefaultFactoryMethodQuery();  DefaultFactoryMethodQuery(Comparator<Method> comparator); @Override List<Method> getFactoryMethodsForType(SpecimenType type);  }