RoleUtils { public static String extractAppIdFromMasterRoleName(String masterRoleName) { Iterator<String> parts = STRING_SPLITTER.split(masterRoleName).iterator(); if (parts.hasNext() && parts.next().equals(RoleType.MASTER) && parts.hasNext()) { return parts.next(); } return null; }  static String buildAppMasterRoleName(String appId); static String extractAppIdFromMasterRoleName(String masterRoleName); static String extractAppIdFromRoleName(String roleName); static String buildAppRoleName(String appId, String roleType); static String buildModifyNamespaceRoleName(String appId, String namespaceName); static String buildModifyNamespaceRoleName(String appId, String namespaceName, String env); static String buildModifyDefaultNamespaceRoleName(String appId); static String buildReleaseNamespaceRoleName(String appId, String namespaceName); static String buildReleaseNamespaceRoleName(String appId, String namespaceName, String env); static String buildNamespaceRoleName(String appId, String namespaceName, String roleType); static String buildNamespaceRoleName(String appId, String namespaceName, String roleType, String env); static String buildReleaseDefaultNamespaceRoleName(String appId); static String buildNamespaceTargetId(String appId, String namespaceName); static String buildNamespaceTargetId(String appId, String namespaceName, String env); static String buildDefaultNamespaceTargetId(String appId); static String buildCreateApplicationRoleName(String permissionType, String permissionTargetId);  }
@Test public void testExtractAppIdFromMasterRoleName() throws Exception { assertEquals("someApp", RoleUtils.extractAppIdFromMasterRoleName("Master+someApp")); assertEquals("someApp", RoleUtils.extractAppIdFromMasterRoleName("Master+someApp+xx")); assertNull(RoleUtils.extractAppIdFromMasterRoleName("ReleaseNamespace+app1+application")); }