diff --git a/src/main/java/com/glencoesoftware/bioformats2raw/Converter.java b/src/main/java/com/glencoesoftware/bioformats2raw/Converter.java index c760bac..7a7fcd2 100644 --- a/src/main/java/com/glencoesoftware/bioformats2raw/Converter.java +++ b/src/main/java/com/glencoesoftware/bioformats2raw/Converter.java @@ -867,7 +867,7 @@ public void resetResolutions() { /** */ public void resetSeriesList() { - seriesList.clear(); + seriesList = new ArrayList(); } /** @@ -927,7 +927,7 @@ public void resetCompression() { /** */ public void resetCompressionProperties() { - compressionProperties.clear(); + compressionProperties = new HashMap(); } /** @@ -1003,7 +1003,7 @@ public void resetFillValue() { /** */ public void resetReaderOptions() { - readerOptions.clear(); + readerOptions = new ArrayList(); } /** @@ -1048,7 +1048,7 @@ public void resetDimensionOrder() { * @return path to input data */ public String getInputPath() { - return inputPath.toString(); + return inputPath == null ? null : inputPath.toString(); } /** diff --git a/src/test/java/com/glencoesoftware/bioformats2raw/test/ZarrTest.java b/src/test/java/com/glencoesoftware/bioformats2raw/test/ZarrTest.java index 3acdb19..426bd62 100644 --- a/src/test/java/com/glencoesoftware/bioformats2raw/test/ZarrTest.java +++ b/src/test/java/com/glencoesoftware/bioformats2raw/test/ZarrTest.java @@ -1983,6 +1983,40 @@ public void testOptionsAPI() throws Exception { } } + /** + * Check that setting and resetting options via API will reset options to + * their default values. + */ + @Test + public void testResetOptions() throws Exception { + input = fake("series", "2", "sizeX", "4096", "sizeY", "4096"); + + Converter apiConverter = new Converter(); + apiConverter.setInputPath(input.toString()); + apiConverter.setOutputPath(output.toString()); + apiConverter.setSeriesList(Collections.singletonList(1)); + apiConverter.setTileWidth(128); + apiConverter.setTileHeight(128); + + assertEquals(apiConverter.getInputPath(), input.toString()); + assertEquals(apiConverter.getOutputPath(), output.toString()); + assertEquals(apiConverter.getSeriesList(), Collections.singletonList(1)); + assertEquals(apiConverter.getTileWidth(), 128); + assertEquals(apiConverter.getTileHeight(), 128); + + apiConverter.resetInputPath(); + assertEquals(apiConverter.getInputPath(), null); + + apiConverter.setInputPath(input.toString()); + + apiConverter.resetOptions(); + assertEquals(apiConverter.getInputPath(), null); + assertEquals(apiConverter.getOutputPath(), null); + assertEquals(apiConverter.getSeriesList().size(), 0); + assertEquals(apiConverter.getTileWidth(), 1024); + assertEquals(apiConverter.getTileHeight(), 1024); + } + /** * @param root dataset root path * @param rowCount total rows the plate could contain