From 8d316a69defd34163959ed39d59af31acd79b0a7 Mon Sep 17 00:00:00 2001 From: jo-pol Date: Thu, 29 Aug 2024 09:46:19 +0200 Subject: [PATCH] test mix up of dir and file --- .../command/CollectionCreateDatasetTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/java/nl/knaw/dans/dvcli/command/CollectionCreateDatasetTest.java b/src/test/java/nl/knaw/dans/dvcli/command/CollectionCreateDatasetTest.java index ebcd9ef..a386736 100644 --- a/src/test/java/nl/knaw/dans/dvcli/command/CollectionCreateDatasetTest.java +++ b/src/test/java/nl/knaw/dans/dvcli/command/CollectionCreateDatasetTest.java @@ -113,6 +113,27 @@ public void doCall_is_happy() throws Exception { verifyNoMoreInteractions(api); } + @Test + public void doCall_with_dir_as_json() throws Exception { + + var metadataKeys = new HashMap(); + var jsonFile = "src/test/resources/debug-etc"; // invalid json file, don't care + var client = new DataverseClient(new DataverseClientConfig(new URI("http://localhost:8080"), "apiToken")); + + // command under test + CollectionCreateDataset cmd = getCmd("A", metadataKeys, jsonFile, client); + cmd.doCall(); + + assertThat(stderr.toString()).isEqualTo(""" + A: FAILED: Exception type = IOException, message = Is a directory + """); + assertThat(stdout.toString()).isEqualTo(""" + INFO Starting batch processing + INFO Processing item 1 of 1 + INFO Finished batch processing of 1 items + """); + } + private static CollectionCreateDataset getCmd(String target, HashMap metadataKeys, String json, final DataverseClient client) throws NoSuchFieldException, IllegalAccessException {