LdapRdnComponent implements Comparable, Serializable { public int compareTo(Object obj) { LdapRdnComponent that = (LdapRdnComponent) obj; int keyCompare = this.key.toLowerCase().compareTo(that.key.toLowerCase()); if(keyCompare == 0) { return this.value.toLowerCase().compareTo(that.value.toLowerCase()); } else { return keyCompare; } } LdapRdnComponent(String key, String value);  LdapRdnComponent(String key, String value, boolean decodeValue); String getKey(); void setKey(String key); String getValue(); void setValue(String value); String toString(); String getLdapEncoded(); String encodeUrl(); int hashCode(); boolean equals(Object obj); int compareTo(Object obj); LdapRdnComponent immutableLdapRdnComponent(); static final boolean DONT_DECODE_VALUE; }
@Test public void testCompareTo_Less() { LdapRdnComponent component1 = new LdapRdnComponent("cn", "john doe"); LdapRdnComponent component2 = new LdapRdnComponent("sn", "doe"); int result = component1.compareTo(component2); assertThat(result < 0).isTrue(); }
@Test public void testCompareTo_Greater() { LdapRdnComponent component1 = new LdapRdnComponent("sn", "doe"); LdapRdnComponent component2 = new LdapRdnComponent("cn", "john doe"); int result = component1.compareTo(component2); assertThat(result > 0).isTrue(); }
@Test public void testCompareTo_Equal() { LdapRdnComponent component1 = new LdapRdnComponent("cn", "john doe"); LdapRdnComponent component2 = new LdapRdnComponent("cn", "john doe"); int result = component1.compareTo(component2); assertThat(result).isEqualTo(0); }
@Test public void testCompareTo_DifferentCase_LDAP259() { LdapRdnComponent component1 = new LdapRdnComponent("cn", "john doe"); LdapRdnComponent component2 = new LdapRdnComponent("CN", "John Doe"); assertThat(component2).as("Should be equal").isEqualTo(component1); assertThat(component1.compareTo(component2) == 0).as("0 should be returned by compareTo").isTrue(); }