### Question:
XmppStringUtils { public static String parseLocalpart(String jid) { int atIndex = jid.indexOf('@'); if (atIndex < 0) { return null; } if (atIndex == 0) { return ""; } int slashIndex = jid.indexOf('/'); if (slashIndex >= 0 && slashIndex < atIndex) { return null; } return jid.substring(0, atIndex); }  static String parseLocalpart(String jid); static String parseDomain(String jid); static String parseResource(String jid); static String parseBareJid(String jid); static boolean isFullJID(String jid); static boolean isBareJid(String jid); static String escapeLocalpart(String localpart); static String unescapeLocalpart(String localpart); static String completeJidFrom(CharSequence localpart, CharSequence domainpart); static String completeJidFrom(String localpart, String domainpart); static String completeJidFrom(CharSequence localpart, CharSequence domainpart, CharSequence resource); static String completeJidFrom(String localpart, String domainpart, String resource); static String generateKey(String element, String namespace);  }### Answer:
@Test public void parseLocalpart() { final String error = "Error parsing localpart"; assertEquals(error, null, XmppStringUtils.parseLocalpart("yahoo.myjabber.net")); assertEquals(error, null, XmppStringUtils.parseLocalpart("yahoo.myjabber.net/registred")); assertEquals(error, "user", XmppStringUtils.parseLocalpart("user@yahoo.myjabber.net/registred")); assertEquals(error, "user", XmppStringUtils.parseLocalpart("user@yahoo.myjabber.net")); assertEquals(error, "", XmppStringUtils.parseLocalpart("@example.org/")); assertEquals(error, null, XmppStringUtils.parseLocalpart("foo.jxmpp.org/resOne@resTwo")); }