### Question:
AuthorizationHeaders { public static String[] decode( String authorizationHeader ) { String[] parts = authorizationHeader.trim().split( " " ); String tokenSegment = parts[parts.length - 1]; if ( tokenSegment.trim().length() == 0 ) { return null; } String decoded = Base64.base64Decode( tokenSegment ); if ( decoded.length() < 1 ) { return null; } String[] userAndPassword = decoded.split( ":", 2 ); if ( userAndPassword.length != 2 ) { return null; } return userAndPassword; } private  AuthorizationHeaders(); static String[] decode( String authorizationHeader );  }### Answer:
@Test public void shouldParseHappyPath() { String username = "jake"; String password = "qwerty123456"; String header = HTTP.basicAuthHeader( username, password ); String[] parsed = decode( header ); assertEquals( username, parsed[0] ); assertEquals( password, parsed[1] ); }
@Test public void shouldHandleSadPaths() { assertNull( decode( "" ) ); assertNull( decode( "Basic" ) ); assertNull( decode( "Basic not valid value" ) ); assertNull( decode( "Basic " + Base64.getEncoder().encodeToString( "".getBytes() ) ) ); }