### Question:
Invite { public static Invite fromCanonicalForm(String inviteCode) { String exceptionMessage = "Invite code should be of format host:port:publicKey.curveName~secretKey"; List<String> parts = Splitter.on(':').splitToList(inviteCode); if (parts.size() != 3) { throw new MalformedInviteCodeException(exceptionMessage); } String host = parts.get(0); String portString = parts.get(1); int port = toPort(portString); List<String> keyAndSecret = Splitter.on('~').splitToList(parts.get(2)); if (keyAndSecret.size() != 2) { throw new MalformedInviteCodeException(exceptionMessage); } String fullKey = keyAndSecret.get(0); List<String> splitKey = Splitter.on('.').splitToList(fullKey); if (splitKey.size() != 2) { throw new MalformedInviteCodeException(exceptionMessage); } String keyPart = splitKey.get(0); String secretKeyPart = keyAndSecret.get(1); Signature.Seed secretKey = toSecretKey(secretKeyPart); Ed25519PublicKeyIdentity identity = toPublicKey(keyPart); return new Invite(host, port, identity, secretKey); } Invite(String host, int port, Identity identity, Signature.Seed seedKey); String host(); int port(); Identity identity(); Signature.Seed seedKey(); String toCanonicalForm(); static Invite fromCanonicalForm(String inviteCode); @Override String toString();  }### Answer:
@Test void testParseFromCanonicalMissingHost() { String testInvite = ":@MS/HpeAess0EGruiZjfnc+x+FkPq7qoMqSD4SdvTCtM=.ed25519~IJubWEcZM6usWncF/Lu26CyI3ZiovcHjh9+kBI1hiKI="; try { Invite.fromCanonicalForm(testInvite); fail("Exception expected when host missing from invite code."); } catch (MalformedInviteCodeException malformedInviteCodeException) { } }
@Test void testParseFromCanonicalMissingSeed() { String testInvite = "fake.address.com:8009:@MS/HpeAess0EGruiZjfnc+x+FkPq7qoMqSD4SdvTCtM=.ed25519"; try { Invite.fromCanonicalForm(testInvite); fail("Exception expected when seed missing from invite code."); } catch (MalformedInviteCodeException malformedInviteCodeException) { } }