StreamIdConversions { public static String parseStreamTypeId(String siteId, String generatedUniqueStreamId) { String subffix = String.format("_%s", siteId).toUpperCase(); if (generatedUniqueStreamId.endsWith(subffix)) { int streamTypeIdLength = generatedUniqueStreamId.length() - subffix.length(); Preconditions.checkArgument(streamTypeIdLength > 0, "Invalid streamId: " + generatedUniqueStreamId + ", streamTypeId is empty"); return generatedUniqueStreamId.substring(0, streamTypeIdLength).toUpperCase(); } else { throw new IllegalArgumentException("Invalid streamId: " + generatedUniqueStreamId + ", not end with \"" + subffix + "\""); } }  static String formStreamTypeId(String streamTypeId); static String formatSiteStreamId(String siteId, String streamTypeId); static String parseStreamTypeId(String siteId, String generatedUniqueStreamId);  }
@Test public void testParseStreamTypeId() { Assert.assertEquals("MOCK_STREAM", StreamIdConversions.parseStreamTypeId("test", "MOCK_STREAM_TEST")); }