S3Utils { static String getBaseDirectory(Repository repository) { StringBuilder sb = new StringBuilder(repository.getBasedir()).deleteCharAt(0); if ((sb.length() != 0) && (sb.charAt(sb.length() - 1) != '/')) { sb.append('/'); } return sb.toString(); } private  S3Utils();   }
@Test public void getBaseDirectory() { assertEquals("", S3Utils.getBaseDirectory(createRepository(""))); assertEquals("", S3Utils.getBaseDirectory(createRepository("/"))); assertEquals("foo/", S3Utils.getBaseDirectory(createRepository("/foo"))); assertEquals("foo/", S3Utils.getBaseDirectory(createRepository("/foo/"))); assertEquals("foo/bar/", S3Utils.getBaseDirectory(createRepository("/foo/bar"))); assertEquals("foo/bar/", S3Utils.getBaseDirectory(createRepository("/foo/bar/"))); }