title: Custom attribute factories for MeanBean EqualsMethodTester and HashCodeMethodTester
body: <p>Is it possible to configure custom factories to generate values for the <code>EqualsMethodTester</code> and <code>HashCodeMethodTester</code> classes from <code>org.meanbean.test</code>?  When I pass the Configuration which works for <code>BeanTester</code> to <code>EqualsMethodTester</code>, I get the following messages in the error traceback: </p>
  
  <p><strong>org.meanbean.factories.ObjectCreationException: Failed to create a value for property [demoUrl].</strong></p>
  
  <p><strong>Failed to find suitable Factory for property=[demoUrl] of type=[class java.net.URL]. Please register a custom Factory.</strong></p>
  
  <p><strong>org.meanbean.factories.ObjectCreationException: Failed to instantiate object of type [java.net.URL] due to NoSuchMethodException.</strong></p>
  
  <p><strong>java.lang.NoSuchMethodException: <code>java.net.URL.&lt;init&gt;()</code></strong></p>
  
  <p>(Both <code>EqualsMethodTester</code> and <code>HashCodeMethodTester</code> give this error.  Adding "demoUrl" to the list of <code>insignificantProperties</code> for <code>EqualsMethodTester().testEqualsMethod()</code> makes no difference.  Stepping through the code implies my URLFactory.create() isn't called at all.)</p>
  
  <p>I do not see any options for passing the configuration into <code>HashCodeMethodTester</code>.  I've skimmed documentation at the following sites, but have found neither a solution nor acknowledgement of the missing functionality: <a href="http://meanbean.sourceforge.net/docs/2.0.3/public/org/meanbean/test/EqualsMethodTester.html" rel="nofollow noreferrer">http://meanbean.sourceforge.net/docs/2.0.3/public/org/meanbean/test/EqualsMethodTester.html</a>
  <a href="http://meanbean.sourceforge.net/docs/2.0.3/public/org/meanbean/test/HashCodeMethodTester.html" rel="nofollow noreferrer">http://meanbean.sourceforge.net/docs/2.0.3/public/org/meanbean/test/HashCodeMethodTester.html</a>
  <a href="http://meanbean.sourceforge.net/docs/2.0.3/public/org/meanbean/test/ConfigurationBuilder.html" rel="nofollow noreferrer">http://meanbean.sourceforge.net/docs/2.0.3/public/org/meanbean/test/ConfigurationBuilder.html</a>
  <a href="http://meanbean.sourceforge.net/docs/2.0.3/Mean_Bean_2.0.3_User_Guide.pdf" rel="nofollow noreferrer">http://meanbean.sourceforge.net/docs/2.0.3/Mean_Bean_2.0.3_User_Guide.pdf</a></p>
  
  <p>(I'm using MeanBean v 2.0.3 and Java 1.8.)</p>
  
  <p>I have the following class, using <code>java.net.URL</code>:</p>
  
  <pre><code>public class Product {
      private String name;
      private URL demoUrl;
  
      public Product(){
          super();
      }
  
      public int hashCode() {
          return Objects.hash(getName(), whitehawkSKU);
      }
  
      public boolean equals(Object obj) {
          if (obj == null) {
              return false;
          }
          if (obj == this) { 
              return true;
          }
          if (obj.getClass() != getClass()) {
              return false;
          }
          Product other = (Product) obj;
          return Objects.equals(getName(), other.getName());
      }
  
      public String getName() {
          return this.name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public URL getDemoUrl() {
          return demoUrl;
      }
  
      public void setDemoUrl(URL demoUrl) {
          this.demoUrl = demoUrl;
      }
  
  }
  </code></pre>
  
  <p>To handle the URL field, I created a custom factory, as per <a href="https://stackoverflow.com/questions/36640299/meanbean-failed-to-test-bean-with-arrays">meanbean: failed to test bean with arrays</a> and it works for <code>BeanTester</code> but not for <code>EqualsMethodTester</code>:</p>
  
  <pre><code>import org.meanbean.lang.Factory;
  
  import java.net.MalformedURLException;
  import java.net.URL;
  
  public class URLFactory implements Factory&lt;URL&gt; {
      private static int counter = 0;
  
      @Override
      public URL create() {
          String host = "http://test." + counter + ".url/";
          try {
              return new URL(host);
          }
          catch (MalformedURLException except) {
              return null;
          }
      }
  }
  </code></pre>
  
  <p>My test methods are as follows:</p>
  
  <pre><code>private Configuration configureMeanBeanTests() {
      URLFactory urlFactory = new URLFactory();
      return new ConfigurationBuilder()
          .overrideFactory("demoUrl", urlFactory).build();
  }
  
  @Test
  public void testAccessors() {
      new BeanTester().testBean(Product.class, configureMeanBeanTests());
  }
  
  @Test
  public void testEquals() {
      new EqualsMethodTester().testEqualsMethod(
          Product.class,
          configureMeanBeanTests(),
          "name",
          "demoUrl"
      );
  }
  
  @Test
  public void testHashCode() {
      new HashCodeMethodTester().testHashCodeMethod(Product.class);
  }
  </code></pre>
  
  <p>What am I missing?</p>