### Question:
AgentIdentifierParser { public static Set<AgentIdentifier> parse(String raw) { if (Strings.isNullOrEmpty(raw)) { return Collections.emptySet(); } return Stream.of(raw.split(DELIMITER)) .map(String::trim) .map(AgentIdentifierParser::parseValue) .collect(Collectors.toSet()); }  static Set<AgentIdentifier> parse(String raw);  }### Answer:
@Test public void parseNullTest() { Set<AgentIdentifier> set = AgentIdentifierParser.parse(null); assertTrue(set.isEmpty()); }
@Test public void parseEmptyTest() { String raw = ""; Set<AgentIdentifier> set = AgentIdentifierParser.parse(raw); assertTrue(set.isEmpty()); }
@Test public void parseEmptyDelimitrTest() { String raw = "|||"; Set<AgentIdentifier> set = AgentIdentifierParser.parse(raw); assertTrue(set.isEmpty()); }
@Test public void parseOrcidTest() { Set<AgentIdentifier> expected = Collections.singleton( AgentIdentifier.newBuilder() .setType(AgentIdentifierType.ORCID.name()) .setValue("https: .build()); String raw = "https: Set<AgentIdentifier> set = AgentIdentifierParser.parse(raw); assertFalse(set.isEmpty()); assertEquals(expected, set); }
@Test public void parseOrcidWithoutSchemaTest() { Set<AgentIdentifier> expected = Collections.singleton( AgentIdentifier.newBuilder() .setType(AgentIdentifierType.ORCID.name()) .setValue("https: .build()); String raw = "0000-0002-0144-1997"; Set<AgentIdentifier> set = AgentIdentifierParser.parse(raw); assertFalse(set.isEmpty()); assertEquals(expected, set); }
@Test public void parseWikidataTest() { Set<AgentIdentifier> expected = Collections.singleton( AgentIdentifier.newBuilder() .setType(AgentIdentifierType.WIKIDATA.name()) .setValue("https: .build()); String raw = "https: Set<AgentIdentifier> set = AgentIdentifierParser.parse(raw); assertFalse(set.isEmpty()); assertEquals(expected, set); }
@Test public void parseWikidataWithoutSchemaTest() { Set<AgentIdentifier> expected = Collections.singleton( AgentIdentifier.newBuilder() .setType(AgentIdentifierType.WIKIDATA.name()) .setValue("wikidata.org/wiki/0000") .build()); String raw = "wikidata.org/wiki/0000"; Set<AgentIdentifier> set = AgentIdentifierParser.parse(raw); assertFalse(set.isEmpty()); assertEquals(expected, set); }
@Test public void parseOtherTest() { Set<AgentIdentifier> expected = Collections.singleton( AgentIdentifier.newBuilder() .setType(AgentIdentifierType.OTHER.name()) .setValue("something") .build()); String raw = "something"; Set<AgentIdentifier> set = AgentIdentifierParser.parse(raw); assertFalse(set.isEmpty()); assertEquals(expected, set); }
@Test public void parseMixedTest() { Set<AgentIdentifier> expected = Stream.of( AgentIdentifier.newBuilder() .setType(AgentIdentifierType.ORCID.name()) .setValue("https: .build(), AgentIdentifier.newBuilder() .setType(AgentIdentifierType.WIKIDATA.name()) .setValue("wikidata.org/wiki/0000") .build(), AgentIdentifier.newBuilder() .setType(AgentIdentifierType.OTHER.name()) .setValue("something") .build()) .collect(Collectors.toSet()); String raw = "wikidata.org/wiki/0000| something|0000-0002-0144-1997"; Set<AgentIdentifier> set = AgentIdentifierParser.parse(raw); assertFalse(set.isEmpty()); assertEquals(expected, set); }