@Test(expected = NullPointerException.class) public void testServiceAccountNullEmail() { Identity.serviceAccount(null); }
/** * Converts a string to an {@code Identity}. Used primarily for converting protobuf-generated * policy identities to {@code Identity} objects. */ public static Identity valueOf(String identityStr) { String[] info = identityStr.split(":"); Type type = Type.valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, info[0])); switch (type) { case ALL_USERS: return Identity.allUsers(); case ALL_AUTHENTICATED_USERS: return Identity.allAuthenticatedUsers(); case USER: return Identity.user(info[1]); case SERVICE_ACCOUNT: return Identity.serviceAccount(info[1]); case GROUP: return Identity.group(info[1]); case DOMAIN: return Identity.domain(info[1]); default: throw new IllegalStateException("Unexpected identity type " + type); } } }