DataBundles extends Bundles { public static long getListSize(Path list) throws IOException { try (DirectoryStream<Path> ds = newDirectoryStream(list)) { long max = -1L; for (Path entry : ds) try { long entryNum = getEntryNumber(entry); if (entryNum > max) max = entryNum; } catch (NumberFormatException ex) { } return max + 1; } catch (DirectoryIteratorException ex) { throw ex.getCause(); } }  static void createList(Path path); static void deleteAllExtensions(final Path file); static ErrorDocument getError(Path path); static Path getInputs(Bundle dataBundle); static List<Path> getList(Path list); static Path getListItem(Path list, long position); static Path getOutputs(Bundle dataBundle); static Path getPort(Path map, String portName); static NavigableMap<String, Path> getPorts(Path path); static boolean hasInputs(Bundle dataBundle); static boolean hasOutputs(Bundle dataBundle); static boolean isError(Path path); static boolean isList(Path path); static boolean isMissing(Path item); static boolean isValue(Path item); static Path newListItem(Path list); static Path setError(Path path, ErrorDocument error); static Path setError(Path errorPath, String message, String trace,
			Path... causedBy); static Path setReference(Path path, URI reference); static void setStringValue(Path path, String string); static Path getWorkflowRunProvenance(Bundle dataBundle); static Path getWorkflowRunReport(Bundle dataBundle); static JsonNode getWorkflowRunReportAsJson(Bundle dataBundle); static void setWorkflowRunReport(Bundle dataBundle,
			JsonNode workflowRunReport); static Path getWorkflow(Bundle dataBundle); static Path getWorkflowDescription(Bundle dataBundle); static void setWorkflowBundle(Bundle dataBundle,
			WorkflowBundle wfBundle); static WorkflowBundle getWorkflowBundle(Bundle dataBundle); static Path getIntermediates(Bundle dataBundle); static Path getIntermediate(Bundle dataBundle, UUID uuid); static long getListSize(Path list); @SuppressWarnings({ "unchecked", "rawtypes" }) static Object resolve(Path path, ResolveOptions... options); static Stream<T> resolveAsStream(Path path, Class<T> type); static WorkflowBundleIO getWfBundleIO(); static void setWfBundleIO(WorkflowBundleIO wfBundleIO);  }
@Test public void getListSize() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path list = DataBundles.getPort(inputs, "in1"); DataBundles.createList(list); for (int i = 0; i < 5; i++) { Path item = DataBundles.newListItem(list); DataBundles.setStringValue(item, "item " + i); } assertEquals(5, DataBundles.getListSize(list)); Path item5 = DataBundles.getListItem(list, 5); assertTrue(item5.getFileName().toString().contains("5")); DataBundles.setStringValue(item5, "item 5"); assertEquals(6, DataBundles.getListSize(list)); Path item8 = DataBundles.getListItem(list, 8); assertTrue(item8.getFileName().toString().contains("8")); DataBundles.setStringValue(item8, "item 8"); assertEquals(9, DataBundles.getListSize(list)); long highNumber = 3l * Integer.MAX_VALUE; Path itemHigh = DataBundles.getListItem(list, highNumber); assertTrue(itemHigh.getFileName().toString().contains(Long.toString(highNumber))); DataBundles.setStringValue(itemHigh, "item 6442450941"); assertEquals(highNumber+1l, DataBundles.getListSize(list)); }