FileResourceKeyUtil { public static String makeKey( FileResourceDomain domain, Optional<String> key ) { if ( key.isPresent() ) { return domain.getContainerName() + "/" + key.get(); } return generateStorageKey( domain ); }  static String makeKey( FileResourceDomain domain, Optional<String> key );  }
@Test public void verifyBuildKey() { String key = FileResourceKeyUtil.makeKey( FileResourceDomain.DOCUMENT, Optional.empty() ); assertThat( key, startsWith( "document/" ) ); assertEquals( 36, key.substring( "document/".length() ).length() ); key = FileResourceKeyUtil.makeKey( FileResourceDomain.DOCUMENT, Optional.of( "myKey" ) ); assertThat( key, is( "document/myKey" ) ); }