DataBundles extends Bundles { public static Path getListItem(Path list, long position) throws IOException { if (position < 0) throw new IllegalArgumentException( "Position must be 0 or more, not: " + position); return anyExtension(list, Long.toString(position)); }  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 getListItem() 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); } Path item5 = DataBundles.getListItem(list, 5); assertTrue(item5.getFileName().toString().contains("5")); DataBundles.setStringValue(item5, "item 5"); Path item8 = DataBundles.getListItem(list, 8); assertTrue(item8.getFileName().toString().contains("8")); DataBundles.setStringValue(item8, "item 8"); Path item7 = DataBundles.getListItem(list, 7); assertFalse(Files.exists(item7)); assertFalse(DataBundles.isList(item7)); assertFalse(DataBundles.isError(item7)); assertFalse(DataBundles.isValue(item7)); assertTrue(DataBundles.isMissing(item7)); Path item2 = DataBundles.getListItem(list, 2); DataBundles.setStringValue(item2, "replaced"); List<Path> listItems = DataBundles.getList(list); assertEquals(9, listItems.size()); assertEquals("item 0", DataBundles.getStringValue(listItems.get(0))); assertEquals("item 1", DataBundles.getStringValue(listItems.get(1))); assertEquals("replaced", DataBundles.getStringValue(listItems.get(2))); assertEquals("item 3", DataBundles.getStringValue(listItems.get(3))); assertEquals("item 4", DataBundles.getStringValue(listItems.get(4))); assertEquals("item 5", DataBundles.getStringValue(listItems.get(5))); assertNull(listItems.get(6)); assertNull(listItems.get(7)); assertEquals("item 8", DataBundles.getStringValue(listItems.get(8))); }