equals

Jesus M. Rodriguez jmrodri at gmail.com
Thu Mar 25 15:41:23 UTC 2010


I brought this up in the hallway today, figured I'd share. What is the
best practices
around equals methods? I made a change to a Consumer's facts list in a test
and expected the test to fail.

        Consumer con1 = new Consumer("name", owner, consumerType);
        Consumer con2 = new Consumer(con1);
        con1.getFacts().put("name1", "value1");
        ...
        assertEquals(con1, con2);

It did NOT fail. The equals of the Consumer checks only that the uuid's are
equal. For the most part this makes sense, but is that really what equals
should check? part of me says no it should check everything, but for the
most part maybe all we care about is that the uuid's are the same for Consumers.

Thoughts?

jesus



More information about the candlepin mailing list