Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public String strValue() {
* policy identities to {@code Identity} objects.
*/
public static Identity valueOf(String identityStr) {
String[] info = identityStr.split(":");
String[] info = identityStr.split(":", 2);
Type type = Type.valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, info[0]));
if (info.length == 1) {
return new Identity(type, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,18 @@ public void testValueOfEmpty() {
Identity.valueOf("");
}

@Test(expected = IllegalArgumentException.class)
public void testValueOfThreePart() {
Identity.valueOf("a:b:c");
}

@Test
public void testUnrecognizedToString() {
assertEquals("a:b", Identity.valueOf("a:b").strValue());
}

@Test
public void testValueOfThreePart() {
Identity identity = Identity.valueOf("a:b:c");
assertEquals("A", identity.getType().name());
assertEquals("b:c", identity.getValue());
}

private void compareIdentities(Identity expected, Identity actual) {
assertEquals(expected, actual);
assertEquals(expected.getType(), actual.getType());
Expand Down