@Test public void isValueOnError() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); DataBundles.setError(DataBundles.getPort(inputs, "test"), "error", ""); assertFalse(DataBundles.isValue(DataBundles.getPorts(inputs).get("test"))); }
@Test public void getPortChecksExtension() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path portIn1 = DataBundles.getPort(inputs, "in1"); assertFalse(Files.exists(portIn1)); Path ref = DataBundles.setReference(portIn1, URI.create("http://example.com/")); Path portIn1Again = DataBundles.getPort(inputs, "in1"); assertEquals(ref, portIn1Again); assertFalse(portIn1Again.equals(portIn1)); assertTrue(Files.exists(portIn1Again)); }
@Test public void getPort() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path portIn1 = DataBundles.getPort(inputs, "in1"); assertFalse(Files.exists(portIn1)); assertEquals(inputs, portIn1.getParent()); }
@Test public void setReferenceExistsAsReference() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path in1 = DataBundles.getPort(inputs, "in1"); Path ref = DataBundles.setReference(in1, URI.create("http://example.com/")); assertFalse(Files.exists(in1)); assertTrue(Files.isRegularFile(ref)); DataBundles.setReference(in1, URI.create("http://example.com/")); }
@Test public void createList() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path list = DataBundles.getPort(inputs, "in1"); DataBundles.createList(list); assertTrue(Files.isDirectory(list)); }
@Test(expected=FileAlreadyExistsException.class) public void setErrorExistsAsReference() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path in1 = DataBundles.getPort(inputs, "in1"); Path ref = DataBundles.setReference(in1, URI.create("http://example.com/")); assertFalse(Files.exists(in1)); assertTrue(Files.isRegularFile(ref)); DataBundles.setError(in1, "a", "b"); }
@Test(expected = FileAlreadyExistsException.class) public void setReferenceExistsAsList() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path in1 = DataBundles.getPort(inputs, "in1"); DataBundles.createList(in1); assertTrue(Files.isDirectory(in1)); DataBundles.setReference(in1, URI.create("http://example.com/")); }
@Test(expected = FileAlreadyExistsException.class) public void setReferenceExistsAsValue() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path in1 = DataBundles.getPort(inputs, "in1"); DataBundles.setStringValue(in1, "Hello"); assertTrue(Files.isRegularFile(in1)); DataBundles.setReference(in1, URI.create("http://example.com/")); }
@Test(expected=FileAlreadyExistsException.class) public void newListAlreadyExistsAsReference() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path list = DataBundles.getPort(inputs, "in1"); Path ref = DataBundles.setReference(list, URI.create("http://example.com/")); assertFalse(Files.isRegularFile(list)); assertFalse(Files.isDirectory(list)); assertTrue(Files.isRegularFile(ref)); DataBundles.createList(list); }
@Test(expected=FileAlreadyExistsException.class) public void setStringExistsAsReference() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path in1 = DataBundles.getPort(inputs, "in1"); Path ref = DataBundles.setReference(in1, URI.create("http://example.com/")); assertFalse(Files.exists(in1)); assertTrue(Files.isRegularFile(ref)); DataBundles.setStringValue(in1, "Hello"); }
@Test(expected=FileAlreadyExistsException.class) public void setErrorExistsAsValue() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path in1 = DataBundles.getPort(inputs, "in1"); DataBundles.setStringValue(in1, "test"); assertTrue(Files.isRegularFile(in1)); DataBundles.setError(in1, "a", "b"); }
@Test(expected=FileAlreadyExistsException.class) public void newListAlreadyExistsAsError() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path list = DataBundles.getPort(inputs, "in1"); Path err = DataBundles.setError(list, "a", "b"); assertFalse(Files.isRegularFile(list)); assertFalse(Files.isDirectory(list)); assertTrue(Files.isRegularFile(err)); DataBundles.createList(list); }
@Test(expected=FileAlreadyExistsException.class) public void newListAlreadyExistsAsFile() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path list = DataBundles.getPort(inputs, "in1"); DataBundles.setStringValue(list, "A string"); assertTrue(Files.isRegularFile(list)); assertFalse(Files.isDirectory(list)); DataBundles.createList(list); }
@Test(expected=FileAlreadyExistsException.class) public void setStringExistsAsError() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path in1 = DataBundles.getPort(inputs, "in1"); Path err = DataBundles.setError(in1, "x", "X"); assertFalse(Files.exists(in1)); assertTrue(Files.isRegularFile(err)); DataBundles.setStringValue(in1, "Hello"); }
@Test(expected=FileAlreadyExistsException.class) public void setStringExistsAsList() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path in1 = DataBundles.getPort(inputs, "in1"); DataBundles.createList(in1); assertTrue(Files.isDirectory(in1)); DataBundles.setStringValue(in1, "Hello"); }
@Test public void getListItemChecksExtension() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path portIn1 = DataBundles.getPort(inputs, "in1"); Path list = DataBundles.newListItem(portIn1); Path item = DataBundles.newListItem(list); Path ref = DataBundles.setReference(item, URI.create("http://example.com/")); Path itemAgain = DataBundles.getListItem(list, 0); assertEquals(ref, itemAgain); assertFalse(itemAgain.equals(portIn1)); assertTrue(Files.exists(itemAgain)); }
@Test public void setStringExistsAsString() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path in1 = DataBundles.getPort(inputs, "in1"); DataBundles.setStringValue(in1, "A"); assertTrue(Files.isRegularFile(in1)); DataBundles.setStringValue(in1, "B"); assertEquals("B", DataBundles.getStringValue(in1)); }
@Test public void getError() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path portIn1 = DataBundles.getPort(inputs, "in1"); DataBundles.setError(portIn1, "Something did not work", "A very\n long\n error\n trace"); ErrorDocument error = DataBundles.getError(portIn1); assertTrue(error.getCausedBy().isEmpty()); assertEquals("Something did not work", error.getMessage()); // Notice that the lack of trailing \n is preserved assertEquals("A very\n long\n error\n trace", error.getTrace()); assertEquals(null, DataBundles.getError(null)); }
@Test public void isMissing() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path portIn1 = DataBundles.getPort(inputs, "in1"); assertFalse(DataBundles.isList(portIn1)); assertFalse(DataBundles.isValue(portIn1)); assertFalse(DataBundles.isError(portIn1)); assertTrue(DataBundles.isMissing(portIn1)); assertFalse(DataBundles.isReference(portIn1)); }
@Test public void isError() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path portIn1 = DataBundles.getPort(inputs, "in1"); DataBundles.setError(portIn1, "Something did not work", "A very\n long\n error\n trace"); assertFalse(DataBundles.isList(portIn1)); assertFalse(DataBundles.isValue(portIn1)); assertFalse(DataBundles.isMissing(portIn1)); assertFalse(DataBundles.isReference(portIn1)); assertTrue(DataBundles.isError(portIn1)); }