### Question:
MiscIRODSUtils { public static String buildPathFromComponentsUpToIndex(final List<String> pathComponents, final int lastIndex) { if (pathComponents == null) { throw new IllegalArgumentException("null pathComponents"); } StringBuilder sb = new StringBuilder(); int i = 0; for (String pathComponent : pathComponents) { if (!pathComponent.isEmpty()) { if (lastIndex >= 0) { if (i++ >= lastIndex) { break; } } sb.append("/"); sb.append(pathComponent); } } if (sb.length() == 0) { sb.append("/"); } return sb.toString(); } private  MiscIRODSUtils(); static String normalizeIrodsPath(final String irodsPath); static String escapePasswordChars(final String password); static String buildTrashHome(final String userName, final String zoneName); static String buildPathZoneAndHome(final String zoneName); static String buildTrashOrphanPath(final String zoneName); static String buildTrashHome(final String zoneName); static String getDefaultIRODSResourceFromAccountIfFileInZone(final String irodsAbsolutePath,
			final IRODSAccount irodsAccount); static boolean isFileInThisZone(final String irodsAbsolutePath, final IRODSAccount irodsAccount); static String getZoneInPath(final String irodsAbsolutePath); static List<String> breakIRODSPathIntoComponents(final String irodsAbsolutePath); static String buildPathFromComponentsUpToIndex(final List<String> pathComponents, final int lastIndex); static String convertStreamToString(final InputStream inputStream); static String convertStreamToString(final InputStream inputStream, final String encoding); static String getUserInUserName(final String userName); static String getZoneInUserName(final String userName); static String humanReadableByteCount(final long bytes); static String computeMD5HashOfAStringValue(final String input); static String computeHomeDirectoryForIRODSAccount(final IRODSAccount irodsAccount); static String computeHomeDirectoryForIRODSAccountInFederatedZone(final IRODSAccount irodsAccount,
			final String zone); static String computeHomeDirectoryForGivenUserInSameZoneAsIRODSAccount(final IRODSAccount irodsAccount,
			final String irodsUserName); static String computePublicDirectory(final IRODSAccount irodsAccount); static String getLastPathComponentForGivenAbsolutePath(final String collectionPath); static void evaluateSpecCollSupport(final ObjStat objStat); static String buildAbsolutePathFromCollectionParentAndFileName(final String collectionPath,
			final String dataName); static String determineAbsolutePathBasedOnCollTypeInObjectStat(final ObjStat objStat); static CollectionAndPath separateCollectionAndPathFromGivenAbsolutePath(final String filePath); static List<String> getDisplayValuesFromEnum(final Class<T> enumClass); static int countCharsInString(final String stringToCountOccurrancesIn, final char characterToCount); static String padRight(final String s, final int n); static String padLeft(final String s, final int n); static String checkPathSizeForMax(final String path); static String buildIRODSUserHomeForAccountUsingDefaultScheme(final IRODSAccount irodsAccount); static void checkPathSizeForMax(final String parentPath, final String childPath); static final String abbreviateFileName(final String fileName); static final String wrapStringInQuotes(final String string); static final String subtractPrefixFromGivenPath(final String prefix, final String path);  }### Answer:
@Test(expected = IllegalArgumentException.class) public final void testBuildPathFromComponentsWhenNull() throws Exception { MiscIRODSUtils.buildPathFromComponentsUpToIndex(null, -1); }
@Test public final void testBreakAndRebuildPathFromComponentsWhenEmpty() throws Exception { String targetPath = "/"; List<String> pathComponents = new ArrayList<String>(); String actual = MiscIRODSUtils.buildPathFromComponentsUpToIndex(pathComponents, -1); Assert.assertEquals("did not reconstitute path correctly", targetPath, actual); }