/** Test method for {@link NullElement#compareTo(Element)}. */
  @Test
  public void testCompareTo() {
    final NullElement a = new NullElement("a");
    final NullElement b = new NullElement("b");
    final Element other = new MaxKeyElement("a");

    assertEquals(0, a.compareTo(a));

    assertTrue(a.compareTo(b) < 0);
    assertTrue(b.compareTo(a) > 0);

    assertTrue(a.compareTo(other) < 0);
    assertTrue(other.compareTo(a) > 0);
  }
  /** Test method for {@link NullElement#equals(java.lang.Object)} . */
  @Test
  public void testEqualsObject() {

    final List<Element> objs1 = new ArrayList<Element>();
    final List<Element> objs2 = new ArrayList<Element>();

    for (final String name : Arrays.asList("1", "foo", "bar", "baz", "2")) {
      objs1.add(new NullElement(name));
      objs2.add(new NullElement(name));
    }

    // Sanity check.
    assertEquals(objs1.size(), objs2.size());

    for (int i = 0; i < objs1.size(); ++i) {
      final Element obj1 = objs1.get(i);
      Element obj2 = objs2.get(i);

      assertTrue(obj1.equals(obj1));
      assertNotSame(obj1, obj2);
      assertEquals(obj1, obj2);

      assertEquals(obj1.hashCode(), obj2.hashCode());

      for (int j = i + 1; j < objs1.size(); ++j) {
        obj2 = objs2.get(j);

        assertFalse(obj1.equals(obj2));
        assertFalse(obj1.hashCode() == obj2.hashCode());
      }

      assertFalse(obj1.equals("foo"));
      assertFalse(obj1.equals(null));
      assertFalse(obj1.equals(new MaxKeyElement(obj1.getName())));
    }
  }