### Question:
KeyValuePair { public static KeyValuePair valueOf( String asString ) { int equalsIndex = asString.indexOf( '=' ); if ( equalsIndex == -1 ) return new KeyValuePair( asString, EMPTY ); String aKey = asString.substring( 0, equalsIndex ); String aValue = equalsIndex == asString.length() - 1 ? EMPTY : asString.substring( equalsIndex + 1 ); return new KeyValuePair( aKey, aValue ); } private  KeyValuePair( String key, String value ); static KeyValuePair valueOf( String asString ); @Override boolean equals( Object that ); @Override int hashCode(); @Override String toString(); final String key; final String value; }### Answer:
@Test( expected = NullPointerException.class ) public void nullArg() { KeyValuePair.valueOf( null ); }
@Test public void empty() { KeyValuePair pair = KeyValuePair.valueOf( "" ); assertEquals( "", pair.key ); assertEquals( "", pair.value ); }
@Test public void noEqualsSign() { KeyValuePair pair = KeyValuePair.valueOf( "aString" ); assertEquals( "aString", pair.key ); assertEquals( "", pair.value ); }
@Test public void signAtEnd() { KeyValuePair pair = KeyValuePair.valueOf( "aKey=" ); assertEquals( "aKey", pair.key ); assertEquals( "", pair.value ); }
@Test public void signAtStart() { KeyValuePair pair = KeyValuePair.valueOf( "=aValue" ); assertEquals( "", pair.key ); assertEquals( "aValue", pair.value ); }
@Test public void typical() { KeyValuePair pair = KeyValuePair.valueOf( "aKey=aValue" ); assertEquals( "aKey", pair.key ); assertEquals( "aValue", pair.value ); }
@Test public void multipleEqualsSignsDoNotMatter() { KeyValuePair pair = KeyValuePair.valueOf( "aKey=1=2=3=4" ); assertEquals( "aKey", pair.key ); assertEquals( "1=2=3=4", pair.value ); }