RegexMountPointInterceptorFactory { public static RegexMountPointInterceptor create( String interceptorSettingsString) { int typeTagIndex = interceptorSettingsString .indexOf(RegexMountPoint.INTERCEPTOR_INTERNAL_SEP); if (typeTagIndex == -1 || (typeTagIndex == ( interceptorSettingsString.length() - 1))) { return null; } String typeTag = interceptorSettingsString.substring(0, typeTagIndex).trim() .toLowerCase(); RegexMountPointInterceptorType interceptorType = RegexMountPointInterceptorType.get(typeTag); if (interceptorType == null) { return null; } switch (interceptorType) { case REPLACE_RESOLVED_DST_PATH: RegexMountPointInterceptor interceptor = RegexMountPointResolvedDstPathReplaceInterceptor .deserializeFromString(interceptorSettingsString); return interceptor; default: return null; } } private  RegexMountPointInterceptorFactory(); static RegexMountPointInterceptor create(
      String interceptorSettingsString);  }
@Test public void testCreateNormalCase() { String replaceInterceptorStr = RegexMountPointInterceptorType.REPLACE_RESOLVED_DST_PATH.getConfigName() + Character.toString(RegexMountPoint.INTERCEPTOR_INTERNAL_SEP) + "src" + Character .toString(RegexMountPoint.INTERCEPTOR_INTERNAL_SEP) + "replace"; RegexMountPointInterceptor interceptor = RegexMountPointInterceptorFactory.create(replaceInterceptorStr); Assert.assertTrue( interceptor instanceof RegexMountPointResolvedDstPathReplaceInterceptor); }
@Test public void testCreateBadCase() { String replaceInterceptorStr = RegexMountPointInterceptorType.REPLACE_RESOLVED_DST_PATH.getConfigName() + "___" + Character .toString(RegexMountPoint.INTERCEPTOR_INTERNAL_SEP) + "src" + Character.toString(RegexMountPoint.INTERCEPTOR_INTERNAL_SEP) + "replace"; RegexMountPointInterceptor interceptor = RegexMountPointInterceptorFactory.create(replaceInterceptorStr); Assert.assertTrue(interceptor == null); }