UriBuilder { public static String concatUriSegments(String... segments) { StringBuilder uri = new StringBuilder(); for (int i = 0; i < segments.length; i++) { if (i == 0) { uri.append(segments[0]); } else { uri.append("/").append(segments[i]); } } return cleanUri(uri.toString()); } private  UriBuilder(); static String concatUriSegments(String... segments); static String cleanUri(String uri);  }
@Test public void uriWithTrailingSlash() { Assert.assertEquals("segment1/segment2/segment3", UriBuilder.concatUriSegments("segment1/", "segment2", "segment3")); }
@Test public void uriWithTrailingAndLeadingSlash() { Assert.assertEquals("segment1/segment2", UriBuilder.concatUriSegments("segment1/", "/segment2")); }
@Test public void uriWithLeadingSlash() { Assert.assertEquals("segment1/segment2", UriBuilder.concatUriSegments("segment1", "/segment2")); }
@Test public void uriWithNoSlash() { Assert.assertEquals("segment1/segment2/segment3", UriBuilder.concatUriSegments("segment1", "segment2", "segment3")); }