CloudnamePath { @Override public boolean equals(final Object other) { if (other == null || !(other instanceof CloudnamePath)) { return false; } final CloudnamePath otherPath = (CloudnamePath) other; return Arrays.deepEquals(otherPath.pathElements, pathElements); } CloudnamePath(final String[] pathElements);  CloudnamePath(final CloudnamePath path, final String additionalElement); static boolean isValidPathElementName(final String name); int length(); String join(final char separator); String get(final int index); boolean isSubpathOf(final CloudnamePath other); CloudnamePath getParent(); @Override boolean equals(final Object other); @Override int hashCode(); @Override String toString();  }
@Test public void equalsTest() { final CloudnamePath twoA = new CloudnamePath(twoElements); final CloudnamePath twoB = new CloudnamePath(twoElements); final CloudnamePath none = new CloudnamePath(emptyElements); final CloudnamePath entirelyDifferent = new CloudnamePath(new String[] { "foo", "2" }); assertThat("Identical paths are equal", twoA.equals(twoB), is(true)); assertThat("Hash codes for equal objects are the same", twoA.hashCode(), is(twoB.hashCode())); assertThat("Identical paths are equal, ignore order", twoB, is(equalTo(twoA))); assertThat("Paths aren't equal to strings", twoA.equals(""), is(false)); assertThat("Empty path does not equal actual path", twoA, is(not(equalTo(none)))); assertThat("Null elements aren't equal", twoA.equals(null), is(false)); assertThat("Differen is just different", twoA, is(not(equalTo(entirelyDifferent)))); }
@Test public void labelNamesAreCaseInsensitive() { final CloudnamePath one = new CloudnamePath(new String[] { "FirstSecond" }); final CloudnamePath two = new CloudnamePath(new String[] { "fIRSTsECOND" }); assertTrue("Label names aren't case sensitive", one.equals(two)); }