PolicyIdConversions { public static String parsePolicyId(String siteId, String policyName) { String subffix = String.format("_%s", siteId.toLowerCase()); if (policyName.toLowerCase().endsWith(subffix)) { int streamTypeIdLength = policyName.length() - subffix.length(); Preconditions.checkArgument(streamTypeIdLength > 0, "Invalid policyId: " + policyName + ", policyId is empty"); return policyName.substring(0, streamTypeIdLength); } else { return policyName; } }  static String generateUniquePolicyId(String siteId, String policyName); static String parsePolicyId(String siteId, String policyName);  }
@Test public void testParsePolicyId() { Assert.assertEquals("mock_policy", PolicyIdConversions.parsePolicyId("test", "mock_policy_test")); }
@Test public void testParsePolicyId2() { Assert.assertEquals("mock_policy", PolicyIdConversions.parsePolicyId("test", "mock_policy")); }